- Timestamp:
- Oct 16, 2007, 11:20:19 PM (17 years ago)
- Location:
- locker/update-system/bin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
locker/update-system/bin/build-update
r448 r497 1 #!/usr/ athena/bin/perl1 #!/usr/bin/env perl 2 2 3 3 use File::Spec::Functions qw(:ALL); … … 6 6 use Data::Dumper; 7 7 use Getopt::Long; 8 use Archive::Tar; 8 9 use Cwd; 9 10 use strict; … … 33 34 34 35 (-d $proposaldir) or die "Can't find $proposaldir, did you run propose-update?\n"; 35 ( -d $outdir ||mkdir($outdir)) or die "mkdir($outdir) failed: $!";36 ((! -e $outdir) && mkdir($outdir)) or die "mkdir($outdir) failed: $!"; 36 37 37 38 my $olddir = catdir($proposaldir,$old); … … 63 64 close(DELETE); 64 65 65 my $outfile dir = catdir($outdir, "newfiles");66 (-d $outfiledir || mkdir($outfiledir)) or die "Can't mkdir($outfiledir)\n";66 my $outfiletarball = catfile($outdir, "newfiles.tar.gz"); 67 my $cwd = getcwd(); 67 68 68 foreach my $file (@toadd, @toreplace) { 69 my $filename = $file->[1]; 70 my $src = catfile($newdir, $filename); 71 my $dest = catfile($outfiledir, $filename); 72 my (undef, $dir, undef) = splitpath($dest); 73 mkpath($dir); 74 copy($src, $dest) or die "Couldn't copy $filename from $src to $dest: $!"; 69 chdir($newdir); 70 my $tar = Archive::Tar->new; 71 $tar->add_files(map { $_->[1] } @toadd, @toreplace); 72 $tar->write($outfiletarball, 1); 73 chdir($cwd) or die "Couldn't chdir back to $cwd: $!\n"; 74 75 if (0) { 76 my $outfiledir = catdir($outdir, "newfiles"); 77 (-d $outfiledir || mkdir($outfiledir)) or die "Can't mkdir($outfiledir)\n"; 78 79 foreach my $file (@toadd, @toreplace) { 80 my $filename = $file->[1]; 81 my $src = catfile($newdir, $filename); 82 my $dest = catfile($outfiledir, $filename); 83 my (undef, $dir, undef) = splitpath($dest); 84 mkpath($dir); 85 copy($src, $dest) or die "Couldn't copy $filename from $src to $dest: $!"; 86 } 75 87 } 76 88 … … 78 90 79 91 open (SCRIPT, ">", catfile($outdir, "update")) or die "Couldn't write update: $!"; 80 printf SCRIPT <<'EOF', $updatename, $new;92 printf SCRIPT <<'EOF', catfile("/mit/scripts/deploy/", $old), catfile("/mit/scripts/deploy/", $new); 81 93 #!/bin/bash 82 94 set -e -o noclobber … … 88 100 >.scripts-security-upd-lock || die "error: Unable to obtain update lock." 89 101 102 packages=$(tail -n 1 .scripts-version) 103 90 104 echo "[$PWD] begin dry run" 91 105 106 found="" 107 newpackages="" 108 for package in $packages; do 109 if [ "$package" = "%s" ]; then 110 found="yes" 111 newpackages="$newpackages%s " 112 else 113 newpackages="$newpackages$package " 114 fi 115 done 116 117 [ "$found" = "yes" ] || die "error: Correct version not found." 92 118 xargs -n1 test ! -e <"$patchdir/oldfiles.absent" || die "error: Conflicting files exist." 93 119 md5sum -c "$patchdir/check.md5" || die "error: MD5 check failed." … … 99 125 patch -stN --no-backup-if-mismatch -p2 <"$patchdir/update.diff" || : 100 126 xargs rm -f <"$patchdir/files.delete" 101 cp -a "$patchdir/newfiles/." . 102 (cat .scripts-version.old; date ; echo "%s"; echo "%s") >>.scripts-version127 tar -xzf "$patchdir/newfiles.tar.gz" 128 (cat .scripts-version.old; date "+%%F %%T %%z"; echo "$USER@$(hostname)"; echo "$patchdir"; echo "$newpackages") >>.scripts-version 103 129 rm -f .scripts-version.old 104 130 -
locker/update-system/bin/propose-update
r446 r497 46 46 my $cwd = cwd(); 47 47 chdir($dir) or die $!; 48 `athrun scripts gtar zxf "/mit/scripts/deploy$scriptsdev/$package.tar.gz"`; $? && die "Failed to unpack $package.tar.gz: $?"; 48 `athrun scripts gtar zxf "/mit/scripts/deploy$scriptsdev/$package/$package.tar.gz"`; 49 if ($?) { chdir($cwd); system("rmdir", "$dir"); die "Failed to unpack $package.tar.gz: $?"; } 49 50 my @files=`athrun scripts gfind . -mindepth 1 -maxdepth 1 | grep -v .admin`; 50 51 if (@files <= 1) { … … 67 68 my @aonly, @bonly, @both; 68 69 $a = $b = 0; 69 my $debug = 1;70 my $debug = 0; 70 71 local $Data::Dumper::Indent = 0; 71 72 while ($a <= $#a || $b <= $#a) {
Note: See TracChangeset
for help on using the changeset viewer.