diff options
-rw-r--r-- | .gitignore | 5 | ||||
-rw-r--r-- | GNUmakefile | 95 | ||||
-rw-r--r-- | Makefile | 14 | ||||
-rw-r--r-- | install.pl | 251 |
4 files changed, 100 insertions, 265 deletions
@@ -1 +1,6 @@ *~ +\#* +.emacs* +listarchive +*.tar +*.tar.gz diff --git a/GNUmakefile b/GNUmakefile new file mode 100644 index 0000000..27707ac --- /dev/null +++ b/GNUmakefile @@ -0,0 +1,95 @@ +# usage: +# +# 1. make PREFIX=prefix [MAILMANSRC=mdir] install +# Installs everything. +# +# 2. make PREFIX=prefix [MAILMANSRC=mdir] install-cgi +# Builds (if necessary) and installs the listarchive cgi. +# MAILMANSRC must be set for building the program. +# Installation directory is $(PREFIX)/cgi-bin. Set CGIDIR +# to override. +# +# 3. make PREFIX=prefix install-Mailman +# Installs scripts in the Mailman subdirectory. +# Installation directory is $(PREFIX)/Mailman. Set MAILMANDIR +# to override. +# +# 4. make PREFIX=prefix install-templates +# Installs templates to $(PREFIX)/templates. Set TEMPLATESDIR +# to override. +# +# 5. make PREFIX=prefix install-bin +# Installs binary scripts to $(PREFIX)/bin. Set BINDIR to +# override. +# +# 6. make PREFIX=prefix install-man +# Installs manpages to $(PREFIX)/man. Set MANDIR to override. +# +# 7. make PREFIX=prefix install-htdocs +# Installs static HTML files to $(PREFIX)/htdocs. Set HTDOCSDIR +# to override. +# +# 8. make MAILMANSRC=mdir listarchive +# Builds the listarchive cgi. +# +# 9. make clean +# Remove created files. +# +# 10. make help +# Shows this help list. +# +# usage ends + +help: + @sed -n \ + -e '/# usage ends/,$$d' \ + -e 's/^# //' \ + -e ta \ + -e 's/^#$$//' \ + -e ta \ + -e d \ + -e :a \ + -e '/^usage:/,$$p' $(firstword $(MAKEFILE_LIST)) + +listarchive: + @if [ -z "$(MAILMANSRC)" ]; then \ + echo >&2 "Please set MAILMANSRC to point to the mailman-2.x tree"; \ + false; \ + else \ + make -C $(MAILMANSRC)/src CGI_PROGS=`pwd`/listarchive `pwd`/listarchive; \ + fi + +define geninstall +install-$(1):; + install -d $$(DESTDIR)$$($(shell echo $(1) | tr '[:lower:]' '[:upper:]')DIR) + tar -C $(1) -cf - . | tar -C $$(DESTDIR)$$($(shell echo $(1) | tr '[:lower:]' '[:upper:]')DIR) -xpf - +endef + +ifndef PREFIX + $(if $(subst help,,$(MAKECMDGOALS)),$(error Please supply PREFIX)) +endif + +MAILMANDIR = $(PREFIX)/Mailman +BINDIR = $(PREFIX)/bin +HTDOCSDIR = $(PREFIX)/htdocs +TEMPLATESDIR = $(PREFIX)/templates +MANDIR = $(PREFIX)/man +CGIDIR = $(PREFIX)/cgi-bin + +TARGETS=\ + Mailman\ + templates\ + bin\ + man\ + htdocs + +$(foreach tgt,$(TARGETS),$(eval $(call geninstall,$(tgt)))) + +install-cgi: listarchive + install -d $(DESTDIR)$(CGIDIR) + install -o root -g mailman -m 2755 listarchive $(DESTDIR)$(CGIDIR) + +install: install-cgi $(foreach tgt,$(TARGETS), install-$(tgt)) + +clean: + rm listarchive diff --git a/Makefile b/Makefile deleted file mode 100644 index ec0b8c5..0000000 --- a/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -prefix = /usr -sysconfdir = $(prefix)/etc -sources=\ - foo.c\ - bar.c\ - baz.c -objects=$(sources:.c=.o) - -ifndef MAILMANDIR -$(error Please set MAILMANDIR) -endif - -listinfo: - make -C $(MAILMANDIR) CGI_PROGS=listarchive `pwd`/listarchive diff --git a/install.pl b/install.pl deleted file mode 100644 index 0bcc464..0000000 --- a/install.pl +++ /dev/null @@ -1,251 +0,0 @@ -use strict; -use Getopt::Long; -use File::Basename; -use File::Copy; -use File::Find; -use File::Path qw(make_path); -use Pod::Usage; -use Pod::Man; -use Data::Dumper; - -=head1 NAME - -install.pl - install Puszcza-specific Mailman extensions - -=head1 SYNOPSIS - -B<perl install.pl> -[B<-D> I<DIR>] -[B<-n>] -[B<--destdir=>I<DIR>] -[B<--htdocs-dir=>I<DIR>] -[B<--dry-run>] -I<MAILMAN-DIR> -[I<DIR>...] - -=head1 DESCRIPTION - -Installs Puszcza extensions to Mailman. This includes the B<mail.gnu.org.ua> -site, backend scripts for conversion to HTML and indexing, and B<listarchive> -CGI script. - -The I<MAILMAN-DIR> argument should point to B<Mailman> source directory. This -is a directory from where you installed B<Mailman>, in other words, -B<configure> and B<make install> should have already been run in it by the -time you run B<install.pl>. Also, this directory should be writable. - -Optional I<DIR> arguments select specific components to install. - -=head1 OPTIONS - -=over 4 - -=item B<-D>, B<--destdir=>I<DIR> - -Destination directory. This has the same meaning as B<DESTDIR> variable in -automake-generated makefiles. - -=item B<-n>, B<--dry-run> - -Do nothing, print what would have been done. - -=item B<--htdocs-dir=>I<DIR> - -Installation directory for the B<mail.gnu.org.ua> site. Defaults to -F<B<MAILMAN>/htdocs>, where B<MAILMAN> is Mailman installation prefix. - -=cut - -my $progname; -my $progdescr = "install Puszcza-specific Mailman extensions"; -my $dry_run; -my $destdir; -my $mailmandir; -my $htdocsdir; - -sub expvar { - my ($vtab, $name, $f, $t) = @_; - my $val = $vtab->{$name}; - return '' unless defined $val; - if (defined($f)) { - $val = join(' ', map { s/$f$/$t/; $_ } split(/\s+/, $val)); - } - return $val; -} - -sub parse_makefile_vars { - my $file = shift; - my %vtab; - - open(my $fd, '<', $file) or die "can't open $file: $!"; - while (<$fd>) { - chomp; - - if (/\\$/) { - chop; - $_ .= <$fd>; - redo; - } - - s/\s+$//; - s/#.*//; - next if ($_ eq ""); - - if (/^([a-zA-Z0-9_]+)\s*=\s*(.*)$/) { - $vtab{$1} = $2; - $vtab{$1} =~ s/\$\(([a-zA-Z0-9_]+)(?::([^)=]+)=([^)]+))?\)/expvar(\%vtab, $1, $2, $3)/gex; - } - } - close($fd); - return %vtab; -} - -# ## - -sub runcmd { - my ($cmd, $res) = @_; - system($cmd); - die "failed to execute \"$cmd\": $!" if ($? == -1); - die "\"$cmd\" died with signal " . ($? & 127) if ($? & 127); - die "\"$cmd\" exited with code " . ($? >> 8) if ($? >> 8); -} - -sub install { - my ($src, $dst) = @_; - print "$progname: Installing $src to $dst\n"; - find(sub { - return if /~$/; - my $dir = $File::Find::dir; - my $target; - if ($dir eq $src) { - $target = "$dst/$_"; - } else { - $dir =~ s#^$src/##; - $target = "$dst/$dir/$_"; - } - if (-d $_) { - unless (-d $target) { - print "$progname: creating $target\n"; - make_path($target) unless $dry_run; - } - } else { - print "$progname: cp $_ $target\n"; - unless ($dry_run or copy($_, $target)) { - print STDERR "error copying file: $!\n" - } - } - }, $src); -} - -sub dir_src { - my $dir = shift; - $dir = "$mailmandir/$dir"; - die "$dir does not exist or is not a directory" unless -d $dir; - die "$dir is not writable" unless -d $dir; - my $opt = '-n' if $dry_run; - $opt .= " DESTDIR=\"$destdir\"" if defined($destdir); - print "$progname: building and installing listarchive\n"; - runcmd("make -C $dir $opt CGI_PROGS=listarchive listarchive"); - runcmd("make -C $dir $opt CGI_PROGS=listarchive MAIL_PROGS= install"); -} - -sub dest { - my ($dir, $var) = @_; - my %vtab = parse_makefile_vars("$dir/Makefile"); - die "$var not defined in $dir/Makefile" - unless exists $vtab{$var}; - my $dest = $vtab{$var}; - $dest = "$destdir/$dest" if defined($destdir); - return $dest; -} - -sub dir_default { - my ($base, $ref) = @_; - my $dir = "$mailmandir/$base"; - die "$dir does not exist or is not a directory" unless -d $dir; - install($base, dest($dir, $ref->{var})); -} - -sub dir_htdocs { - my ($base, $ref) = @_; - my $dest; - if (defined($htdocsdir)) { - $dest = $htdocsdir; - } else { - my %vtab = parse_makefile_vars("$mailmandir/Makefile"); - die "prefix not defined in $mailmandir/Makefile" - unless exists $vtab{prefix}; - $dest = "$vtab{prefix}/$base"; - $dest = "$destdir/$dest" if defined($destdir); - } - install($base, $dest); -} - -sub dir_man { - my ($base, $ref) = @_; - my $dest; - my %vtab = parse_makefile_vars("$mailmandir/Makefile"); - die "prefix not defined in $mailmandir/Makefile" - unless exists $vtab{prefix}; - $dest = "$vtab{prefix}/$base"; - $dest = "$destdir/$dest" if defined($destdir); - print "$progname: Installing $base to $dest\n"; - for (my $i = 1; $i <= 8; ++$i) { - my @files = map { s#$base/##; $_ } glob "$base/*.$i"; - next unless $#files >= 0; - my $d = "$dest/man$i"; - make_path($d) unless -d $d; - foreach my $f (@files) { - print "$progname: cp $f $d/$f\n"; - unless ($dry_run or copy("$base/$f", "$d/$f")) { - print STDERR "error copying file: $!\n" - } - } - } -} - -my %dirs = ( - 'src' => { proc => \&dir_src }, - 'Mailman' => { proc => \&dir_default, var => 'PACKAGEDIR' }, - 'templates' => { proc => \&dir_default, var => 'TEMPLATEDIR' }, - 'bin' => { proc => \&dir_default, var => 'SCRIPTSDIR' }, - 'man' => { proc => \&dir_man }, - 'htdocs' => { proc => \&dir_htdocs } -); -# ## -$progname = basename($0); -GetOptions("h" => sub { - pod2usage(-message => "$progname: $progdescr", - -exitstatus => 0); - }, - "help" => sub { - pod2usage(-verbose => 2, -exitstatus => 0); - }, - "usage" => sub { - pod2usage(-verbose => 0, -exitstatus => 0); - }, - "destdir|D=s" => \$destdir, - "htdocs-dir=s" => \$htdocsdir, - "dry-run|n" => \$dry_run) or exit(1); - -die "bad number of arguments" unless $#ARGV>=0; - -$mailmandir = shift @ARGV; - -die "$mailmandir does not exist or is not a directory" unless -d $mailmandir; - -@ARGV = ('src', - 'Mailman', - 'templates', - 'bin', - 'man', - 'htdocs') if ($#ARGV == -1); - -foreach my $arg (@ARGV) { - die "unknown source: $arg" unless exists $dirs{$arg}; - my $v = $dirs{$arg}; - &{$v->{proc}}($arg, $v); -} - - - |