4 echo "Usage: $0 filename version arch changes_file"
8 TARBALL="$1" # Tarball to read, compressed with gzip
11 CHANGES="$4" # Changes file for the upload
18 # Check validity of version number
19 # Expected are: YYYYMMDD, YYYYMMDD.x, YYYYMMDD<suite>x
20 if ! echo "$VERSION" | grep -Eq "^[0-9]{8}(|(\.|[a-z]+)[0-9]+)$"; then
21 error "Invalid version: '$VERSION'"
24 # Get the target suite from the Changes file
25 # NOTE: it may be better to pass this to the script as a parameter!
26 SUITE="$(grep "^Distribution:" "$CHANGES" | awk '{print $2}')"
29 error "Error: unable to determine suite from Changes file"
35 SUITE="${SUITE}-proposed-updates"
39 # This must end with /
40 TARGET="/srv/ftp.debian.org/ftp/dists/$SUITE/main/installer-$ARCH/"
42 # Check validity of the target directory
43 # This could fail, for example for new architectures; doing
44 # a regular BYHAND is safer in that case
45 if [ ! -d "$TARGET" ]; then
48 # Check that there isn't already a directory for this version
49 if [ -d "$TARGET/$VERSION" ]; then
50 error "Directory already exists: $TARGET/$VERSION"
53 # We know all data to be in ./installer-<arch>/<version>; see if there's
54 # anything else in the tarball except that and the 'current' symlink
55 if tar tzf "$TARBALL" | \
56 grep -Eqv "^\./(installer-$ARCH/($VERSION/.*|current|)|)$"; then
57 error "Tarball contains unexpected contents"
60 # Create a temporary directory where to store the images
62 TMPDIR="$(mktemp -td byhand-di.XXXXXX)"
64 # If we fail somewhere, cleanup the temporary directory
70 # Extract the data into the temporary directory
71 tar xzf "$TARBALL" --directory="$TMPDIR" "./installer-$ARCH/"
73 # Check the 'current' symlink
74 if [ ! -L $TMPDIR/installer-$ARCH/current ]; then
75 error "Missing 'current' symlink"
76 elif [ X"$(readlink "$TMPDIR/installer-$ARCH/current")" != X"$VERSION" ]; then
77 error "Incorrect 'current' symlink"
80 # We should have an MD5SUMS file; use that for a final check
81 if [ -r "$TMPDIR/installer-$ARCH/$VERSION/images/MD5SUMS" ]; then
83 cd "$TMPDIR/installer-$ARCH/$VERSION/images"
84 md5sum -c --status MD5SUMS || error "Error while checking MD5SUMS"
87 error "Missing MD5SUMS file"
90 # Move the data to the final location
91 mv "$TMPDIR/installer-$ARCH/$VERSION" "$TARGET"
92 mv "$TMPDIR/installer-$ARCH/current" "$TARGET"
95 find "$TARGET/$VERSION" -type d -exec chmod 755 {} +
96 find "$TARGET/$VERSION" -type f -exec chmod 644 {} +
98 # Make sure nothing symlinks outside of the ftpdir
99 # Shouldnt happen, but better be sure.
100 symlinks -d -r /srv/ftp.debian.org/ftp