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

Last change on this file since 2619 was 2619, checked in by fitz, 10 years ago

merging from trunk

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