Skip to content

Commit

Permalink
make-automaps: create auto.pkg from /etc/mxpkg
Browse files Browse the repository at this point in the history
  • Loading branch information
donald committed Feb 15, 2017
1 parent 7fe2202 commit fc1f6f0
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions make-automaps/make-automaps
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
use strict;
use warnings;

chomp (my $hostname=`uname -n`);$hostname=~s/\..*//;

sub convert_map {
my ($amd,$auto,$parse_line)=@_;
open IN,'<',$amd or die "$amd: $!\n";
Expand Down Expand Up @@ -65,6 +67,26 @@ sub parse_map_line {
sub parse_subkey_line { my ($key,$host,$fs)=parse_map_line(@_); return $key ? "$key $host:$fs/$key" : undef; }
sub parse_nosubkey_line { my ($key,$host,$fs)=parse_map_line(@_); return $key ? "$key $host:$fs" : undef; }

sub create_pkg_map {
my $cache;

# ensure the map exists even if we fail out later
open my $out,'>','/etc/automount/auto.pkg' or die "/etc/automount/auto.pkg: $!\n";
open my $in,'<','/etc/mxpkg' or return warn "/etc/mxpkg: $!\n";
while (<$in>) {
s/#.*//;
/\S/ or next;
my ($pkg,$flags)=split ' ';
my $local="/amd/$hostname/P/pkg/$pkg";
my $rw = $flags eq 'BUILD' ? ' -rw' : '';
if (-d $local) {
print $out "$pkg$rw :$local\n";
} else {
print $out "$pkg$rw ex:/amd/ex/X/X2008/package/pkg/$pkg\n";
}
}
}

-d "/etc/automount" or mkdir("/etc/automount") or die "/etc/automount: $!\n";

convert_map('/etc/amd/amd.jbod','/etc/automount/auto.jbod',\&parse_jbod_line);
Expand All @@ -76,8 +98,7 @@ convert_map('/etc/amd/amd.scratch','/etc/automount/auto.scratch',\&parse_subkey_
convert_map('/etc/amd/amd.src','/etc/automount/auto.src',\&parse_subkey_line);

######################################## /scratch

chomp (my $hostname=`uname -n`);$hostname=~s/\..*//;

open O,'>>','/etc/automount/auto.scratch' or die "/etc/automount/auto.scratch: $!\n";
print O<<"eof";
local :/amd/$hostname/S/scratch
Expand Down Expand Up @@ -148,7 +169,7 @@ for my $package (qw(kde qt xfce)) {

######################################## /pkg

open O,'>>','/etc/automount/auto.pkg' or die "/etc/automount/auto.pkg: $!\n";
create_pkg_map();

########################################

Expand Down

0 comments on commit fc1f6f0

Please sign in to comment.