source: locker/update-system/bin/scripts-patch @ 363

Last change on this file since 363 was 363, checked in by quentin, 15 years ago
initial checkin of the update-system; not fully functional yetd
  • Property svn:executable set to *
File size: 1.4 KB
Line 
1#!/bin/bash
2set -e
3
4die () { echo "$1" >&2; exit 1; }
5
6path="$1"
7url=$(echo "$path" | perl -pe '/^\/mit\/([^\/]*)\/web_scripts\/(.*)$/; $_ = "http://scripts.mit.edu/~$1/$2\n";')
8[ "$url" != "http://scripts.mit.edu/~/" ] || die "Usage: scripts-patch /mit/<user>/web_scripts/<path>"
9
10versionfile=$path/.scripts-version
11[ -f "$versionfile" ] || die "$path was not created by the scripts installer."
12[ -r "$versionfile" ] || die "[$path] Could not read .scripts-version file."
13
14# The format of the .scripts-version file is such an awful mess.
15#
16# I feel like that needed to be said.
17
18version=$(tail -n +2 "$versionfile" | head -n1 | perl -pe '/File: .* -> \`(.*)\.tar\.(gz|bz2)'\''$/; $_ = $1')
19
20updatespath=/mit/andersk/Public/scripts/updates
21[ -d "$updatespath" ] || die "Could not find updates repository."
22[ -d "$updatespath/$version" ] || die "[$path] No update available for $version."
23echo "[$path] Applying update for $version:"
24
25pagebefore=`mktemp -t scripts-patch.XXXXXXXXXX`
26pageafter=`mktemp -t scripts-patch.XXXXXXXXXX`
27
28url=$(echo "$path" | perl -pe '/^\/mit\/([^\/]*)\/web_scripts\/(.*)$/; $_ = "http://scripts.mit.edu/~$1/$2\n";')
29wget -q "$url/" -O "$pagebefore"
30
31(cd "$path"; "$updatespath/$version/update") || die "[$path] *** FAILED UPDATE *** of $version"
32
33wget -q "$url/" -O "$pageafter"
34echo "[$path] Diff from before/after upgrade:"
35diff -U0 "$pagebefore" "$pageafter" || :
36
37rm -f "$pagebefore" "$pageafter"
Note: See TracBrowser for help on using the repository browser.