Changeset 2496 in /cluster/svnroot


Ignore:
Timestamp:
Jun 24, 2010 12:10:41 AM (10 years ago)
Author:
skylar
Message:

using new File::Temp constructor to cause clean up to happen when leaving scope (#512)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • bccd-ng/branches/skylar-devel/bin/build_livecd.pl

    r2492 r2496  
    1515use Readonly;
    1616
    17 $ENV{LANGUAGE} = "C";
    18 $ENV{LC_ALL} = "C";
    19 $ENV{LANG} = "C";
    20 
    2117my %opts;
    2218
     
    5349
    5450Readonly my $PROJECT => 'bccd';
    55 $ft = new File::Temp();
     51if(defined($opts{'nocleanup'})) {
     52        $ft = File::Temp->newdir("/tmp/$PROJECT.XXXXXXX",CLEANUP => 0);
     53}
     54else {
     55        $ft = File::Temp->newdir("/tmp/$PROJECT.XXXXXXX",DIR=>$dir,CLEANUP => 1);
     56
     57}
     58$tmpdir = $ft->dirname();
    5659if(defined($opts{'dir'})) {
    5760        $dir = $opts{'dir'};
     
    6063}
    6164
    62 if(defined($opts{'nocleanup'})) {
    63     $tmpdir = $ft->tempdir('$PROJECT',DIR => $dir,CLEANUP => 0);
    64 } else {
    65     $tmpdir = $ft->tempdir('$PROJECT',DIR => $dir,CLEANUP => 1);
    66 }
    6765$Bccd = new Bccd();
    6866
     
    7270        $debmirror_host = "debmirror.cluster.earlham.edu";
    7371}
    74 $debmirror = "http://$debmirror_host";
     72$debmirror = "http://$debmirror_host/apt/mirror/bccd-ng/debian/";
    7573
    7674if(defined($opts{'websvn'})) {
    7775        $websvn = $opts{'websvn'};
    7876} else {
    79         $websvn = "http://bccd-ng.cluster.earlham.edu/svn/bccd-ng/branches/skylar-devel/";
     77        $websvn = "http://bccd-ng.cluster.earlham.edu/svn/bccd-ng/trunk/";
    8078}
    8179
     
    8886Readonly my $LIBFETCH   => "/root/liberate";
    8987$ENV{'DEBIAN_FRONTEND'} = "noninteractive";
    90 Readonly 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";
     88Readonly 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 netpbm imagemagick libyaml-perl";
    9189Readonly 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";
    92 Readonly my $AMD64_PACKAGES => "libc6-dev-i386 ia32-libs";
    9390Readonly my $BAD_PACKAGES   => ""; # Packages that throw some fatal error during install but still work
    9491Readonly my $PERLDIR        => "/usr/local/lib/site_perl/";
     
    10198Readonly my $FORMAT_DATE    => ($TIME[5]+1900)."-".($TIME[4]+1)."-".$TIME[3];
    10299Readonly my $SPLASH_FILE    => 'bccd_logo_new.png';
    103 Readonly my @MINIRT_MODS    => (
    104                                 "BusLogic.ko",
    105                                 "NCR53c406a.ko",
    106                                 "a100u2w.ko",
    107                                 "advansys.ko",
    108                                 "aic7xxx.ko",
    109                                 "cloop.ko",
    110                                 "dc395x.ko",
    111                                 "dtc.ko",
    112                                 "eata.ko",
    113                                 "ehci-hcd.ko",
    114                                 "fdomain.ko",
    115                                 "ff-memless.ko",
    116                                 "forcedeth.ko",
    117                                 "gdth.ko",
    118                                 "ieee1394.ko",
    119                                 "initio.ko",
    120                                 "libusual.ko",
    121                                 "loop.ko",
    122                                 "mptbase.ko",
    123                                 "mptscsih.ko",
    124                                 "ohci-hcd.ko",
    125                                 "ohci1394.ko",
    126                                 "pas16.ko",
    127                                 "psi240i.ko",
    128                                 "sbp2.ko",
    129                                 "sym53c8xx.ko",
    130                                 "t128.ko",
    131                                 "tmscsim.ko",
    132                                 "u14-34f.ko",
    133                                 "uhci-hcd.ko",
    134                                 "ultrastor.ko",
    135                                 "usb-storage.ko",
    136                                 "usbcore.ko",
    137                                 "usbhid.ko",
    138                                 "wd7000.ko",
    139                                 );
    140 
    141100# Revision fetch
    142101
     
    156115    $svnrev = $opts{'svnrev'};
    157116} else {
    158     $svnrev = $Bccd->run_test(
    159         "getsvnrev",
    160         "",
    161         "Got subversion revision of $websvn.",
    162         "$websvn",
    163         );
     117    if($websvn !~ /^http/) {
     118        $svnrev = "BASE";
     119    } else {
     120        $svnrev = $Bccd->run_test(
     121            "getsvnrev",
     122            "",
     123            "Got subversion revision of $websvn.",
     124            "$websvn",
     125            );
     126    }
    164127}
    165128
     
    189152    "",
    190153    "Mounted /proc into $BUILDDIR.",
    191     "mount -t proc none $BUILDDIR/proc",
    192     );
    193 
    194 $Bccd->run_test(
    195     "system",
    196     "",
    197     "Mounted /sys into $BUILDDIR.",
    198     "mount -t sysfs none $BUILDDIR/sys",
     154    "mount -t proc proc $BUILDDIR/proc",
    199155    );
    200156
     
    273229    "regexsub_file",
    274230    "",
    275     "Changed DEBMIRROR template in sources list to $debmirror_host.",
     231    "Changed DEBMIRROR template in sources list.",
    276232    "$BUILDDIR/etc/apt/sources.list",
    277233    "!DEBMIRROR!",
     
    316272          "lam.conf", "init.d/bccd-nfs", "init.d/bccd-unite-sw", "init.d/bccd-nics",
    317273          "init.d/bccd-dhcp-conf", "init.d/bccd-route", "init.d/bccd-keyboard", "rc.local",
    318           "init.d/bccd-fsrw", "auto.master", "auto.sshfs" ) {
     274          "init.d/bccd-fsrw", "auto.master", "auto.sshfs", "ld.so.conf.d/CUDA.conf" ) {
    319275    $Bccd->run_test(
    320276        "revfetch",
     
    447403    "revfetch",
    448404    "",
     405    "Fetched gen_c3_conf autogen script.",
     406    $svnrev,
     407    "$websvn/packages/gen_c3_conf.sh",
     408    "$BUILDDIR/root/gen_c3_conf.sh",
     409    );
     410
     411$Bccd->run_test(
     412    "revfetch",
     413    "",
    449414    "Fetched liberate script.",
    450415    $svnrev,
    451416    "$websvn/packages/liberate.pl",
    452417    "$BUILDDIR/root/liberate.pl",
     418    );
     419
     420$Bccd->run_test(
     421    "chmod",
     422    "",
     423    "Set gen_c3_conf executable.",
     424    0754,
     425    "$BUILDDIR/root/gen_c3_conf.sh"
    453426    );
    454427
     
    485458    );
    486459
    487 if($opts{'arch'} eq 'i386') {
    488         $Bccd->run_test(
    489             "system",
    490             "0",
    491             "Fetched Debian packages.",
    492             "/usr/sbin/chroot $BUILDDIR /usr/bin/aptitude --allow-untrusted -y install $PACKAGES $EXTRA_PACKAGES",
    493             );
    494 }
    495 elsif($opts{'arch'} eq 'amd64') {
    496         $Bccd->run_test(
    497             "system",
    498             "0",
    499             "Fetched Debian packages.",
    500             "/usr/sbin/chroot $BUILDDIR aptitude --allow-untrusted -y install $PACKAGES $EXTRA_PACKAGES $AMD64_PACKAGES",
    501             );
    502 
    503 }
    504 
    505 # Workaround for tftpd-hpa/inetd conflict
    506 $Bccd->run_test(
    507     "system",
    508     "",
    509     "Removing inetutils-inetd to avoid conflict with tftpd-hpa.",
    510     "/usr/sbin/chroot $BUILDDIR /usr/bin/dpkg -r inetutils-inetd",
    511     );
    512 
    513 $Bccd->run_test(
    514     "system",
    515     100,
    516     "Fetching tftpd-hpa separately.",
    517     "/usr/sbin/chroot $BUILDDIR /usr/bin/apt-get --force-yes -y install tftpd-hpa",
     460$Bccd->run_test(
     461    "system",
     462    "0",
     463    "Fetched Debian packages.",
     464    "/usr/sbin/chroot $BUILDDIR aptitude -y install $PACKAGES $EXTRA_PACKAGES",
    518465    );
    519466
     
    526473
    527474$Bccd->run_test(
     475    "system",
     476    "",
     477    "Stopped pdnsd.",
     478    "killall pdnsd",
     479    );
     480
     481$Bccd->run_test(
    528482    "revfetch",
    529483    "",
     
    548502    "Making $KERNREV modules directory.",
    549503    "$BUILDDIR/lib/modules/$KERNREV",
     504    );
     505
     506$cwd = getcwd();
     507
     508$Bccd->run_test(
     509    "chdir",
     510    "",
     511    "cd'ing to $KERNREV modules directory.",
     512    "$BUILDDIR/lib/modules/",
     513    );
     514
     515$Bccd->run_test(
     516    "recrevfetch",
     517    "",
     518    "Fetched Knoppix kernel modules.",
     519    $svnrev,
     520    "$websvn/trees/linux_aufs/lib/modules/$KERNREV",
     521    );
     522
     523$Bccd->run_test(
     524    "chdir",
     525    "",
     526    "Changing back to old directory.",
     527    "$cwd",
    550528    );
    551529
     
    595573    );
    596574
     575# PAM fetch
     576foreach my $file ( "rlogin", "rsh" ) {
     577    $Bccd->run_test(
     578        "revfetch",
     579        "",
     580        "Fetched /etc/pam.d/$file file.",
     581        $svnrev,
     582        "$websvn/packages/etc/pam.d/$file",
     583        "$BUILDDIR/etc/pam.d/$file",
     584        );
     585}
     586
    597587# Install software
    598588
     
    699689}
    700690
    701 foreach my $script ( "nfs-common", "vboxadd-service", "mpd" ) {
     691foreach my $script ( "bccd-passwd","bccd-sshd", "bccd-nfs", "nfs-common", "vboxadd-service", "mpd" ) {
    702692    $Bccd->run_test(
    703693        "system",
     
    709699
    710700# This must run before 20 (bccd-passwd) and autofs
    711 foreach my $script ( "bccd-unite-sw", "perfctr", ) {
     701foreach my $script ( "bccd-keyboard", "bccd-unite-sw", "perfctr", ) {
    712702    $Bccd->run_test(
    713703        "system",
     
    722712        "",
    723713        "Enabling home directory overlay cleaning.",
    724         "/usr/sbin/chroot $BUILDDIR /usr/sbin/update-rc.d bccd-clean-home start 5 2 .",
     714        "/usr/sbin/chroot $BUILDDIR /usr/sbin/update-rc.d bccd-clean-home start 5 2 S .",
    725715        );
    726716
     
    729719    "",
    730720    "Enabling bccd-nics config.",
    731     "/usr/sbin/chroot $BUILDDIR /usr/sbin/update-rc.d bccd-nics start 39 S .",
     721    "/usr/sbin/chroot $BUILDDIR /usr/sbin/update-rc.d bccd-nics defaults 39",
    732722    );
    733723
     
    736726    "",
    737727    "Enabling bccd-dhcp-conf config.",
    738     "/usr/sbin/chroot $BUILDDIR /usr/sbin/update-rc.d bccd-dhcp-conf start 38 S .",
     728    "/usr/sbin/chroot $BUILDDIR /usr/sbin/update-rc.d bccd-dhcp-conf defaults 38",
    739729    );
    740730
     
    743733    "",
    744734    "Enabling bccd-route config.",
    745     "/usr/sbin/chroot $BUILDDIR /usr/sbin/update-rc.d bccd-route start 41 S .",
     735    "/usr/sbin/chroot $BUILDDIR /usr/sbin/update-rc.d bccd-route defaults 41",
    746736    );
    747737
     
    750740    "",
    751741    "Enabling bccd-fsrw config.",
    752     "/usr/sbin/chroot $BUILDDIR /usr/sbin/update-rc.d bccd-fsrw start 11 S .",
    753     );
    754 
    755 $Bccd->run_test(
    756     "system",
    757     "",
    758     "Enabling bccd-keyboard config.",
    759     "/usr/sbin/chroot $BUILDDIR /usr/sbin/update-rc.d bccd-keyboard start 18 S .",
     742    "/usr/sbin/chroot $BUILDDIR /usr/sbin/update-rc.d bccd-fsrw defaults 11",
    760743    );
    761744
     
    770753    "system",
    771754    "",
    772     "Enabling networking config.",
    773     "/usr/sbin/chroot $BUILDDIR /usr/sbin/update-rc.d networking start 42 2 S .",
    774     );
    775 
    776 $Bccd->run_test(
    777     "system",
    778     "",
    779     "Enabling bccd-nfs config.",
    780     "/usr/sbin/chroot $BUILDDIR /usr/sbin/update-rc.d bccd-nfs start 20 2 S .",
    781     );
    782 
    783 $Bccd->run_test(
    784     "system",
    785     "",
    786     "Enabling bccd-passwd config.",
    787     "/usr/sbin/chroot $BUILDDIR /usr/sbin/update-rc.d bccd-passwd start 20 S .",
    788     );
    789 
    790 $Bccd->run_test(
    791     "system",
    792     "",
    793     "Enabling bccd-sshd config.",
    794     "/usr/sbin/chroot $BUILDDIR /usr/sbin/update-rc.d bccd-sshd start 20 2 S .",
    795     );
    796 
    797 $Bccd->run_test(
    798     "system",
    799     "",
    800755    "Enabling bccd-dhcp config.",
    801     "/usr/sbin/chroot $BUILDDIR /usr/sbin/update-rc.d bccd-dhcp start 40 S .",
     756    "/usr/sbin/chroot $BUILDDIR /usr/sbin/update-rc.d bccd-dhcp defaults 40",
    802757    );
    803758
     
    10981053
    10991054$Bccd->run_test(
    1100     "recrevfetch",
    1101     "",
    1102     "Fetched architecure-specific items for $opts{'arch'}.",
    1103     $svnrev,
    1104     "$websvn/trees/arch/$opts{'arch'}",
    1105     );
    1106 
    1107 $Bccd->run_test(
    1108     "system",
    1109     "",
    1110     "Copied architecture-specific items from /$opts{'arch'} to /.",
    1111         "/usr/sbin/chroot $BUILDDIR /usr/bin/rsync -av --progress /$opts{'arch'}/ /",
    1112     );
    1113 
    1114 $Bccd->run_test(
    1115         "fmove",
    1116         "",
    1117         "Moved cloop.ko into $tmpdir.",
    1118         "$BUILDDIR/KNOPPIX/KNOPPIX/modules/cloop.ko",
    1119         "$tmpdir/cloop.ko",
    1120         );
    1121 
    1122 $Bccd->run_test(
    11231055    "chdir",
    11241056    "",
     
    11731105
    11741106$Bccd->run_test(
     1107    "recrevfetch",
     1108    "",
     1109    "Fetched $websvn/trees/linux_aufs over svn.",
     1110    $svnrev,
     1111    "$websvn/trees/linux_aufs/",
     1112    );
     1113
     1114$Bccd->run_test(
    11751115    "system",
    11761116    "",
    11771117    "Tar'd up linux_aufs.",
    1178     "tar -C $BUILDDIR -cjvf $BUILDDIR/$LIBFETCH/lib-linux.tar.bz2 boot lib/modules var/lib/tftpboot",
     1118    "tar -C $BUILDDIR/$LIBFETCH/linux_aufs -cjvf $BUILDDIR/$LIBFETCH/lib-linux.tar.bz2 .",
     1119    );
     1120
     1121$Bccd->run_test(
     1122    "rmtree",
     1123    "",
     1124    "Removing linux_aufs fetch.",
     1125    "linux_aufs",
    11791126    );
    11801127
     
    12361183
    12371184$Bccd->run_test(
    1238     "system",
    1239     "",
    1240     "Unmounted $BUILDDIR/sys.",
    1241     "umount -l $BUILDDIR/sys",
    1242     );
    1243 
    1244 $Bccd->run_test(
    12451185    "chdir",
    12461186    "",
     
    12781218        "",
    12791219        "Created minirt filesystem.",
    1280         "dd if=/dev/zero of=$tmpdir/minirt bs=1k count=5400",
     1220        "dd if=/dev/zero of=$tmpdir/minirt bs=1M count=4",
    12811221        );
    12821222
     
    13101250
    13111251$Bccd->run_test(
    1312         "mkpath",
    1313         "",
    1314         "Made modules directory in loop filesystem.",
    1315         "$tmpdir/loop/modules/",
    1316         );
    1317 
    1318 foreach my $mod (@MINIRT_MODS) {
    1319         $Bccd->run_test(
    1320                 "system",
    1321                 "",
    1322                 "Copied $mod into minirt loop filesystem.",
    1323                 "find $BUILDDIR/lib/modules/$KERNREV/ -type f -name $mod -exec /bin/cp {} $tmpdir/loop/modules/$mod \\;",
    1324         );
    1325 }
    1326 
    1327 $Bccd->run_test(
    1328         "fcopy",
    1329         "",
    1330         "Moved cloop.ko into $tmpdir.",
    1331         "$tmpdir/cloop.ko",
    1332         "$tmpdir/loop/modules",
    1333         );
    1334 
    1335 $Bccd->run_test(
    13361252        "system",
    13371253        "",
     
    13841300    "Fetched knoppix kernel image.",
    13851301    $svnrev,
    1386     "$websvn/trees/arch/$opts{'arch'}/boot/vmlinuz-$KERNREV",
     1302    "$websvn/trees/linux_aufs/boot/vmlinuz-$KERNREV",
    13871303        "$KNOPDIR/boot/isolinux/linux",
    13881304    );
     
    14041320        "$BUILDDIR/etc/$PROJECT-build-date",
    14051321        "$FORMAT_DATE",
    1406         );
    1407 
    1408 $Bccd->run_test(
    1409         "rmtree",
    1410         "",
    1411         "Removing linux_aufs fetch for $BUILDDIR.",
    1412         "$BUILDDIR/$opts{'arch'}",
    14131322        );
    14141323
     
    14401349}
    14411350
     1351chdir $ENV{'HOME'};
     1352
    14421353exit $Bccd->get_total()-$Bccd->get_passed();
    14431354
Note: See TracChangeset for help on using the changeset viewer.