I've written an untested deb build script

Discussion about the game and its default mods.
Post Reply
Posts: 92
Joined: Wed Sep 08, 2010 3:16 pm

I've written an untested deb build script

Post by Iran » Fri Sep 10, 2010 12:09 pm

Couldn't test it, so expect to see mistakes. I'm assuming that you execute this script in a directory that has an outdated ./DEBIAN folder and an up-to-date package file system (the script assumes this file system starts with /usr)

Code: Select all


if [ $# -ne "$ARGS" ]
    echo "Usage: `basename $0` ftp-server ftp-path username password version temp-packaging-dir"
    exit $E_BADARGS

PKGVERSION=`echo $5 | sed "s/-/\\./g"`

# Delete lines and insert updated ones for version
sed -i '2,2 d' ./DEBIAN/control
sed -i '11,11 i\Version: $PKGVERSION' ./DEBIAN/control
sed -i '1,1 d' ./DEBIAN/changelog
sed -i '1,1 i\openra ($PKGVERSION) unstable; urgency=low' ./DEBIAN/changelog

# Get the size needed for the Installed-Size line and change it
sed -i '5,5 d' ./DEBIAN/control
PACKAGE_SIZE= $( du --apparent-size -c ./usr | grep total | sed 's/[a-z]//g' | sed 's/\ //g')
sed -i '5,5 i\Installed-Size: $PACKAGE_SIZE' ./DEBIAN/control

# Copy our two needed folders to a clean package directory (yes, this is needed)
cp -R ./DEBIAN $t6
cp -R ./usr $6

# Build it in the package directory, but place the finished deb in our starting directory
BUILD_DIR=$( pwd )
pushd $6

# Calculate md5sums and clean up the /usr/ part of them
md5sum `find . -type f | grep -v '^[.]/DEBIAN/'` >DEBIAN/md5sums
sed -i 's/\.\/usr\//usr\//g' ./DEBIAN/md5sums

# Start building, the file should appear in directory the script was executed in
dpkg-deb -b . $BUILD_DIR/openra-$PKGVERSION.deb

# Get back to begin directory


# Get package file and dump it on ftp

size=`stat -c "%s" $PACKAGEFILE`

echo "$5,$size,$PACKAGEFILE" > /tmp/deblatest.txt

wput $PACKAGEFILE "ftp://$3:$4@$1/$2/"
cd /tmp
wput -u deblatest.txt "ftp://$3:$4@$1/$2/"

# remove temp-packaging-dir

rm -rf $6

Post Reply