source: /cluster/svnroot/bccd-ng/branches/fitz-devel/bin/build_livecd.pl @ 2524

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

bugfix for specifying destination build directory

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