Annotation of loncom/build/make_rpm.pl, revision 1.7
1.1 harris41 1: #!/usr/bin/perl
2:
3: # Scott Harrison, September 30
4: # Automatically generate RPM listing files
5: # from file listing.
6:
7: # GNU General Public License, Version 2, June 1991
8: # See http://www.gnu.org/copyleft/gpl.html.
9:
1.2 harris41 10: # This script does actually "build" the RPM.
1.1 harris41 11:
1.2 harris41 12: # This script also generates and then deletes temporary
1.1 harris41 13: # files (and binary root directory tree) to build an RPM with.
14:
15: # I still need to implement the CONFIGURATION_FILES and
16: # DOCUMENTATION_FILES portion of the command line interface to this
17: # script.
18:
19: # Take in a file list (from standard input),
20: # a description tag and version tag from command line argument
1.2 harris41 21: # and temporarily generate a:
1.1 harris41 22: # RPM .spec file
23: # RPM Makefile
24: # SourceRoot
1.2 harris41 25:
26: # A resulting .rpm file is generated.
1.1 harris41 27:
28: unless (-e "/usr/lib/rpm/rpmrc") {
29: print <<END;
30: ERROR: This script only works with a properly installed RPM builder application.
31: Cannot find /usr/lib/rpm/rpmrc, so cannot generate customized rpmrc file.
32: Script aborting.
33: END
34: }
35:
36: my ($tag,$version,$configuration_files,$documentation_files,$pathprefix)=@ARGV;
37: @ARGV=();
1.3 harris41 38:
1.1 harris41 39: if (!$version) {
40: print "Usage: <TAG> <VERSION> [CONFIGURATION_FILES] [DOCUMENTATION] [PATHPREFIX]\n";
41: print "Standard input provides the list of files to work with.\n";
42: print "TAG, required descriptive tag. For example, a kerberos software package might be tagged as \"krb4\".\n";
43: print "VERSION, required version. Needed to generate version information for the RPM. This should be in the format N.M where N and M are integers.\n";
44: print "CONFIGURATION_FILES, optional comma-separated listing of files to be treated as configuration files by RPM (and thus subject to saving during RPM upgrades).\n";
45: print "DOCUMENTATION, optional comma-separated listing of files to be treated as documentation files by RPM (and thus subject to being placed in the /usr/doc/RPM-NAME directory during RPM installation).\n";
46: print "PATHPREFIX, optional path to be removed from file listing. This is in case you are building an RPM from files elsewhere than root-level. Note, this still depends on a root directory hierarchy after PATHPREFIX.\n";
47: exit;
48: }
49:
50: mkdir $tag,0755;
51: mkdir "$tag/BuildRoot",0755;
52: mkdir "$tag/SOURCES",0755;
53: mkdir "$tag/SOURCES/LON-CAPA-$tag-$version",0755;
54: mkdir "$tag/SPECS",0755;
55: mkdir "$tag/BUILD",0755;
56: mkdir "$tag/SRPMS",0755;
57: mkdir "$tag/RPMS",0755;
58: mkdir "$tag/RPMS/i386",0755;
59:
60: my $file;
61: my $binaryroot="$tag/BinaryRoot";
62: my ($type,$size,$octalmode,$user,$group);
63:
64: $currentdir=`pwd`; chop $currentdir; $invokingdir=$currentdir; $currentdir.="/$tag";
65:
66: open (IN,"</usr/lib/rpm/rpmrc") or die("Can't open /usr/lib/rpm/rpmrc");
67: @lines=<IN>;
68: close IN;
69:
70: open (RPMRC,">$tag/SPECS/rpmrc");
71: foreach $line (@lines) {
72: if ($line=~/^macrofiles/) {
73: chop $line;
74: $line.=":./rpmmacros\n";
75: }
76: print RPMRC $line;
77: }
78: close RPMRC;
79:
80: open (RPMMACROS,">$tag/SPECS/rpmmacros");
81: print RPMMACROS <<END;
82: \%_topdir $currentdir
83: \%__spec_install_post \\
84: /usr/lib/rpm/brp-strip \\
85: /usr/lib/rpm/brp-strip-comment-note \\
86: \%{nil}
87: END
88: close RPMMACROS;
89:
1.7 ! harris41 90: # This needs to be dynamically based upon doc/otherfiles/rpm_list.txt
! 91: # at some point.
! 92: my $requires="";
! 93: if ($tag eq "setup") {
! 94: $requires=<<END;
! 95: Requires: setup
! 96: END
! 97: }
! 98: elsif ($tag eq "base") {
! 99: $requires=<<END;
! 100: Requires: LON-CAPA-base
! 101: Requires: LON-CAPA-krb4
! 102: Requires: LON-CAPA-mysql
! 103: Requires: LON-CAPA-systemperl
! 104: Requires: raidtools
! 105: Requires: ncurses
! 106: Requires: popt
! 107: Requires: tcsh
! 108: Requires: redhat-release
! 109: Requires: diffutils
! 110: Requires: ed
! 111: Requires: dialog
! 112: Requires: rmt
! 113: Requires: sed
! 114: Requires: which
! 115: Requires: gawk
! 116: Requires: mingetty
! 117: Requires: info
! 118: Requires: portmap
! 119: Requires: openssh-clients
! 120: Requires: openssh
! 121: Requires: openssh-server
! 122: Requires: openssl
! 123: Requires: basesystem
! 124: Requires: ldconfig
! 125: Requires: filesystem
! 126: Requires: mktemp
! 127: Requires: termcap
! 128: Requires: shadow-utils
! 129: Requires: libtermcap
! 130: Requires: MAKEDEV
! 131: Requires: utempter
! 132: Requires: bash
! 133: Requires: logrotate
! 134: Requires: SysVinit
! 135: Requires: chkconfig
! 136: Requires: textutils
! 137: Requires: pwdb
! 138: Requires: vixie-cron
! 139: Requires: procps
! 140: Requires: modutils
! 141: Requires: psmisc
! 142: Requires: sysklogd
! 143: Requires: authconfig
! 144: Requires: zlib
! 145: Requires: sh-utils
! 146: Requires: mailcap
! 147: Requires: anacron
! 148: Requires: bc
! 149: Requires: bdflush
! 150: Requires: bind-utils
! 151: Requires: cpio
! 152: Requires: crontabs
! 153: Requires: etcskel
! 154: Requires: e2fsprogs
! 155: Requires: samba-client
! 156: Requires: apache-devel
! 157: Requires: autofs
! 158: Requires: findutils
! 159: Requires: gdbm
! 160: Requires: getty_ps
! 161: Requires: readline
! 162: Requires: glib10
! 163: Requires: inetd
! 164: Requires: losetup
! 165: Requires: gnupg
! 166: Requires: gpgp
! 167: Requires: urw-fonts
! 168: Requires: mailx
! 169: Requires: gzip
! 170: Requires: ld.so
! 171: Requires: less
! 172: Requires: passwd
! 173: Requires: sysreport
! 174: Requires: ncompress
! 175: Requires: mount
! 176: Requires: lilo
! 177: Requires: bzip2
! 178: Requires: grep
! 179: Requires: memprof
! 180: Requires: mars-nwe
! 181: Requires: pidentd
! 182: Requires: procinfo
! 183: Requires: units
! 184: Requires: routed
! 185: Requires: quota
! 186: Requires: pam
! 187: Requires: stat
! 188: Requires: setserial
! 189: Requires: mod_perl
! 190: Requires: rootfiles
! 191: Requires: nfs-utils
! 192: Requires: sendmail
! 193: Requires: sharutils
! 194: Requires: tmpwatch
! 195: Requires: shapecfg
! 196: Requires: tcp_wrappers
! 197: Requires: unzip
! 198: Requires: tetex-dvips
! 199: Requires: tetex-afm
! 200: Requires: tetex-latex
! 201: Requires: xntp3
! 202: Requires: rpm
! 203: Requires: wu-ftpd
! 204: Requires: setup
! 205: Requires: glibc
! 206: Requires: fileutils
! 207: Requires: initscripts
! 208: Requires: netatalk
! 209: Requires: apache
! 210: Requires: bash2
! 211: Requires: dev
! 212: Requires: samba
! 213: Requires: ghostscript
! 214: Requires: kernel-headers
! 215: Requires: kernel
! 216: Requires: linuxconf
! 217: Requires: tetex
! 218: Requires: tetex-fonts
! 219: Requires: util-linux
! 220: Requires: vim-common
! 221: Requires: perl
! 222: Requires: cracklib
! 223: Requires: cracklib-dicts
! 224: Requires: cdrecord
! 225: Requires: ghostscript-fonts
! 226: Requires: libgr
! 227: Requires: libjpeg
! 228: Requires: libpng
! 229: Requires: libungif-progs
! 230: Requires: libtiff
! 231: Requires: libungif
! 232: Requires: samba-common
! 233: Requires: ImageMagick
! 234: Requires: libgr-progs
! 235: Requires: man-pages
! 236: Requires: tar
! 237: Requires: vim-minimal
! 238: END
! 239: }
! 240: else {
! 241: $requires=<<END;
! 242: Requires: LON-CAPA-base
! 243: END
! 244: }
1.1 harris41 245: open (SPEC,">$tag/SPECS/LON-CAPA-$tag-$version.spec");
246:
247: print SPEC <<END;
248: Summary: Files for the $tag component of LON-CAPA.
249: Name: LON-CAPA-$tag
250: Version: $version
251: Release: 1
252: Vendor: Laboratory for Instructional Technology Education, Division of Science and Mathematics Education, Michigan State University.
253: BuildRoot: $currentdir/BuildRoot
254: Copyright: GNU General Public License. Version 2, June 1991. Michigan State University patents may apply.
255: Group: Utilities/System
256: Source: LON-CAPA-$tag-$version.tar.gz
257: AutoReqProv: no
1.7 ! harris41 258: $requires
1.1 harris41 259: # requires: filesystem
260: \%description
261: This package is automatically generated by the make_rpm.pl perl
262: script (written by the LON-CAPA development team, www.lon-capa.org,
263: Scott Harrison). This implements the $tag component for LON-CAPA.
264: For more on the LON-CAPA project, visit http://www.lon-capa.org/.
265:
266: \%prep
267: \%setup
268:
269: \%build
270: rm -Rf "$currentdir/BuildRoot"
271:
272: \%install
273: make ROOT="\$RPM_BUILD_ROOT" SOURCE="$currentdir/BinaryRoot" directories
274: make ROOT="\$RPM_BUILD_ROOT" SOURCE="$currentdir/BinaryRoot" files
275: make ROOT="\$RPM_BUILD_ROOT" SOURCE="$currentdir/BinaryRoot" links
276:
277: \%pre
278: echo "***********************************************************************"
279: echo "LON-CAPA LearningOnline with CAPA"
280: echo "http://www.lon-capa.org/"
281: echo "Gerd Kortemeyer, et al"
282: echo "Laboratory for Instructional Technology Education"
283: echo "Michigan State University"
284: echo "General Public License, Version 2, June 1991"
285: echo "** Michigan State University patents may apply **"
286: echo " "
287: echo "This installation assumes an installation of Redhat 6.2"
288: echo " "
289: echo "The server computer should be currently connected to the ethernet"
290: echo " "
291: echo "The files in this package are only those for the $tag component."
292: echo "Configuration files are sometimes part of the LON-CAPA-base RPM."
293: echo "***********************************************************************"
294:
295: \%post
296: \%postun
297:
298: \%files
299: END
300:
301: foreach $file (<>) {
302: chop $file;
1.4 harris41 303: my $comment="";
304: if ($file=~/\s+\#(.*)$/) {
305: $file=~s/\s+\#(.*)$//;
306: $comment=$1;
307: }
308: my $config="";
309: if ($comment=~/config/i) {
310: $config="\%config ";
311: }
1.1 harris41 312: if (($type,$size,$octalmode,$user,$group)=find_info($file)) {
313: $octalmode="0" . $octalmode if length($octalmode)<4;
314: if ($pathprefix) {
315: $file=~s/^$pathprefix//;
316: }
317: if ($type eq "files") {
318: push @{$BinaryRootMakefile{$type}},"\tinstall -D -m $octalmode $pathprefix$file $binaryroot$file\n";
319: push @{$Makefile{$type}},"\tinstall -D -m $octalmode \$(SOURCE)$file \$(ROOT)$file\n";
1.4 harris41 320: push @{$dotspecfile{$type}},"$config\%attr($octalmode,$user,$group) $file\n";
1.1 harris41 321: }
322: elsif ($type eq "directories") {
323: push @{$BinaryRootMakefile{$type}},"\tinstall -m $octalmode -d $binaryroot$file\n";
324: push @{$Makefile{$type}},"\tinstall -m $octalmode -d \$(SOURCE)$file \$(ROOT)$file\n";
325: push @{$dotspecfile{$type}},"\%dir \%attr($octalmode,$user,$group) $file\n";
326: }
327: elsif ($type eq "links") {
328: my $link=$size; # I use the size variable to pass the link value from the subroutine find_info
329: $link=~s/^$pathprefix//;
330: push @{$BinaryRootMakefile{$type}},"\tln -s $link $binaryroot$file\n";
331: push @{$Makefile{$type}},"\tln -s $link \$(ROOT)$file\n";
332: push @{$dotspecfile{$type}},"\%attr(-,$user,$group) $file\n";
333: }
334: }
335: }
336:
337: open OUT, ">$tag/SOURCES/LON-CAPA-$tag-$version/Makefile";
338: open OUT2, ">$tag/BinaryRootMakefile";
339: foreach $type ("directories","files","links") {
340: print OUT "$type\:\n";
341: print OUT join("",@{$Makefile{$type}});
342: print OUT "\n";
343: print OUT2 "$type\:\n";
344: print OUT2 join("",@{$BinaryRootMakefile{$type}});
345: print OUT2 "\n";
346: print SPEC join("",@{$dotspecfile{$type}});
347: }
348: close OUT2;
349: close OUT;
350:
351:
352: close SPEC;
353:
354: `make -f $tag/BinaryRootMakefile directories`;
355: `make -f $tag/BinaryRootMakefile files`;
356: `make -f $tag/BinaryRootMakefile links`;
357:
358: print `cd $currentdir/SOURCES; tar czvf LON-CAPA-$tag-$version.tar.gz LON-CAPA-$tag-$version`;
359: print `cd $currentdir/SPECS; rpm --rcfile=./rpmrc -ba LON-CAPA-$tag-$version.spec; cd ../RPMS/i386; cp LON-CAPA-$tag-$version-1.i386.rpm $invokingdir/.`;
1.5 harris41 360: print `cd $invokingdir; rm -Rf $tag`;
1.1 harris41 361:
362: sub find_info {
363: # only look for
364: my ($file)=@_;
365: my $line;
366: if (($line=`find $file -type f -prune`)=~/^$file\n/) {
367: $line=`find $file -type f -prune -printf "\%s\t\%m\t\%u\t\%g"`;
368: return ("files",split(/\t/,$line));
369: }
370: elsif (($line=`find $file -type d -prune`)=~/^$file\n/) {
371: $line=`find $file -type d -prune -printf "\%s\t\%m\t\%u\t\%g"`;
372: return ("directories",split(/\t/,$line));
373: }
374: elsif (($line=`find $file -type l -prune`)=~/^$file\n/) {
1.6 harris41 375: $line=`find $file -type l -prune -printf "\%l\t\%m\t\%u\t\%g"`;
1.1 harris41 376: return ("links",split(/\t/,$line));
377: }
378:
379: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>