# feed this into perl eval "exec perl -S $0 $*" if $running_under_some_shell; # $Id: packinit.SH 1 2006-08-24 12:32:52Z rmanfredi $ # # Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi # # You may redistribute only under the terms of the Artistic Licence, # as specified in the README file that comes with the distribution. # You may reuse parts of this distribution only within the terms of # that same Artistic Licence; a copy of which may be found at the root # of the source tree for dist 4.0. # # $Log: packinit.SH,v $ # Revision 3.0.1.4 1997/02/28 14:55:14 ram # patch61: fixed one wrong ':' comment in .package # # Revision 3.0.1.3 1994/10/29 15:43:49 ram # patch36: added support for user-defined C and shell file extensions # patch36: now asks whether a ChangeLog file is to be managed # # Revision 3.0.1.2 1994/01/24 13:54:07 ram # patch16: can now configure mailing list knowledge from packinit # # Revision 3.0.1.1 1993/08/19 06:41:53 ram # patch1: leading config.sh searching was not aborting properly # # Revision 3.0 1993/08/18 12:04:05 ram # Baseline for dist 3.0 netwide release. # $orgname='PROCURA B.V.'; $myhostname='lx09'; $mydomain='.procura.nl'; $nametype='other'; print < $mypackver) { die "This .package file was produced by a newer packinit than I am.\n". "Please find a packinit of version $packver or greater.\n"; } } elsif (-f '../.package' || -f '../../.package' || -f '../../../.package') { die "Run in top level directory only.\n"; } # Now set up to do reads with possible shell escape. sub myread { ($rp,$dflt) = @_; $rp .= " [$dflt]"; print "$rp "; $ans='!'; while ($ans =~ /^!/) { $ans = ; chop($ans); if ($ans eq '!') { system '/bin/sh'; print "\n$rp "; } elsif ($ans =~ s/^!//) { system '/bin/sh', '-c', $ans; print "\n$rp "; } } $ans = $dflt if $ans eq ''; $ans = '' if $ans eq 'none'; $ans; } $dflt = $package; ($dflt) = (`pwd | tr "[A-Z]" "[a-z]"` =~ m|.*/(.*)|) unless $package; print <; $rcs = shift(@rcs); if (! -f $rcs) { $rcs = shift(@rcs); if (! -f $1) { print "I don't see any RCS files there (yet)."; $dflt='1.1'; } } $revs=0; if ($dflt eq '') { $rlog = `rlog $rcs`; ($dflt) = ($rlog =~ /\nhead:\s*(\d+\.\d+)/); $rlog = `rlog -r$dflt.1- -r$dflt.2- -r$dflt.3- -r$dflt.4- $rcs`; ($revs) = ($rlog =~ /selected revisions:\s*([\d.]+)/); $dflt='1.1' if $dflt eq ''; } print < 1) { print <.package') || die "Can't create .package"; chop($date = `date`); print PACKAGE <) { next if /^:/; next if /^#/; if (($var,$val) = /^\s*(\w+)=(.*)/) { $val = "\"$val\"" unless $val =~ /^['"]/; eval "\$$var = $val;"; } } close PACKAGE; } sub getlogname { local($logname) = $ENV{'USER'}; $logname = $ENV{'LOGNAME'} unless $logname; chop($logname = `who am i`) unless $logname; $logname =~ s/\s.*//; $logname =~ s/.*!//; $logname; } sub getfullname { local($logname) = @_; local($foo,$bar); if ($ENV{'NAME'}) { $ENV{'NAME'}; } else { open(PASSWD,'/etc/passwd') || die "Can't open /etc/passwd"; while () { /(\w+):/; last if $1 eq $logname; } close PASSWD; local($login,$passwd,$uid,$gid,$gcos,$home,$shell) = split(/:/); if (-f "$home/.fullname") { open(FN,"$home/.fullname"); chop($foo = ); close FN; $foo; } elsif ($nametype eq 'bsd') { $gcos =~ s/[,;].*//; if ($gcos =~ /&/) { # oh crud ($foo,$bar) = ($logname =~ /(.)(.*)/); $foo =~ y/a-z/A-Z/; $gcos =~ s/&/$foo$bar/; } $gcos; } else { $gcos =~ s/[(].*//; $gcos =~ s/.*-//; $gcos; } } } # Perform ~name expansion ala ksh... # (banish csh from your vocabulary ;-) sub tilda_expand { local($path) = @_; return $path unless $path =~ /^~/; $path =~ s:^~([^/]+):(getpwnam($1))[$[+7]:e; # ~name $path =~ s:^~:$ENV{'HOME'} || (getpwuid($<))[$[+7]:e; # ~ $path; }