7 echo "Usage: $0 filename version arch changes_file"
11 TARBALL="$1" # Tarball to read, compressed with gzip
14 CHANGES="$4" # Changes file for the upload
21 # Check validity of version number
22 # Expected are: YYYYMMDD, YYYYMMDD.x, YYYYMMDD<suite>x and the +b[0-9] on the end
23 if ! echo "$VERSION" | grep -Eq "^[0-9]{8}(|(\.|[a-z]+)[0-9]+)(\+b[0-9])?$"; then
24 error "Invalid version: '$VERSION'"
27 # Get the target suite from the Changes file
28 # NOTE: it may be better to pass this to the script as a parameter!
29 SUITE="$(grep "^Distribution:" "$CHANGES" | awk '{print $2}')"
32 error "Error: unable to determine suite from Changes file"
38 SUITE="${SUITE}-proposed-updates"
42 # This must end with /
43 TARGET="/srv/ftp-master.debian.org/ftp/dists/$SUITE/main/installer-$ARCH/"
45 # Check validity of the target directory
46 # This could fail, for example for new architectures; doing
47 # a regular BYHAND is safer in that case
48 if [ ! -d "$TARGET" ]; then
51 # Check that there isn't already a directory for this version
52 if [ -d "$TARGET/$VERSION" ]; then
53 error "Directory already exists: $TARGET/$VERSION"
56 # We know the VERSION is sane by here, we just need to make sure we escape the + in +b1 (if any)
57 VERSIONREGEXP="$(echo $VERSION | sed 's@+@\\\+@')"
59 # We know all data to be in ./installer-<arch>/<version>; see if there's
60 # anything else in the tarball except that and the 'current' symlink
61 if tar tzf "$TARBALL" | \
62 grep -Eqv "^\./(installer-$ARCH/($VERSIONREGEXP/.*|current|)|)$"; then
63 error "Tarball contains unexpected contents"
66 # Create a temporary directory where to store the images
68 TMPDIR="$(mktemp -td byhand-di.XXXXXX)"
70 # If we fail somewhere, cleanup the temporary directory
76 # Extract the data into the temporary directory
77 tar xzf "$TARBALL" --directory="$TMPDIR" "./installer-$ARCH/"
79 # Check the 'current' symlink
80 if [ ! -L $TMPDIR/installer-$ARCH/current ]; then
81 error "Missing 'current' symlink"
82 elif [ X"$(readlink "$TMPDIR/installer-$ARCH/current")" != X"$VERSION" ]; then
83 error "Incorrect 'current' symlink"
86 # We should have an MD5SUMS file; use that for a final check
87 if [ -r "$TMPDIR/installer-$ARCH/$VERSION/images/MD5SUMS" ]; then
89 cd "$TMPDIR/installer-$ARCH/$VERSION/images"
90 md5sum -c --status MD5SUMS || error "Error while checking MD5SUMS"
93 error "Missing MD5SUMS file"
96 # Move the data to the final location
97 mv "$TMPDIR/installer-$ARCH/$VERSION" "$TARGET"
98 mv "$TMPDIR/installer-$ARCH/current" "$TARGET"
101 find "$TARGET/$VERSION" -type d -exec chmod 755 {} +
102 find "$TARGET/$VERSION" -type f -exec chmod 644 {} +
104 # Make sure nothing symlinks outside of the ftpdir
105 # Shouldnt happen, but better be sure.
106 symlinks -d -r /srv/ftp-master.debian.org/ftp