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

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

Removing .bashrc link (#480)

  • Property svn:executable set to *
File size: 28.7 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 bin directory.",
310    $svnrev,
311    "$websvn/trees/bin/",
312    );
313
314$Bccd->run_test(
315    "recrevfetch",
316    "",
317    "Fetched sbin directory.",
318    $svnrev,
319    "$websvn/trees/sbin/",
320    );
321
322$Bccd->run_test(
323    "recrevfetch",
324    "",
325    "Fetched etc tree.",
326    $svnrev,
327    "$websvn/trees/etc/",
328    );
329
330$Bccd->run_test(
331    "recrevfetch",
332    "",
333    "Fetched root home directory.",
334    $svnrev,
335    "$websvn/trees/root/",
336    );
337
338
339$Bccd->run_test(
340    "chdir",
341    "",
342    "cd $BUILDDIR/etc",
343    "$BUILDDIR/etc",
344    );
345
346$Bccd->run_test(
347    "recrevfetch",
348    "",
349    "Fetched skel profile.",
350    $svnrev,
351    "$websvn/packages/etc/skel",
352    );
353
354foreach my $file ( "$BUILDDIR/etc/skel/.firstlogin", "$BUILDDIR/etc/skel/.bash_profile", ) {
355    $Bccd->run_test(
356        "chmod",
357        "",
358        "chmod 0755 $file",
359        0755,
360        "$file",
361        );
362}
363
364if(-f "$BUILDDIR/etc/skel/.bashrc") {
365    $Bccd->run_test(
366        "unlink",
367        "",
368        "Removed default .bashrc",
369        "$BUILDDIR/etc/skel/.bashrc",
370        );
371}
372
373$Bccd->run_test(
374    "chdir",
375    "",
376    "cd'ing into $BUILDDIR/etc/skel",
377    "$BUILDDIR/etc/skel",
378    );
379
380$Bccd->run_test(
381    "chdir",
382    "",
383    "cd $cwd",
384    "$cwd",
385    );
386
387$Bccd->run_test(
388    "revfetch",
389    "",
390    "Fetched gen_c3_conf autogen script.",
391    $svnrev,
392    "$websvn/packages/gen_c3_conf.sh",
393    "$BUILDDIR/root/gen_c3_conf.sh",
394    );
395
396$Bccd->run_test(
397    "revfetch",
398    "",
399    "Fetched liberate script.",
400    $svnrev,
401    "$websvn/packages/liberate.pl",
402    "$BUILDDIR/root/liberate.pl",
403    );
404
405$Bccd->run_test(
406    "chmod",
407    "",
408    "Set gen_c3_conf executable.",
409    0754,
410    "$BUILDDIR/root/gen_c3_conf.sh"
411    );
412
413$Bccd->run_test(
414    "revfetch",
415    "",
416    "Fetched /etc/default/useradd file.",
417    $svnrev,
418    "$websvn/packages/etc/default/useradd",
419    "$BUILDDIR/etc/default/useradd",
420    );
421
422$Bccd->run_test(
423    "fwrite",
424    "",
425    "Allowing initrd kernel upgrade.",
426    "a",
427    "$BUILDDIR/etc/kernel-img.conf",
428    "do_initrd=yes",
429    );
430
431$Bccd->run_test(
432    "system",
433    "",
434    "Updated apt cache.",
435    "/usr/sbin/chroot $BUILDDIR apt-get update",
436    );
437
438$Bccd->run_test(
439    "system",
440    "",
441    "Fetched Debian keyring.",
442    "/usr/sbin/chroot $BUILDDIR apt-get -y --allow-unauthenticated  install debian-archive-keyring",
443    );
444
445$Bccd->run_test(
446    "system",
447    "0",
448    "Fetched Debian packages.",
449    "/usr/sbin/chroot $BUILDDIR aptitude -y install $PACKAGES $EXTRA_PACKAGES",
450    );
451
452$Bccd->run_test(
453    "system",
454    "",
455    "Deleted cached deb packages.",
456    "/usr/sbin/chroot $BUILDDIR apt-get clean",
457    );
458
459$Bccd->run_test(
460    "system",
461    "",
462    "Stopped pdnsd.",
463    "killall pdnsd",
464    );
465
466$Bccd->run_test(
467    "revfetch",
468    "",
469    "Fetched tftpd-hpa configuration.",
470    $svnrev,
471    "$websvn/packages/etc/default/tftpd-hpa",
472    "$BUILDDIR/etc/default/tftpd-hpa",
473    );
474
475$Bccd->run_test(
476    "revfetch",
477    "",
478    "Fetched NIS default domain.",
479    $svnrev,
480    "$websvn/packages/etc/defaultdomain",
481    "$BUILDDIR/etc/defaultdomain",
482    );
483
484$Bccd->run_test(
485    "revfetch",
486    "",
487    "Fetched Knoppix cloop package.",
488    $svnrev,
489    "$websvn/packages/cloop-module-2.6.19_2.05-1_i386.deb",
490    "$BUILDDIR/tmp/cloop.deb",
491    );
492
493$Bccd->run_test(
494    "revfetch",
495    "",
496    "Fetched Knoppix Linux package.",
497    $svnrev,
498    "$websvn/packages/linux-image-2.6.19_2.6.19-10.00.Custom_i386.deb",
499    "$BUILDDIR/tmp/linux-image.deb",
500    );
501
502$Bccd->run_test(
503    "mkpath",
504    "",
505    "Making $KERNREV modules directory.",
506    "$BUILDDIR/lib/modules/$KERNREV",
507    );
508
509$cwd = getcwd();
510
511$Bccd->run_test(
512    "chdir",
513    "",
514    "cd'ing to $KERNREV modules directory.",
515    "$BUILDDIR/lib/modules/",
516    );
517
518$Bccd->run_test(
519    "recrevfetch",
520    "",
521    "Fetched Knoppix kernel modules.",
522    $svnrev,
523    "$websvn/trees/linux_aufs/lib/modules/$KERNREV",
524    );
525
526$Bccd->run_test(
527    "chdir",
528    "",
529    "Changing back to old directory.",
530    "$cwd",
531    );
532
533$Bccd->run_test(
534    "revfetch",
535    "",
536    "Fetched ssh_config file.",
537    $svnrev,
538    "$websvn/packages/etc/ssh/ssh_config",
539    "$BUILDDIR/etc/ssh/ssh_config",
540    );
541
542$Bccd->run_test(
543    "revfetch",
544    "",
545    "Fetched sshd_config file.",
546    $svnrev,
547    "$websvn/packages/etc/ssh/sshd_config",
548    "$BUILDDIR/etc/ssh/sshd_config",
549    );
550
551$Bccd->run_test(
552    "mkpath",
553    "",
554    "mkdir $BUILDDIR/etc/udev/rules.d",
555    "$BUILDDIR/etc/udev/rules.d",
556    );
557
558$Bccd->run_test(
559    "revfetch",
560    "",
561    "Fetched USB automounting udev rule.",
562    $svnrev,
563    "$websvn/packages/etc/udev/rules.d/99-automount_usb.rules",
564    "$BUILDDIR/etc/udev/rules.d/99-automount_usb.rules",
565    );
566
567# Revision write
568
569$Bccd->run_test(
570    "fwrite",
571    "",
572    "Opened $BUILDDIR/etc/$PROJECT-revision for writing.",
573    "w",
574    "$BUILDDIR/etc/$PROJECT-revision",
575    "$svnrev",
576    );
577
578# PAM fetch
579foreach my $file ( "rlogin", "rsh" ) {
580    $Bccd->run_test(
581        "revfetch",
582        "",
583        "Fetched /etc/pam.d/$file file.",
584        $svnrev,
585        "$websvn/packages/etc/pam.d/$file",
586        "$BUILDDIR/etc/pam.d/$file",
587        );
588}
589
590# Install software
591
592$Bccd->run_test(
593    "mkpath",
594    "",
595    "Created node checkin directory.",
596    "$CHECKIN",
597    );
598
599
600$nouid = $Bccd->run_test(
601    "getuseruid",
602    "",
603    "Got uid for nobody user.",
604    "nobody",
605    );
606
607$nogid = $Bccd->run_test(
608    "getusergid",
609    "",
610    "Got gid for nobody user.",
611    "nobody",
612    );
613
614$Bccd->run_test(
615    "chown",
616    "",
617    "chown'd checkin directory $CHECKIN to $nouid:$nogid.",
618    "$nouid",
619    "$nogid",
620    "$CHECKIN",
621    );
622
623if( ! -f "$BUILDDIR/usr/bin/python2" ) {
624    $Bccd->run_test(
625        "symlink",
626        "",
627        "Linked python->python2 for C3 tools.",
628        "$BUILDDIR/usr/bin/python",
629        "$BUILDDIR/usr/bin/python2",
630        );
631}
632
633$Bccd->run_test(
634    "revfetch",
635    "",
636    "Fetched c3 tools tarball.",
637    $svnrev,
638    "$websvn/packages/c3-4.0.1.tar.gz",
639    "$tmpdir/c3.tar.gz",
640    );
641
642$Bccd->run_test(
643    "system",
644    "",
645    "Extracted c3 tools tarball.",
646    "tar -C $BUILDDIR/opt -xzf $tmpdir/c3.tar.gz",
647    );
648
649$Bccd->run_test(
650    "rename",
651    "",
652    "Renamed /opt/c3-4.0.1 to /opt/c3-4.",
653    "$BUILDDIR/opt/c3-4.0.1",
654    "$BUILDDIR/opt/c3-4",
655    );
656
657$Bccd->run_test(
658    "fcopy",
659    "",
660    "Copied pxelinux to tftpboot.",
661    "$BUILDDIR/usr/lib/syslinux/pxelinux.0",
662    "$BUILDDIR/var/lib/tftpboot/pxelinux.0",
663    );
664
665$Bccd->run_test(
666    "mkpath",
667    "",
668    "Made $BUILDDIR/var/lib/tftpboot/pxelinux.cfg",
669    "$BUILDDIR/var/lib/tftpboot/pxelinux.cfg",
670    );
671
672foreach my $file ( "dhcpd.conf", "dhclient.conf", "dhclient.conf-bccd", "dhclient.conf-any" ) {
673    $Bccd->run_test(
674        "revfetch",
675        "",
676        "Fetched DHCP $file configuration.",
677        $svnrev,
678        "$websvn/packages/etc/dhcp3/$file",
679        "$BUILDDIR/etc/dhcp3/$file",
680        );
681}
682
683# Needed down here to prevent hang with debconf
684foreach my $file ( "exports", "hosts.equiv", "gpm.conf", "inittab" ) {
685    $Bccd->run_test(
686        "revfetch",
687        "",
688        "Fetched /etc/$file file.",
689        $svnrev,
690        "$websvn/packages/etc/$file",
691        "$BUILDDIR/etc/$file",
692        );
693}
694
695$Bccd->run_test(
696    "system",
697    "",
698    "Setting LSB parsing of init scripts.",
699    "touch $BUILDDIR/etc/update-rc.d-lsbparse",
700    );
701
702foreach my $script ( "nis", "ssh-host-keys", "nfs-kernel-server", "ssh", "dhcp3-server", "dbus", "hal", "apache2" ) {
703    $Bccd->run_test(
704        "system",
705        "",
706        "Disabled $script.",
707        "/usr/sbin/chroot $BUILDDIR /usr/sbin/update-rc.d -f $script remove",
708        );
709}
710
711foreach my $script ( "bccd-passwd","bccd-sshd", "bccd-nfs", "nfs-common", "vboxadd-service", "mpd" ) {
712    $Bccd->run_test(
713        "system",
714        "",
715        "Enabling $script at boot time.",
716        "/usr/sbin/chroot $BUILDDIR /usr/sbin/update-rc.d $script defaults",
717        );
718}
719
720# This must run before 20 (bccd-passwd) and autofs
721foreach my $script ( "bccd-keyboard", "bccd-unite-sw", "perfctr", ) {
722    $Bccd->run_test(
723        "system",
724        "",
725        "Enabling $script config.",
726        "/usr/sbin/chroot $BUILDDIR /usr/sbin/update-rc.d $script defaults 18",
727        );
728}
729
730$Bccd->run_test(
731        "system",
732        "",
733        "Enabling home directory overlay cleaning.",
734        "/usr/sbin/chroot $BUILDDIR /usr/sbin/update-rc.d bccd-clean-home start 5 2 S .",
735        );
736
737$Bccd->run_test(
738    "system",
739    "",
740    "Enabling bccd-nics config.",
741    "/usr/sbin/chroot $BUILDDIR /usr/sbin/update-rc.d bccd-nics defaults 39",
742    );
743
744$Bccd->run_test(
745    "system",
746    "",
747    "Enabling bccd-dhcp-conf config.",
748    "/usr/sbin/chroot $BUILDDIR /usr/sbin/update-rc.d bccd-dhcp-conf defaults 38",
749    );
750
751$Bccd->run_test(
752    "system",
753    "",
754    "Enabling bccd-route config.",
755    "/usr/sbin/chroot $BUILDDIR /usr/sbin/update-rc.d bccd-route defaults 41",
756    );
757
758$Bccd->run_test(
759    "system",
760    "",
761    "Enabling bccd-fsrw config.",
762    "/usr/sbin/chroot $BUILDDIR /usr/sbin/update-rc.d bccd-fsrw defaults 11",
763    );
764
765$Bccd->run_test(
766    "system",
767    "",
768    "Enabling bccd-networking config.",
769    "/usr/sbin/chroot $BUILDDIR /usr/sbin/update-rc.d bccd-networking start 42 2 S .",
770    );
771
772$Bccd->run_test(
773    "system",
774    "",
775    "Enabling bccd-dhcp config.",
776    "/usr/sbin/chroot $BUILDDIR /usr/sbin/update-rc.d bccd-dhcp defaults 40",
777    );
778
779$Bccd->run_test(
780    "system",
781    "",
782    "Added root password.",
783    "/usr/sbin/chroot $BUILDDIR /usr/sbin/usermod -p '\$1\$erNdlHdL\$EV6C0eBbe6M3bVaK9m4If0' root",
784    );
785
786# User creation
787
788# Manual writes to keep NIS from interfering with static uid/gid
789
790$Bccd->run_test(
791    "fwrite",
792    "",
793    "Wrote out sshd user.",
794    "a",
795    "$BUILDDIR/etc/passwd",
796    "sshd:x:103:65534::/var/run/sshd:/usr/sbin/nologin",
797    );
798
799$Bccd->run_test(
800    "fwrite",
801    "",
802    "Wrote out sshd group.",
803    "a",
804    "$BUILDDIR/etc/shadow",
805    "sshd:!:13625:0:99999:7:::",
806    );
807
808$Bccd->run_test(
809    "system",
810    "",
811    "Creating non-root-group account.",
812    "/usr/sbin/chroot $BUILDDIR /usr/sbin/groupadd -g 1000 bccd",
813    );
814
815$Bccd->run_test(
816    "system",
817    "",
818    "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",
819    );
820
821$Bccd->run_test(
822    "system",
823    "",
824    "Altered non-root account directory for KNOPPIX.",
825    "/usr/sbin/chroot $BUILDDIR /usr/sbin/usermod -d /UNIONFS/home/$USER $USER",
826    );
827
828# Bccd perl modules
829
830$Bccd->run_test(
831    "mkpath",
832    "",
833    "mkdir $BUILDDIR/$PERLDIR",
834    "$BUILDDIR/$PERLDIR",
835    );
836
837$Bccd->run_test(
838    "chdir",
839    "",
840    "cd'd to $BUILDDIR/$PERLDIR/../",
841    "$BUILDDIR/$PERLDIR/../",
842    );
843
844
845$Bccd->run_test(
846    "recrevfetch",
847    "",
848    "Checked out Bccd perl modules.",
849    $svnrev,
850    "$websvn/packages/$PERLDIR/",
851    );
852
853$Bccd->run_test(
854    "chdir",
855    "",
856    "cd'd to $tmpdir.",
857    "$tmpdir",
858    );
859
860$Bccd->run_test(
861    "recrevfetch",
862    "",
863    "Checked out hardware autodetect stuff.",
864    $svnrev,
865    "$websvn/trees/hwsetup/",
866    );
867
868$Bccd->run_test(
869    "system",
870    "",
871    "Copied hardware autodetect into $BUILDDIR.",
872    "cp -R $tmpdir/hwsetup/* $BUILDDIR/",
873    );
874
875# Starting hwsetup init scripts
876foreach my $script ( "knoppix-autoconfig", "xserver-xorg" ) {
877    $Bccd->run_test(
878        "system",
879        "",
880        "Enabled $script.",
881        "/usr/sbin/chroot $BUILDDIR /usr/sbin/update-rc.d $script start 20 2 3 4 5 .",
882        );
883}
884
885# Software install
886
887$Bccd->run_test(
888    "chdir",
889    "",
890    "cd'd to $BUILDDIR",
891    "$BUILDDIR",
892    );
893
894$Bccd->run_test(
895    "recrevfetch",
896    "",
897    "Fetched software tree.",
898    $svnrev,
899    "$websvn/trees/software/bccd/",
900    );
901
902$Bccd->run_test(
903    "system",
904    "",
905    "Changed $SOFTWARE to bccd:bccd.",
906    "/usr/sbin/chroot $BUILDDIR /bin/chown -R bccd:bccd $SOFTWARE",
907    );
908
909foreach my $prog ( <$BUILDDIR/bccd/software/*/bin/*> ) {
910    $Bccd->run_test(
911        "chmod",
912        "",
913        "chmod 0755 $prog",
914        0755,
915        "$prog",
916        );
917}
918
919$Bccd->run_test(
920        "mkpath",
921        "",
922        "mkdir $BUILDDIR/usr/lib/iceweasel/plugins",
923        "$BUILDDIR/usr/lib/iceweasel/plugins", 
924        );
925
926$Bccd->run_test(
927        "fcopy",
928        "",
929        "cp $BUILDDIR//bccd/software/jre1.6.0_13/plugin/i386/ns7/libjavaplugin_oji.so $BUILDDIR/usr/lib/iceweasel/plugins",
930        "$BUILDDIR//bccd/software/jre1.6.0_13/plugin/i386/ns7/libjavaplugin_oji.so",
931        "$BUILDDIR/usr/lib/iceweasel/plugins",
932        );
933
934$Bccd->run_test(
935    "chdir",
936    "",
937    "cd $BUILDDIR/",
938    "$BUILDDIR/",
939    );
940
941$Bccd->run_test(
942    "recrevfetch",
943    "",
944    "Fetched test tree.",
945    $svnrev,
946    "$websvn/trees/home",
947    );
948
949$Bccd->run_test(
950    "system",
951    "",
952    "chown'd $BUILDDIR/home/bccd to bccd:bccd",
953    "/usr/sbin/chroot $BUILDDIR chown -R $USER:$USER /home/bccd",
954    );
955
956$Bccd->run_test(
957    "chmod",
958    "",
959    "chmod 0600 $BUILDDIR/home/bccd/.mpd.conf",
960    0600,
961    "$BUILDDIR/home/bccd/.mpd.conf",
962    );
963
964$Bccd->run_test(
965    "chmod",
966    "",
967    "chmod 0755 $BUILDDIR/root/.ssh/",
968    0755,
969    "$BUILDDIR/root/.ssh/",
970    );
971
972$Bccd->run_test(
973    "chmod",
974    "",
975    "chmod 0755 $BUILDDIR/home/$USER/.ssh",
976    0755,
977    "$BUILDDIR/home/$USER/.ssh",
978    );
979
980$Bccd->run_test(
981                "chmod",
982                "",
983                "chmod 0755 $BUILDDIR/home/$USER",
984                0755,
985                "$BUILDDIR/home/$USER",
986                );
987
988foreach my $file ( "$BUILDDIR/root/.ssh/bccd", "$BUILDDIR/root/.ssh/config" ) {
989    $Bccd->run_test(
990        "chmod",
991        "",
992        "chmod 0600 $file",
993        0600,
994        "$file",
995        );
996}
997
998foreach my $key ( <$BUILDDIR/etc/ssh/ssh*key*> ) {
999    $Bccd->run_test(
1000        "unlink",
1001        "",
1002        "Removed ssh key $key.",
1003        "$key",
1004        );
1005}
1006
1007$Bccd->run_test(
1008    "system",
1009    "",
1010    "Requiring bccd ssh start script for ssh start.",
1011    "perl -wpli -e 's/^(#\\s+Required-Start:\\s+.*\$)/\$1 bccd-sshd/' $BUILDDIR/etc/init.d/ssh",
1012    );
1013
1014$Bccd->run_test(
1015    "system",
1016    "",
1017    "Requiring bccd nic start script for networking start.",
1018    "perl -wpli -e 's/^(#\\s+Required-Start:\\s+.*\$)/\$1 bccd-nics/' $BUILDDIR/etc/init.d/networking",
1019    );
1020
1021$Bccd->run_test(
1022    "system",
1023    "",
1024    "Allowing pdnsd to listen on all interfaces.",
1025    "perl -wpli -e 's!(server_ip = )!// \$1!g' $BUILDDIR/usr/share/pdnsd/pdnsd-resolvconf.conf",
1026    );
1027
1028$Bccd->run_test(
1029    "system",
1030    "",
1031    "Fixing cstddef for openmpi.",
1032    "perl -wpli -e 's/#include_next/#include/g' $BUILDDIR/usr/include/c++/4.3/cstddef",
1033    );
1034
1035# Make us LIVE
1036
1037$Bccd->run_test(
1038    "fwrite",
1039    "",
1040    "Made us LIVE.",
1041    "w",
1042    "$BUILDDIR/etc/$PROJECT-stage",
1043    "LIVE",
1044    );
1045
1046# Setting up menus
1047
1048foreach my $file (<$BUILDDIR/usr/share/menu/*>) {
1049    $Bccd->run_test(
1050        "unlink",
1051        "",
1052        "rm'd X menu item $file",
1053        "$file",
1054        );
1055}
1056
1057$cwd = getcwd();
1058
1059$Bccd->run_test(
1060    "chdir",
1061    "",
1062    "cd $BUILDDIR/",
1063    "$BUILDDIR/",
1064    );
1065
1066$Bccd->run_test(
1067    "recrevfetch",
1068    "",
1069    "Fetched /usr items.",
1070    $svnrev,
1071    "$websvn/trees/usr/",
1072    );
1073
1074$Bccd->run_test(
1075    "chdir",
1076    "",
1077    "Changed back to old directory.",
1078    "$cwd",
1079    );
1080
1081$Bccd->run_test(
1082    "system",
1083    "",
1084    "Updated desktop menus.",
1085    "/usr/sbin/chroot $BUILDDIR /usr/bin/update-menus",
1086    );
1087
1088# Software end
1089
1090# Pre-fetching liberation stuff
1091
1092$Bccd->run_test(
1093    "revfetch",
1094    "",
1095    "Fetched LVM fdisk script.",
1096    $svnrev,
1097    "$websvn/packages/fdisk_lvm.input",
1098    "$BUILDDIR/$LIBFETCH/fdisk_lvm.input",
1099    );
1100
1101$Bccd->run_test(
1102    "revfetch",
1103    "",
1104    "Fetched liberation exports file.",
1105    $svnrev,
1106    "$websvn/packages/etc/exports.liberate",
1107    "$BUILDDIR/$LIBFETCH/exports",
1108    );
1109
1110$Bccd->run_test(
1111    "chdir",
1112    "",
1113    "cd'ing to $BUILDDIR/$LIBFETCH/.",
1114    "$BUILDDIR/$LIBFETCH",
1115    );
1116
1117$Bccd->run_test(
1118    "recrevfetch",
1119    "",
1120    "Fetched $websvn/trees/linux_aufs over svn.",
1121    $svnrev,
1122    "$websvn/trees/linux_aufs/",
1123    );
1124
1125$Bccd->run_test(
1126    "system",
1127    "",
1128    "Tar'd up linux_aufs.",
1129    "tar -C $BUILDDIR/$LIBFETCH/linux_aufs -cjvf $BUILDDIR/$LIBFETCH/lib-linux.tar.bz2 .",
1130    );
1131
1132$Bccd->run_test(
1133    "rmtree",
1134    "",
1135    "Removing linux_aufs fetch.",
1136    "linux_aufs",
1137    );
1138
1139foreach my $file (grep(-f $_, <$BUILDDIR/var/lib/apt/lists/*>)) {
1140        $Bccd->run_test(
1141            "unlink",
1142            "",
1143            "Removed apt file lists.",
1144            "$file",
1145            );
1146}
1147
1148$Bccd->run_test(
1149    "recrevfetch",
1150    "",
1151    "Fetched $websvn/trees/diskless over svn.",
1152    $svnrev,
1153    "$websvn/trees/diskless",
1154    );
1155
1156$Bccd->run_test(
1157    "chdir",
1158    "",
1159    "Reverted to $cwd.",
1160    "$cwd",
1161    );
1162
1163$Bccd->run_test(
1164    "revfetch",
1165    "",
1166    "Fetched grub menu.",
1167    $svnrev,
1168    "$websvn/packages/boot/grub/menu.lst",
1169    "$BUILDDIR/$LIBFETCH/grub_menu.lst",
1170    );
1171
1172$Bccd->run_test(
1173    "lsofkill",
1174    "",
1175    "Killing procs in $BUILDDIR: ",
1176    "$BUILDDIR",
1177    );
1178
1179# Make here so automount doesn't destroy it
1180
1181$Bccd->run_test(
1182    "mkpath",
1183    "",
1184    "mkdir $BUILDDIR/mnt/ssh",
1185    "$BUILDDIR/mnt/ssh",
1186    );
1187
1188$Bccd->run_test(
1189    "system",
1190    "",
1191    "Unmounted $BUILDDIR/proc.",
1192    "umount -f $BUILDDIR/proc",
1193    );
1194
1195$Bccd->run_test(
1196    "chdir",
1197    "",
1198    "cd'd to $tmpdir for Knoppix fetch.",
1199    "$tmpdir",
1200    );
1201
1202$Bccd->run_test(
1203    "recrevfetch",
1204    "",
1205    "Fetched KNOPPIX sans root filesystem.",
1206    $svnrev,
1207    "$websvn/trees/KNOPPIX/",
1208    );
1209
1210$Bccd->run_test(
1211    "regexsub_file",
1212    "",
1213    "Adding revision to KNOPPIX boot file.",
1214    "$tmpdir/KNOPPIX/boot/isolinux/boot.msg",
1215    "==REVISION==",
1216    "$svnrev",
1217    );
1218
1219$Bccd->run_test(
1220    "revfetch",
1221    "",
1222    "Fetched knoppix kernel image.",
1223    $svnrev,
1224    "$websvn/trees/linux_aufs/boot/vmlinuz-$KERNREV",
1225        "$KNOPDIR/boot/isolinux/linux",
1226    );
1227
1228$Bccd->run_test(
1229    "regexsub_file",
1230    "",
1231    "Adding date to KNOPPIX boot file.",
1232    "$tmpdir/KNOPPIX/boot/isolinux/boot.msg",
1233    "==DATE==",
1234    "$FORMAT_DATE",
1235    );
1236
1237$Bccd->run_test(
1238        "fwrite",
1239        "",
1240        "Writing out date to /etc/$PROJECT-build-date.",
1241        "w",
1242        "$BUILDDIR/etc/$PROJECT-build-date",
1243        "$FORMAT_DATE",
1244        );
1245
1246$Bccd->run_test(
1247    "system",
1248    "",
1249    "Created compressed root filesystem.",
1250    "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'",
1251    );
1252
1253$Bccd->run_test(
1254    "system",
1255    "",
1256    "Created bootable ISO image.",
1257    "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",
1258    );
1259
1260print "Passed ".$Bccd->get_passed()." out of ".$Bccd->get_total()." total tests.\n";
1261
1262if($opts{'updatedb'}) {
1263    my $dbh = open_db("$opts{'updatedb'}");
1264    if( $Bccd->get_passed() < $Bccd->get_total() ) {
1265        insert_results($TESTNAME,$STAGE,$svnrev,$Bccd->snarf_file("$tmpdir/allout"),"FAILURE",$dbh);
1266    } else {
1267        insert_results($TESTNAME,$STAGE,$svnrev,$Bccd->snarf_file("$tmpdir/allout"),"SUCCESS",$dbh);
1268    }
1269    $Bccd->close_stdio();
1270    $dbh->disconnect;
1271}
1272
1273exit $Bccd->get_total()-$Bccd->get_passed();
1274
1275__END__
1276
1277build_livecd.pl - Build process based on Knoppix Live CD creation
1278
1279=head1 - SYNOPSIS
1280
1281This script is based on KNOPPIX project documentation for creating a
1282Debian-based Live CD using cloop.
1283
1284=head1 - OPTIONS
1285
1286=over 8
1287
1288=item B<--builddir> I<path-to-dir>
1289
1290Path to build directory for live CD. Will be cleaned up after the work is
1291done.
1292
1293=item B<--arch> I<arch>
1294
1295Architecture to build for.
1296
1297=item B<--outiso> I<path-to-file>
1298
1299Where to output the bccd ISO image.
1300
1301=item B<--websvn> I<websvn-url>
1302
1303Path to bccd's websvn branch, i.e. http://cluster.earlham.edu/svn/bccd-ng/trunk.
1304
1305=item B<--suite> I<release-name>
1306
1307Name of the Debian release suite to download.
1308
1309=item B<--nocleanup>
1310
1311Preserve the /tmp directory for investigation.
1312
1313=item B<--help>
1314
1315This message.
1316
1317=cut
Note: See TracBrowser for help on using the repository browser.