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