source: /cluster/svnroot/bccd-ng/trunk/bin/build_livecd.pl @ 2324

Last change on this file since 2324 was 2324, checked in by fitz, 11 years ago

Add bnx2 firmware appropriate to our driver (#488)

  • Property svn:executable set to *
File size: 28.8 KB
Line 
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5use Getopt::Long;
6use Pod::Usage;
7use File::Path;
8use File::Temp;
9use File::Copy;
10use WWW::Mechanize;
11use POSIX;
12use Bccd;
13use Cwd;
14use Bccd::TestDb qw/open_db insert_results/;
15use Readonly;
16
17my %opts;
18
19my($debmirror,$websvn,$rc,$out,$ft,$tmpdir,$cwd,$svnrev,
20   $Bccd,$allout,$rpkgs,$nouid,$nogid,$debmirror_host,
21   $debmirror_name,$debsecmirror,$dir);
22my(@lsof,@pids,@rd);
23
24GetOptions(
25    'arch=s' => \$opts{'arch'},
26    'outiso=s' => \$opts{'outiso'},
27    'suite=s' => \$opts{'suite'},
28    'nocleanup' => \$opts{'nocleanup'},
29    'updatedb=s' => \$opts{'updatedb'},
30    'svnrev=i' => \$opts{'svnrev'},
31    "debug" => \$opts{'debug'},
32    "info" => \$opts{'info'},
33    "debmirror=s" => \$opts{'debmirror'},
34    "websvn=s" => \$opts{'websvn'},
35    "dir=s" => \$opts{'dir'},
36    'help' => \$opts{'help'}
37    );
38
39if($opts{'help'}) {
40    pod2usage(1);
41}
42
43if(!$opts{'arch'} ||
44   !$opts{'outiso'} ||
45   !$opts{'suite'}
46    ) {
47    pod2usage(2);
48}
49
50Readonly my $PROJECT => 'bccd';
51$ft = new File::Temp();
52if(defined($opts{'dir'})) {
53        $dir = $opts{'dir'};
54} else {
55        $dir = File::Spec->tmpdir;
56}
57
58if( $opts{'nocleanup'} ) {
59    $tmpdir = $ft->tempdir('$PROJECT',DIR => $dir,CLEANUP => 0);
60} else {
61    $tmpdir = $ft->tempdir('$PROJECT',DIR => $dir,CLEANUP => 1);
62}
63$Bccd = new Bccd();
64
65if(defined($opts{'debmirror'})) {
66        $debmirror_host = $opts{'debmirror'};
67} else {
68        $debmirror_host = "debmirror.cluster.earlham.edu";
69}
70$debmirror = "http://$debmirror_host/apt/mirror/bccd-ng/debian/";
71
72if(defined($opts{'websvn'})) {
73        $websvn = $opts{'websvn'};
74} else {
75        $websvn = "http://bccd-ng.cluster.earlham.edu/svn/bccd-ng/trunk/";
76}
77
78Readonly my $BUILDDIR   => $tmpdir."/build-bccd/";
79Readonly my $SOFTWARE   => "/bccd/software/";
80Readonly my $PROJDIR    => $BUILDDIR."/diskless/bccd/";
81Readonly my $BCCDCLIENT => $BUILDDIR."/diskless/clients/";
82Readonly my $NEWHOME    => "$BUILDDIR/bccd/home";
83Readonly my $CHECKIN    => "$NEWHOME/meta/nodes/";
84Readonly my $LIBFETCH   => "/root/liberate";
85$ENV{'DEBIAN_FRONTEND'} = "noninteractive";
86Readonly my $PACKAGES   => "screen openssh-client openssh-server less make gcc-4.2 g++-4.2 flex bison gdb alien lsb-rpm cvs bzip2 sudo yum debootstrap rsync dhcp3-server tftpd-hpa tcpdump syslinux syslinux-common subversion nfs-common nfs-kernel-server ncurses-base ncurses-bin libncurses5 libncurses5-dev psmisc vim iproute pciutils host bc ntp ntpdate debconf-utils dhcpcd rsh-client rsh-server xbase-clients libxt-dev lesstif2 lesstif2-dev ipcalc dialog lvm2 grub parted tzdata xserver-xorg-video-fbdev xfonts-100dpi xfonts-75dpi xfonts-scalable xserver-xorg-video-all fontconfig xfonts-base gpm udev vtwm aterm rxvt xbase-clients menu bbkeys libwww-mechanize-perl postgresql-client-common postgresql-client-8.3 libdbi-perl libdbd-pg-perl strace tcsh libnet-dhcp-perl libnetaddr-ip-perl libnet-ip-perl libstdc++5 pdnsd csh libterm-readkey-perl libsvn-perl libui-dialog-perl libreadonly-perl sshfs autofs libnet-dhcp-perl dnsutils libfile-touch-perl libnet-cidr-perl arping dosfstools gawk dc glutg3-dev libxi-dev wireless-tools snmp snmpd";
87Readonly my $EXTRA_PACKAGES => "fftw2 fftw-dev sfftw-dev sfftw2 automake1.7 console-tools libreadline5-dev hal libxmu-headers libxmu-dev gfortran ethtool libssl0.9.8 libblas-dev libblas-dev atlas3-base atlas3-base-dev atlas3-base refblas3 lapack3 atlas3-test libg2c0-dev libg2c0 apache2 iceweasel xpdf octave3.0 ruby sl robotfindskitten pvm xpvm emacs grac blender automake1.9 libtool libglu1-mesa-dev minicom lcd4linux insight joe grace libxpm-dev telnet lsof xresprobe fbset fluxbox xgalaga zenmap nedit eterm";
88Readonly my $BAD_PACKAGES   => ""; # Packages that throw some fatal error during install but still work
89Readonly my $PERLDIR        => "/usr/local/lib/site_perl/";
90Readonly my $TESTNAME       => "build_livecd";
91Readonly my $STAGE          => $Bccd->get_stage();
92Readonly my $KNOPDIR        => "$tmpdir/KNOPPIX";
93Readonly my $USER           => "$PROJECT";
94Readonly my $KERNREV        => "2.6.31.12_aufs";
95Readonly my @TIME           => localtime();
96Readonly my $FORMAT_DATE    => ($TIME[5]+1900)."-".($TIME[4]+1)."-".$TIME[3];
97# Revision fetch
98
99if($opts{'info'}) {
100    $Bccd->set_debug('INFO');
101}
102
103if($opts{'debug'}) {
104    $Bccd->set_debug('DEBUG');
105}
106
107if($opts{'updatedb'}) {
108    $Bccd->redirect_stdio("$tmpdir");
109}
110
111if($opts{'svnrev'}) {
112    $svnrev = $opts{'svnrev'};
113} else {
114    $svnrev = $Bccd->run_test(
115        "getsvnrev",
116        "",
117        "Got subversion revision of $websvn.",
118        "$websvn",
119        );
120}
121
122$Bccd->run_test(
123    "chdir",
124    "",
125    "cd'd into $tmpdir.",
126    "$tmpdir",
127    );
128
129$Bccd->run_test(
130    "system",
131    "",
132    "Built initial install tree.",
133    "debootstrap --arch $opts{'arch'} $opts{'suite'} $BUILDDIR $debmirror",
134    );
135
136$Bccd->run_test(
137    "system",
138    "",
139    "Copied /dev to $BUILDDIR/dev.",
140    "cp -R /dev $BUILDDIR/dev",
141    );
142
143$Bccd->run_test(
144    "system",
145    "",
146    "Mounted /proc into $BUILDDIR.",
147    "mount -t proc proc $BUILDDIR/proc",
148    );
149
150$Bccd->run_test(
151    "fwrite",
152    "",
153    "Disabled apt-get package authentication.",
154    "a",
155    "$BUILDDIR/etc/apt/apt.conf",
156    "APT::Get::AllowUnauthenticated 1 ;",
157    );
158
159$Bccd->run_test(
160    "system",
161    "",
162    "Installed Perl testing modules in install tree.",
163    "chroot $BUILDDIR apt-get -y install libtest-base-perl",
164    );
165
166$Bccd->run_test(
167    "system",
168    "",
169    "Installed Perl testing modules in install tree.",
170    "chroot $BUILDDIR apt-get -y install libtest-base-perl",
171    );
172
173foreach my $file ( "$BUILDDIR/etc/apt/sources.list","$BUILDDIR/etc/apt/apt.conf","$BUILDDIR/etc/network/interfaces","$BUILDDIR/etc/dhcp3/dhcpd.conf","$BUILDDIR/etc/dhcp3/dhclient.conf","$BUILDDIR/etc/ssh/ssh_config","$BUILDDIR/etc/ssh/sshd_config","$BUILDDIR/etc/profile","$BUILDDIR/etc/defaultdomain","$BUILDDIR/etc/default/nis","$BUILDDIR/etc/default/useradd","$BUILDDIR/etc/default/tftpd-hpa","$BUILDDIR/etc/rc.local" ) {
174    if( -f $file ) {
175        $Bccd->run_test(
176            "unlink",
177            "",
178            "rm'd existing cfg file $file",
179            "$file",
180            );
181    }
182}
183
184foreach my $dir ( $BCCDCLIENT, $PROJDIR, "$BUILDDIR/etc/network", "$BUILDDIR/etc/dhcp3", "$BUILDDIR/etc/ssh", "$BUILDDIR/$SOFTWARE", "$BUILDDIR/root/.ssh", "$BUILDDIR/nfs",
185                  "$BUILDDIR/$LIBFETCH", "$BUILDDIR/var/run" ) {
186    if( !(-d $dir) ) {
187        $Bccd->run_test(
188            "mkpath",
189            "",
190            "Made $dir directory.",
191            "$dir",
192            );
193    }
194}
195
196$Bccd->run_test(
197    "revfetch",
198    "",
199    "Fetched debconf preseed file.",
200    $svnrev,
201    "$websvn/packages/debconf.preseed",
202    "$BUILDDIR/root/debconf.preseed",
203    );
204
205$Bccd->run_test(
206    "system",
207    "",
208    "Set debconf selections.",
209    "/usr/sbin/chroot $BUILDDIR debconf-set-selections /root/debconf.preseed",
210    );
211
212$Bccd->run_test(
213    "revfetch",
214    "",
215    "Fetched apt source list.",
216    $svnrev,
217    "$websvn/packages/etc/apt/sources.list",
218    "$BUILDDIR/etc/apt/sources.list",
219    );
220
221$Bccd->run_test(
222    "regexsub_file",
223    "",
224    "Changed DEBMIRROR template in sources list.",
225    "$BUILDDIR/etc/apt/sources.list",
226    "!DEBMIRROR!",
227    "$debmirror_host",
228    );
229
230foreach my $file ( "interfaces", "interfaces.compute" ) {
231    $Bccd->run_test(
232        "revfetch",
233        "",
234        "Fetched network $file cfg.",
235        $svnrev,
236        "$websvn/packages/etc/network/$file",
237        "$BUILDDIR/etc/network/$file",
238        );
239}
240
241$Bccd->run_test(
242    "mkpath",
243    "",
244    "mkdir /etc/X11/xinit",
245    "$BUILDDIR/etc/X11/xinit",
246    );
247
248# Make apt work
249
250foreach my $dir ( "/var/cache/apt/archives", "/var/cache/apt/archives/partial" ) {
251    $Bccd->run_test(
252        "mkpath",
253        "",
254        "mkdir $dir",
255        "$BUILDDIR/$dir",
256        );
257}
258
259# /etc fetch
260foreach my $file ( "hosts", "hosts.compute", "hosts.allow", "hosts.deny", "profile", "modules", "modules.net",
261          "passwd.compute", "group.compute", "shadow.compute", "exports.compute",
262          "nsswitch.conf", "unionfs.conf", "X11/xinit/xinitrc", "X11/xinit/xserverrc",
263          "dpkg/dpkg.cfg", "ld.so.conf.d/software.conf", "sudoers", "init.d/bccd-networking",
264          "init.d/bccd-passwd", "init.d/bccd-dhcp", "init.d/bccd-sshd", "X11/xorg.conf",
265          "lam.conf", "init.d/bccd-nfs", "init.d/bccd-unite-sw", "init.d/bccd-nics",
266          "init.d/bccd-dhcp-conf", "init.d/bccd-route", "init.d/bccd-keyboard", "rc.local",
267          "init.d/bccd-fsrw", "auto.master", "auto.sshfs" ) {
268    $Bccd->run_test(
269        "revfetch",
270        "",
271        "Fetched /etc/$file file.",
272        $svnrev,
273        "$websvn/packages/etc/$file",
274        "$BUILDDIR/etc/$file",
275        );
276}
277
278$Bccd->run_test(
279    "chmod",
280    "",
281    "Set $BUILDDIR/etc/sudoers user/group readable only.",
282    0440,
283    "$BUILDDIR/etc/sudoers",
284    );
285
286foreach my $file ( "bccd-networking", "bccd-passwd", "bccd-dhcp", "bccd-sshd", "bccd-nfs", "bccd-unite-sw",
287          "bccd-nics", "bccd-dhcp-conf", "bccd-route", "bccd-keyboard", "bccd-fsrw" ) {
288    $Bccd->run_test(
289        "chmod",
290        "",
291        "Set $BUILDDIR/etc/init.d/$file executable.",
292        0755,
293        "$BUILDDIR/etc/init.d/$file",
294        );
295}
296
297$cwd = getcwd();
298
299$Bccd->run_test(
300    "chdir",
301    "",
302    "cd $BUILDDIR",
303    "$BUILDDIR",
304    );
305
306$Bccd->run_test(
307    "recrevfetch",
308    "",
309    "Fetched lib directory.",
310    $svnrev,
311    "$websvn/trees/lib/",
312    );
313
314$Bccd->run_test(
315    "recrevfetch",
316    "",
317    "Fetched bin directory.",
318    $svnrev,
319    "$websvn/trees/bin/",
320    );
321
322$Bccd->run_test(
323    "recrevfetch",
324    "",
325    "Fetched sbin directory.",
326    $svnrev,
327    "$websvn/trees/sbin/",
328    );
329
330$Bccd->run_test(
331    "recrevfetch",
332    "",
333    "Fetched etc tree.",
334    $svnrev,
335    "$websvn/trees/etc/",
336    );
337
338$Bccd->run_test(
339    "recrevfetch",
340    "",
341    "Fetched root home directory.",
342    $svnrev,
343    "$websvn/trees/root/",
344    );
345
346
347$Bccd->run_test(
348    "chdir",
349    "",
350    "cd $BUILDDIR/etc",
351    "$BUILDDIR/etc",
352    );
353
354$Bccd->run_test(
355    "recrevfetch",
356    "",
357    "Fetched skel profile.",
358    $svnrev,
359    "$websvn/packages/etc/skel",
360    );
361
362foreach my $file ( "$BUILDDIR/etc/skel/.firstlogin", "$BUILDDIR/etc/skel/.bash_profile", ) {
363    $Bccd->run_test(
364        "chmod",
365        "",
366        "chmod 0755 $file",
367        0755,
368        "$file",
369        );
370}
371
372if(-f "$BUILDDIR/etc/skel/.bashrc") {
373    $Bccd->run_test(
374        "unlink",
375        "",
376        "Removed default .bashrc",
377        "$BUILDDIR/etc/skel/.bashrc",
378        );
379}
380
381$Bccd->run_test(
382    "chdir",
383    "",
384    "cd'ing into $BUILDDIR/etc/skel",
385    "$BUILDDIR/etc/skel",
386    );
387
388$Bccd->run_test(
389    "chdir",
390    "",
391    "cd $cwd",
392    "$cwd",
393    );
394
395$Bccd->run_test(
396    "revfetch",
397    "",
398    "Fetched gen_c3_conf autogen script.",
399    $svnrev,
400    "$websvn/packages/gen_c3_conf.sh",
401    "$BUILDDIR/root/gen_c3_conf.sh",
402    );
403
404$Bccd->run_test(
405    "revfetch",
406    "",
407    "Fetched liberate script.",
408    $svnrev,
409    "$websvn/packages/liberate.pl",
410    "$BUILDDIR/root/liberate.pl",
411    );
412
413$Bccd->run_test(
414    "chmod",
415    "",
416    "Set gen_c3_conf executable.",
417    0754,
418    "$BUILDDIR/root/gen_c3_conf.sh"
419    );
420
421$Bccd->run_test(
422    "revfetch",
423    "",
424    "Fetched /etc/default/useradd file.",
425    $svnrev,
426    "$websvn/packages/etc/default/useradd",
427    "$BUILDDIR/etc/default/useradd",
428    );
429
430$Bccd->run_test(
431    "fwrite",
432    "",
433    "Allowing initrd kernel upgrade.",
434    "a",
435    "$BUILDDIR/etc/kernel-img.conf",
436    "do_initrd=yes",
437    );
438
439$Bccd->run_test(
440    "system",
441    "",
442    "Updated apt cache.",
443    "/usr/sbin/chroot $BUILDDIR apt-get update",
444    );
445
446$Bccd->run_test(
447    "system",
448    "",
449    "Fetched Debian keyring.",
450    "/usr/sbin/chroot $BUILDDIR apt-get -y --allow-unauthenticated  install debian-archive-keyring",
451    );
452
453$Bccd->run_test(
454    "system",
455    "0",
456    "Fetched Debian packages.",
457    "/usr/sbin/chroot $BUILDDIR aptitude -y install $PACKAGES $EXTRA_PACKAGES",
458    );
459
460$Bccd->run_test(
461    "system",
462    "",
463    "Deleted cached deb packages.",
464    "/usr/sbin/chroot $BUILDDIR apt-get clean",
465    );
466
467$Bccd->run_test(
468    "system",
469    "",
470    "Stopped pdnsd.",
471    "killall pdnsd",
472    );
473
474$Bccd->run_test(
475    "revfetch",
476    "",
477    "Fetched tftpd-hpa configuration.",
478    $svnrev,
479    "$websvn/packages/etc/default/tftpd-hpa",
480    "$BUILDDIR/etc/default/tftpd-hpa",
481    );
482
483$Bccd->run_test(
484    "revfetch",
485    "",
486    "Fetched NIS default domain.",
487    $svnrev,
488    "$websvn/packages/etc/defaultdomain",
489    "$BUILDDIR/etc/defaultdomain",
490    );
491
492$Bccd->run_test(
493    "revfetch",
494    "",
495    "Fetched Knoppix cloop package.",
496    $svnrev,
497    "$websvn/packages/cloop-module-2.6.19_2.05-1_i386.deb",
498    "$BUILDDIR/tmp/cloop.deb",
499    );
500
501$Bccd->run_test(
502    "revfetch",
503    "",
504    "Fetched Knoppix Linux package.",
505    $svnrev,
506    "$websvn/packages/linux-image-2.6.19_2.6.19-10.00.Custom_i386.deb",
507    "$BUILDDIR/tmp/linux-image.deb",
508    );
509
510$Bccd->run_test(
511    "mkpath",
512    "",
513    "Making $KERNREV modules directory.",
514    "$BUILDDIR/lib/modules/$KERNREV",
515    );
516
517$cwd = getcwd();
518
519$Bccd->run_test(
520    "chdir",
521    "",
522    "cd'ing to $KERNREV modules directory.",
523    "$BUILDDIR/lib/modules/",
524    );
525
526$Bccd->run_test(
527    "recrevfetch",
528    "",
529    "Fetched Knoppix kernel modules.",
530    $svnrev,
531    "$websvn/trees/linux_aufs/lib/modules/$KERNREV",
532    );
533
534$Bccd->run_test(
535    "chdir",
536    "",
537    "Changing back to old directory.",
538    "$cwd",
539    );
540
541$Bccd->run_test(
542    "revfetch",
543    "",
544    "Fetched ssh_config file.",
545    $svnrev,
546    "$websvn/packages/etc/ssh/ssh_config",
547    "$BUILDDIR/etc/ssh/ssh_config",
548    );
549
550$Bccd->run_test(
551    "revfetch",
552    "",
553    "Fetched sshd_config file.",
554    $svnrev,
555    "$websvn/packages/etc/ssh/sshd_config",
556    "$BUILDDIR/etc/ssh/sshd_config",
557    );
558
559$Bccd->run_test(
560    "mkpath",
561    "",
562    "mkdir $BUILDDIR/etc/udev/rules.d",
563    "$BUILDDIR/etc/udev/rules.d",
564    );
565
566$Bccd->run_test(
567    "revfetch",
568    "",
569    "Fetched USB automounting udev rule.",
570    $svnrev,
571    "$websvn/packages/etc/udev/rules.d/99-automount_usb.rules",
572    "$BUILDDIR/etc/udev/rules.d/99-automount_usb.rules",
573    );
574
575# Revision write
576
577$Bccd->run_test(
578    "fwrite",
579    "",
580    "Opened $BUILDDIR/etc/$PROJECT-revision for writing.",
581    "w",
582    "$BUILDDIR/etc/$PROJECT-revision",
583    "$svnrev",
584    );
585
586# PAM fetch
587foreach my $file ( "rlogin", "rsh" ) {
588    $Bccd->run_test(
589        "revfetch",
590        "",
591        "Fetched /etc/pam.d/$file file.",
592        $svnrev,
593        "$websvn/packages/etc/pam.d/$file",
594        "$BUILDDIR/etc/pam.d/$file",
595        );
596}
597
598# Install software
599
600$Bccd->run_test(
601    "mkpath",
602    "",
603    "Created node checkin directory.",
604    "$CHECKIN",
605    );
606
607
608$nouid = $Bccd->run_test(
609    "getuseruid",
610    "",
611    "Got uid for nobody user.",
612    "nobody",
613    );
614
615$nogid = $Bccd->run_test(
616    "getusergid",
617    "",
618    "Got gid for nobody user.",
619    "nobody",
620    );
621
622$Bccd->run_test(
623    "chown",
624    "",
625    "chown'd checkin directory $CHECKIN to $nouid:$nogid.",
626    "$nouid",
627    "$nogid",
628    "$CHECKIN",
629    );
630
631if( ! -f "$BUILDDIR/usr/bin/python2" ) {
632    $Bccd->run_test(
633        "symlink",
634        "",
635        "Linked python->python2 for C3 tools.",
636        "$BUILDDIR/usr/bin/python",
637        "$BUILDDIR/usr/bin/python2",
638        );
639}
640
641$Bccd->run_test(
642    "revfetch",
643    "",
644    "Fetched c3 tools tarball.",
645    $svnrev,
646    "$websvn/packages/c3-4.0.1.tar.gz",
647    "$tmpdir/c3.tar.gz",
648    );
649
650$Bccd->run_test(
651    "system",
652    "",
653    "Extracted c3 tools tarball.",
654    "tar -C $BUILDDIR/opt -xzf $tmpdir/c3.tar.gz",
655    );
656
657$Bccd->run_test(
658    "rename",
659    "",
660    "Renamed /opt/c3-4.0.1 to /opt/c3-4.",
661    "$BUILDDIR/opt/c3-4.0.1",
662    "$BUILDDIR/opt/c3-4",
663    );
664
665$Bccd->run_test(
666    "fcopy",
667    "",
668    "Copied pxelinux to tftpboot.",
669    "$BUILDDIR/usr/lib/syslinux/pxelinux.0",
670    "$BUILDDIR/var/lib/tftpboot/pxelinux.0",
671    );
672
673$Bccd->run_test(
674    "mkpath",
675    "",
676    "Made $BUILDDIR/var/lib/tftpboot/pxelinux.cfg",
677    "$BUILDDIR/var/lib/tftpboot/pxelinux.cfg",
678    );
679
680foreach my $file ( "dhcpd.conf", "dhclient.conf", "dhclient.conf-bccd", "dhclient.conf-any" ) {
681    $Bccd->run_test(
682        "revfetch",
683        "",
684        "Fetched DHCP $file configuration.",
685        $svnrev,
686        "$websvn/packages/etc/dhcp3/$file",
687        "$BUILDDIR/etc/dhcp3/$file",
688        );
689}
690
691# Needed down here to prevent hang with debconf
692foreach my $file ( "exports", "hosts.equiv", "gpm.conf", "inittab" ) {
693    $Bccd->run_test(
694        "revfetch",
695        "",
696        "Fetched /etc/$file file.",
697        $svnrev,
698        "$websvn/packages/etc/$file",
699        "$BUILDDIR/etc/$file",
700        );
701}
702
703$Bccd->run_test(
704    "system",
705    "",
706    "Setting LSB parsing of init scripts.",
707    "touch $BUILDDIR/etc/update-rc.d-lsbparse",
708    );
709
710foreach my $script ( "nis", "ssh-host-keys", "nfs-kernel-server", "ssh", "dhcp3-server", "dbus", "hal", "apache2" ) {
711    $Bccd->run_test(
712        "system",
713        "",
714        "Disabled $script.",
715        "/usr/sbin/chroot $BUILDDIR /usr/sbin/update-rc.d -f $script remove",
716        );
717}
718
719foreach my $script ( "bccd-passwd","bccd-sshd", "bccd-nfs", "nfs-common", "vboxadd-service", "mpd" ) {
720    $Bccd->run_test(
721        "system",
722        "",
723        "Enabling $script at boot time.",
724        "/usr/sbin/chroot $BUILDDIR /usr/sbin/update-rc.d $script defaults",
725        );
726}
727
728# This must run before 20 (bccd-passwd) and autofs
729foreach my $script ( "bccd-keyboard", "bccd-unite-sw", "perfctr", ) {
730    $Bccd->run_test(
731        "system",
732        "",
733        "Enabling $script config.",
734        "/usr/sbin/chroot $BUILDDIR /usr/sbin/update-rc.d $script defaults 18",
735        );
736}
737
738$Bccd->run_test(
739        "system",
740        "",
741        "Enabling home directory overlay cleaning.",
742        "/usr/sbin/chroot $BUILDDIR /usr/sbin/update-rc.d bccd-clean-home start 5 2 S .",
743        );
744
745$Bccd->run_test(
746    "system",
747    "",
748    "Enabling bccd-nics config.",
749    "/usr/sbin/chroot $BUILDDIR /usr/sbin/update-rc.d bccd-nics defaults 39",
750    );
751
752$Bccd->run_test(
753    "system",
754    "",
755    "Enabling bccd-dhcp-conf config.",
756    "/usr/sbin/chroot $BUILDDIR /usr/sbin/update-rc.d bccd-dhcp-conf defaults 38",
757    );
758
759$Bccd->run_test(
760    "system",
761    "",
762    "Enabling bccd-route config.",
763    "/usr/sbin/chroot $BUILDDIR /usr/sbin/update-rc.d bccd-route defaults 41",
764    );
765
766$Bccd->run_test(
767    "system",
768    "",
769    "Enabling bccd-fsrw config.",
770    "/usr/sbin/chroot $BUILDDIR /usr/sbin/update-rc.d bccd-fsrw defaults 11",
771    );
772
773$Bccd->run_test(
774    "system",
775    "",
776    "Enabling bccd-networking config.",
777    "/usr/sbin/chroot $BUILDDIR /usr/sbin/update-rc.d bccd-networking start 42 2 S .",
778    );
779
780$Bccd->run_test(
781    "system",
782    "",
783    "Enabling bccd-dhcp config.",
784    "/usr/sbin/chroot $BUILDDIR /usr/sbin/update-rc.d bccd-dhcp defaults 40",
785    );
786
787$Bccd->run_test(
788    "system",
789    "",
790    "Added root password.",
791    "/usr/sbin/chroot $BUILDDIR /usr/sbin/usermod -p '\$1\$erNdlHdL\$EV6C0eBbe6M3bVaK9m4If0' root",
792    );
793
794# User creation
795
796# Manual writes to keep NIS from interfering with static uid/gid
797
798$Bccd->run_test(
799    "fwrite",
800    "",
801    "Wrote out sshd user.",
802    "a",
803    "$BUILDDIR/etc/passwd",
804    "sshd:x:103:65534::/var/run/sshd:/usr/sbin/nologin",
805    );
806
807$Bccd->run_test(
808    "fwrite",
809    "",
810    "Wrote out sshd group.",
811    "a",
812    "$BUILDDIR/etc/shadow",
813    "sshd:!:13625:0:99999:7:::",
814    );
815
816$Bccd->run_test(
817    "system",
818    "",
819    "Creating non-root-group account.",
820    "/usr/sbin/chroot $BUILDDIR /usr/sbin/groupadd -g 1000 bccd",
821    );
822
823$Bccd->run_test(
824    "system",
825    "",
826    "Created non-root user account.","/usr/sbin/chroot $BUILDDIR /usr/sbin/useradd -s /bin/bash -G fuse,adm -u 1000 -g 1000 -d /home/$USER -m -p '\$1\$Agm0SXPB\$JnObEvwBQdg4WCovvMKST1' $USER",
827    );
828
829$Bccd->run_test(
830    "system",
831    "",
832    "Altered non-root account directory for KNOPPIX.",
833    "/usr/sbin/chroot $BUILDDIR /usr/sbin/usermod -d /UNIONFS/home/$USER $USER",
834    );
835
836# Bccd perl modules
837
838$Bccd->run_test(
839    "mkpath",
840    "",
841    "mkdir $BUILDDIR/$PERLDIR",
842    "$BUILDDIR/$PERLDIR",
843    );
844
845$Bccd->run_test(
846    "chdir",
847    "",
848    "cd'd to $BUILDDIR/$PERLDIR/../",
849    "$BUILDDIR/$PERLDIR/../",
850    );
851
852
853$Bccd->run_test(
854    "recrevfetch",
855    "",
856    "Checked out Bccd perl modules.",
857    $svnrev,
858    "$websvn/packages/$PERLDIR/",
859    );
860
861$Bccd->run_test(
862    "chdir",
863    "",
864    "cd'd to $tmpdir.",
865    "$tmpdir",
866    );
867
868$Bccd->run_test(
869    "recrevfetch",
870    "",
871    "Checked out hardware autodetect stuff.",
872    $svnrev,
873    "$websvn/trees/hwsetup/",
874    );
875
876$Bccd->run_test(
877    "system",
878    "",
879    "Copied hardware autodetect into $BUILDDIR.",
880    "cp -R $tmpdir/hwsetup/* $BUILDDIR/",
881    );
882
883# Starting hwsetup init scripts
884foreach my $script ( "knoppix-autoconfig", "xserver-xorg" ) {
885    $Bccd->run_test(
886        "system",
887        "",
888        "Enabled $script.",
889        "/usr/sbin/chroot $BUILDDIR /usr/sbin/update-rc.d $script start 20 2 3 4 5 .",
890        );
891}
892
893# Software install
894
895$Bccd->run_test(
896    "chdir",
897    "",
898    "cd'd to $BUILDDIR",
899    "$BUILDDIR",
900    );
901
902$Bccd->run_test(
903    "recrevfetch",
904    "",
905    "Fetched software tree.",
906    $svnrev,
907    "$websvn/trees/software/bccd/",
908    );
909
910$Bccd->run_test(
911    "system",
912    "",
913    "Changed $SOFTWARE to bccd:bccd.",
914    "/usr/sbin/chroot $BUILDDIR /bin/chown -R bccd:bccd $SOFTWARE",
915    );
916
917foreach my $prog ( <$BUILDDIR/bccd/software/*/bin/*> ) {
918    $Bccd->run_test(
919        "chmod",
920        "",
921        "chmod 0755 $prog",
922        0755,
923        "$prog",
924        );
925}
926
927$Bccd->run_test(
928        "mkpath",
929        "",
930        "mkdir $BUILDDIR/usr/lib/iceweasel/plugins",
931        "$BUILDDIR/usr/lib/iceweasel/plugins", 
932        );
933
934$Bccd->run_test(
935        "fcopy",
936        "",
937        "cp $BUILDDIR//bccd/software/jre1.6.0_13/plugin/i386/ns7/libjavaplugin_oji.so $BUILDDIR/usr/lib/iceweasel/plugins",
938        "$BUILDDIR//bccd/software/jre1.6.0_13/plugin/i386/ns7/libjavaplugin_oji.so",
939        "$BUILDDIR/usr/lib/iceweasel/plugins",
940        );
941
942$Bccd->run_test(
943    "chdir",
944    "",
945    "cd $BUILDDIR/",
946    "$BUILDDIR/",
947    );
948
949$Bccd->run_test(
950    "recrevfetch",
951    "",
952    "Fetched test tree.",
953    $svnrev,
954    "$websvn/trees/home",
955    );
956
957$Bccd->run_test(
958    "system",
959    "",
960    "chown'd $BUILDDIR/home/bccd to bccd:bccd",
961    "/usr/sbin/chroot $BUILDDIR chown -R $USER:$USER /home/bccd",
962    );
963
964$Bccd->run_test(
965    "chmod",
966    "",
967    "chmod 0600 $BUILDDIR/home/bccd/.mpd.conf",
968    0600,
969    "$BUILDDIR/home/bccd/.mpd.conf",
970    );
971
972$Bccd->run_test(
973    "chmod",
974    "",
975    "chmod 0755 $BUILDDIR/root/.ssh/",
976    0755,
977    "$BUILDDIR/root/.ssh/",
978    );
979
980$Bccd->run_test(
981    "chmod",
982    "",
983    "chmod 0755 $BUILDDIR/home/$USER/.ssh",
984    0755,
985    "$BUILDDIR/home/$USER/.ssh",
986    );
987
988$Bccd->run_test(
989                "chmod",
990                "",
991                "chmod 0755 $BUILDDIR/home/$USER",
992                0755,
993                "$BUILDDIR/home/$USER",
994                );
995
996foreach my $file ( "$BUILDDIR/root/.ssh/bccd", "$BUILDDIR/root/.ssh/config" ) {
997    $Bccd->run_test(
998        "chmod",
999        "",
1000        "chmod 0600 $file",
1001        0600,
1002        "$file",
1003        );
1004}
1005
1006foreach my $key ( <$BUILDDIR/etc/ssh/ssh*key*> ) {
1007    $Bccd->run_test(
1008        "unlink",
1009        "",
1010        "Removed ssh key $key.",
1011        "$key",
1012        );
1013}
1014
1015$Bccd->run_test(
1016    "system",
1017    "",
1018    "Requiring bccd ssh start script for ssh start.",
1019    "perl -wpli -e 's/^(#\\s+Required-Start:\\s+.*\$)/\$1 bccd-sshd/' $BUILDDIR/etc/init.d/ssh",
1020    );
1021
1022$Bccd->run_test(
1023    "system",
1024    "",
1025    "Requiring bccd nic start script for networking start.",
1026    "perl -wpli -e 's/^(#\\s+Required-Start:\\s+.*\$)/\$1 bccd-nics/' $BUILDDIR/etc/init.d/networking",
1027    );
1028
1029$Bccd->run_test(
1030    "system",
1031    "",
1032    "Allowing pdnsd to listen on all interfaces.",
1033    "perl -wpli -e 's!(server_ip = )!// \$1!g' $BUILDDIR/usr/share/pdnsd/pdnsd-resolvconf.conf",
1034    );
1035
1036$Bccd->run_test(
1037    "system",
1038    "",
1039    "Fixing cstddef for openmpi.",
1040    "perl -wpli -e 's/#include_next/#include/g' $BUILDDIR/usr/include/c++/4.3/cstddef",
1041    );
1042
1043# Make us LIVE
1044
1045$Bccd->run_test(
1046    "fwrite",
1047    "",
1048    "Made us LIVE.",
1049    "w",
1050    "$BUILDDIR/etc/$PROJECT-stage",
1051    "LIVE",
1052    );
1053
1054# Setting up menus
1055
1056foreach my $file (<$BUILDDIR/usr/share/menu/*>) {
1057    $Bccd->run_test(
1058        "unlink",
1059        "",
1060        "rm'd X menu item $file",
1061        "$file",
1062        );
1063}
1064
1065$cwd = getcwd();
1066
1067$Bccd->run_test(
1068    "chdir",
1069    "",
1070    "cd $BUILDDIR/",
1071    "$BUILDDIR/",
1072    );
1073
1074$Bccd->run_test(
1075    "recrevfetch",
1076    "",
1077    "Fetched /usr items.",
1078    $svnrev,
1079    "$websvn/trees/usr/",
1080    );
1081
1082$Bccd->run_test(
1083    "chdir",
1084    "",
1085    "Changed back to old directory.",
1086    "$cwd",
1087    );
1088
1089$Bccd->run_test(
1090    "system",
1091    "",
1092    "Updated desktop menus.",
1093    "/usr/sbin/chroot $BUILDDIR /usr/bin/update-menus",
1094    );
1095
1096# Software end
1097
1098# Pre-fetching liberation stuff
1099
1100$Bccd->run_test(
1101    "revfetch",
1102    "",
1103    "Fetched LVM fdisk script.",
1104    $svnrev,
1105    "$websvn/packages/fdisk_lvm.input",
1106    "$BUILDDIR/$LIBFETCH/fdisk_lvm.input",
1107    );
1108
1109$Bccd->run_test(
1110    "revfetch",
1111    "",
1112    "Fetched liberation exports file.",
1113    $svnrev,
1114    "$websvn/packages/etc/exports.liberate",
1115    "$BUILDDIR/$LIBFETCH/exports",
1116    );
1117
1118$Bccd->run_test(
1119    "chdir",
1120    "",
1121    "cd'ing to $BUILDDIR/$LIBFETCH/.",
1122    "$BUILDDIR/$LIBFETCH",
1123    );
1124
1125$Bccd->run_test(
1126    "recrevfetch",
1127    "",
1128    "Fetched $websvn/trees/linux_aufs over svn.",
1129    $svnrev,
1130    "$websvn/trees/linux_aufs/",
1131    );
1132
1133$Bccd->run_test(
1134    "system",
1135    "",
1136    "Tar'd up linux_aufs.",
1137    "tar -C $BUILDDIR/$LIBFETCH/linux_aufs -cjvf $BUILDDIR/$LIBFETCH/lib-linux.tar.bz2 .",
1138    );
1139
1140$Bccd->run_test(
1141    "rmtree",
1142    "",
1143    "Removing linux_aufs fetch.",
1144    "linux_aufs",
1145    );
1146
1147foreach my $file (grep(-f $_, <$BUILDDIR/var/lib/apt/lists/*>)) {
1148        $Bccd->run_test(
1149            "unlink",
1150            "",
1151            "Removed apt file lists.",
1152            "$file",
1153            );
1154}
1155
1156$Bccd->run_test(
1157    "recrevfetch",
1158    "",
1159    "Fetched $websvn/trees/diskless over svn.",
1160    $svnrev,
1161    "$websvn/trees/diskless",
1162    );
1163
1164$Bccd->run_test(
1165    "chdir",
1166    "",
1167    "Reverted to $cwd.",
1168    "$cwd",
1169    );
1170
1171$Bccd->run_test(
1172    "revfetch",
1173    "",
1174    "Fetched grub menu.",
1175    $svnrev,
1176    "$websvn/packages/boot/grub/menu.lst",
1177    "$BUILDDIR/$LIBFETCH/grub_menu.lst",
1178    );
1179
1180$Bccd->run_test(
1181    "lsofkill",
1182    "",
1183    "Killing procs in $BUILDDIR: ",
1184    "$BUILDDIR",
1185    );
1186
1187# Make here so automount doesn't destroy it
1188
1189$Bccd->run_test(
1190    "mkpath",
1191    "",
1192    "mkdir $BUILDDIR/mnt/ssh",
1193    "$BUILDDIR/mnt/ssh",
1194    );
1195
1196$Bccd->run_test(
1197    "system",
1198    "",
1199    "Unmounted $BUILDDIR/proc.",
1200    "umount -f $BUILDDIR/proc",
1201    );
1202
1203$Bccd->run_test(
1204    "chdir",
1205    "",
1206    "cd'd to $tmpdir for Knoppix fetch.",
1207    "$tmpdir",
1208    );
1209
1210$Bccd->run_test(
1211    "recrevfetch",
1212    "",
1213    "Fetched KNOPPIX sans root filesystem.",
1214    $svnrev,
1215    "$websvn/trees/KNOPPIX/",
1216    );
1217
1218$Bccd->run_test(
1219    "regexsub_file",
1220    "",
1221    "Adding revision to KNOPPIX boot file.",
1222    "$tmpdir/KNOPPIX/boot/isolinux/boot.msg",
1223    "==REVISION==",
1224    "$svnrev",
1225    );
1226
1227$Bccd->run_test(
1228    "revfetch",
1229    "",
1230    "Fetched knoppix kernel image.",
1231    $svnrev,
1232    "$websvn/trees/linux_aufs/boot/vmlinuz-$KERNREV",
1233        "$KNOPDIR/boot/isolinux/linux",
1234    );
1235
1236$Bccd->run_test(
1237    "regexsub_file",
1238    "",
1239    "Adding date to KNOPPIX boot file.",
1240    "$tmpdir/KNOPPIX/boot/isolinux/boot.msg",
1241    "==DATE==",
1242    "$FORMAT_DATE",
1243    );
1244
1245$Bccd->run_test(
1246        "fwrite",
1247        "",
1248        "Writing out date to /etc/$PROJECT-build-date.",
1249        "w",
1250        "$BUILDDIR/etc/$PROJECT-build-date",
1251        "$FORMAT_DATE",
1252        );
1253
1254$Bccd->run_test(
1255    "system",
1256    "",
1257    "Created compressed root filesystem.",
1258    "bash -c 'genisoimage -R -U -V BCCD-NG -publisher ccg -hide-rr-moved -cache-inodes -no-bak -pad $BUILDDIR | create_compressed_fs  - 65536 > $tmpdir/KNOPPIX/KNOPPIX/KNOPPIX'",
1259    );
1260
1261$Bccd->run_test(
1262    "system",
1263    "",
1264    "Created bootable ISO image.",
1265    "genisoimage -pad -l -r -J -v -V BCCD-NG -no-emul-boot -boot-load-size 4 -boot-info-table -b boot/isolinux/isolinux.bin -c boot/isolinux/boot.cat -hide-rr-moved -o $opts{'outiso'} $tmpdir/KNOPPIX",
1266    );
1267
1268print "Passed ".$Bccd->get_passed()." out of ".$Bccd->get_total()." total tests.\n";
1269
1270if($opts{'updatedb'}) {
1271    my $dbh = open_db("$opts{'updatedb'}");
1272    if( $Bccd->get_passed() < $Bccd->get_total() ) {
1273        insert_results($TESTNAME,$STAGE,$svnrev,$Bccd->snarf_file("$tmpdir/allout"),"FAILURE",$dbh);
1274    } else {
1275        insert_results($TESTNAME,$STAGE,$svnrev,$Bccd->snarf_file("$tmpdir/allout"),"SUCCESS",$dbh);
1276    }
1277    $Bccd->close_stdio();
1278    $dbh->disconnect;
1279}
1280
1281exit $Bccd->get_total()-$Bccd->get_passed();
1282
1283__END__
1284
1285build_livecd.pl - Build process based on Knoppix Live CD creation
1286
1287=head1 - SYNOPSIS
1288
1289This script is based on KNOPPIX project documentation for creating a
1290Debian-based Live CD using cloop.
1291
1292=head1 - OPTIONS
1293
1294=over 8
1295
1296=item B<--builddir> I<path-to-dir>
1297
1298Path to build directory for live CD. Will be cleaned up after the work is
1299done.
1300
1301=item B<--arch> I<arch>
1302
1303Architecture to build for.
1304
1305=item B<--outiso> I<path-to-file>
1306
1307Where to output the bccd ISO image.
1308
1309=item B<--websvn> I<websvn-url>
1310
1311Path to bccd's websvn branch, i.e. http://cluster.earlham.edu/svn/bccd-ng/trunk.
1312
1313=item B<--suite> I<release-name>
1314
1315Name of the Debian release suite to download.
1316
1317=item B<--nocleanup>
1318
1319Preserve the /tmp directory for investigation.
1320
1321=item B<--help>
1322
1323This message.
1324
1325=cut
Note: See TracBrowser for help on using the repository browser.