Changeset 497 for locker


Ignore:
Timestamp:
Oct 16, 2007, 11:20:19 PM (17 years ago)
Author:
quentin
Message:
Use new /mit/scripts/deploy format
Use full path to files in scripts-version file
Location:
locker/update-system/bin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • locker/update-system/bin/build-update

    r448 r497  
    1 #!/usr/athena/bin/perl
     1#!/usr/bin/env perl
    22
    33use File::Spec::Functions qw(:ALL);
     
    66use Data::Dumper;
    77use Getopt::Long;
     8use Archive::Tar;
    89use Cwd;
    910use strict;
     
    3334
    3435(-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: $!";
    3637
    3738my $olddir = catdir($proposaldir,$old);
     
    6364close(DELETE);
    6465
    65 my $outfiledir = catdir($outdir, "newfiles");
    66 (-d $outfiledir || mkdir($outfiledir)) or die "Can't mkdir($outfiledir)\n";
     66my $outfiletarball = catfile($outdir, "newfiles.tar.gz");
     67my $cwd = getcwd();
    6768
    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: $!";
     69chdir($newdir);
     70my $tar = Archive::Tar->new;
     71$tar->add_files(map { $_->[1] } @toadd, @toreplace);
     72$tar->write($outfiletarball, 1);
     73chdir($cwd) or die "Couldn't chdir back to $cwd: $!\n";
     74
     75if (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    }
    7587}
    7688
     
    7890
    7991open (SCRIPT, ">", catfile($outdir, "update")) or die "Couldn't write update: $!";
    80 printf SCRIPT <<'EOF', $updatename, $new;
     92printf SCRIPT <<'EOF', catfile("/mit/scripts/deploy/", $old), catfile("/mit/scripts/deploy/", $new);
    8193#!/bin/bash
    8294set -e -o noclobber
     
    88100>.scripts-security-upd-lock || die "error: Unable to obtain update lock."
    89101
     102packages=$(tail -n 1 .scripts-version)
     103
    90104echo "[$PWD] begin dry run"
    91105
     106found=""
     107newpackages=""
     108for package in $packages; do
     109    if [ "$package" = "%s" ]; then
     110    found="yes"
     111    newpackages="$newpackages%s "
     112    else
     113    newpackages="$newpackages$package "
     114    fi
     115done
     116
     117[ "$found" = "yes" ] || die "error: Correct version not found."
    92118xargs -n1 test ! -e <"$patchdir/oldfiles.absent" || die "error: Conflicting files exist."
    93119md5sum -c "$patchdir/check.md5" || die "error: MD5 check failed."
     
    99125patch -stN --no-backup-if-mismatch -p2 <"$patchdir/update.diff" || :
    100126xargs rm -f <"$patchdir/files.delete"
    101 cp -a "$patchdir/newfiles/." .
    102 (cat .scripts-version.old; date; echo "%s"; echo "%s") >>.scripts-version
     127tar -xzf "$patchdir/newfiles.tar.gz"
     128(cat .scripts-version.old; date "+%%F %%T %%z"; echo "$USER@$(hostname)"; echo "$patchdir"; echo "$newpackages") >>.scripts-version
    103129rm -f .scripts-version.old
    104130
  • locker/update-system/bin/propose-update

    r446 r497  
    4646  my $cwd = cwd();
    4747  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: $?"; }
    4950  my @files=`athrun scripts gfind . -mindepth 1 -maxdepth 1 | grep -v .admin`;
    5051  if (@files <= 1) {
     
    6768  my @aonly, @bonly, @both;
    6869  $a = $b = 0;
    69   my $debug = 1;
     70  my $debug = 0;
    7071  local $Data::Dumper::Indent = 0;
    7172  while ($a <= $#a || $b <= $#a) {
Note: See TracChangeset for help on using the changeset viewer.