major clean-up of debian building script

This commit is contained in:
Daniel Pavel 2013-07-07 14:06:03 +02:00
parent 8b26759731
commit 2ab040591c
3 changed files with 86 additions and 83 deletions

View File

@ -2,98 +2,95 @@
set -e set -e
export DEBFULLNAME="Daniel Pavel" if test "$DEBSIGN_KEYID"; then
export DEBMAIL=${DEBMAIL:-daniel.pavel+debian@gmail.com} test "$DEBEMAIL"
export DEBSIGN_KEYID=${DEBSIGN_KEYID:-0B34B1A7} test "$DEBFULLNAME"
else
export DEBFULLNAME="$(/usr/bin/getent passwd "$USER" | \
/usr/bin/cut --delimiter=: --fields=5 | /usr/bin/cut --delimiter=, --fields=1)"
export DEBEMAIL="${EMAIL:-$USER@$(/bin/hostname --long)}"
fi
export DEBMAIL="$DEBEMAIL"
DISTRIBUTION=${DISTRIBUTION:-debian} export DEBCHANGE_VENDOR=${DEBCHANGE_VENDOR:-$(/usr/bin/dpkg-vendor --query vendor | /usr/bin/tr 'A-Z' 'a-z')}
DIST_RELEASE=${DIST_RELEASE:-unstable} DISTRIBUTION=${DISTRIBUTION:-UNRELEASED}
cd "$(dirname "$0")/.." cd "$(dirname "$0")/.."
UDEV_RULES="$PWD/rules.d"
DEBIAN_FILES="$PWD/packaging/debian" DEBIAN_FILES="$PWD/packaging/debian"
DIST_TARGET="$PWD/dist/$DISTRIBUTION" DEBIAN_FILES_VENDOR="$PWD/packaging/$DEBCHANGE_VENDOR"
DIST_TARGET="$PWD/dist/$DEBCHANGE_VENDOR"
# #
# build a python sdist package # build a python sdist package, then unpack and create .orig and source dir
# #
export TMPDIR=${TMPDIR:-/tmp}/solaar-build-$USER VERSION="$(python2.7 setup.py --version)"
/bin/mkdir --parents --mode=0700 "$TMPDIR" FULLNAME="$(python2.7 setup.py --fullname)"
BUILD_DIR="$TMPDIR/build-$DISTRIBUTION"
/bin/rm --recursive --force "$BUILD_DIR" export TMPDIR="${TMPDIR:-/tmp}/debbuild-$FULLNAME-$USER"
BUILD_DIR="$TMPDIR/$DEBCHANGE_VENDOR-$DISTRIBUTION"
/bin/rm --force --recursive "$BUILD_DIR"
/bin/mkdir --parents --mode=0700 "$BUILD_DIR" /bin/mkdir --parents --mode=0700 "$BUILD_DIR"
python "setup.py" sdist --dist-dir="$BUILD_DIR" --formats=gztar python2.7 setup.py sdist --dist-dir="$BUILD_DIR" --formats=gztar --quiet
cd "$BUILD_DIR" ORIG_FILE="$BUILD_DIR/solaar_$VERSION.orig.tar.gz"
/bin/mv "$BUILD_DIR/$FULLNAME.tar.gz" "$ORIG_FILE"
/bin/tar --extract --gunzip --file "$ORIG_FILE" --directory "$BUILD_DIR"
# guess the version of the built sdist cd "$BUILD_DIR/$FULLNAME"
S=$(ls -1t solaar-*.tar.gz | tail -n 1) unset BUILD_DIR VERSION FULLNAME ORIG_FILE
test -r "$S"
VERSION=${S#solaar-}
VERSION=${VERSION%.tar.gz}
# check the last version built
LAST=$(head -n 1 "$DEBIAN_FILES/changelog" | grep -o ' ([0-9.-]*) ')
LAST=${LAST# (}
LAST=${LAST%) }
LAST_VERSION=$(echo "$LAST" | cut -d- -f 1)
LAST_BUILD=$(echo "$LAST" | cut -d- -f 2)
if test "$BUILD_EXTRA"; then
# when building for a distro other than Debian, keep the same build number,
# just append the BUILD_EXTRA to it
BUILD_NUMBER=$LAST_BUILD
elif dpkg --compare-versions "$VERSION" gt "$LAST_VERSION"; then
# the version increased, this is the first build for this version
BUILD_NUMBER=1
else
# increase the build number
BUILD_NUMBER=$(($LAST_BUILD + 1))
fi
tar xfz "$S"
mv "$S" solaar_$VERSION.orig.tar.gz
# #
# preparing to build the package # preparing to build the package
# #
cd solaar-$VERSION /bin/cp --archive --target-directory=. "$DEBIAN_FILES"
cp -a "$DEBIAN_FILES" .
# udev rules, if not already set if test "$DEBSIGN_KEYID"; then
test -s debian/solaar.udev || cp -a "$UDEV_RULES"/??-*.rules debian/solaar.udev BUILDER_MAIL="$(echo "$DEBEMAIL" | /bin/sed --expression='s/+[a-z]*@/@/')"
MAINT_MAIL="$(/bin/grep '^Maintainer: ' debian/control | /usr/bin/cut --delimiter=' ' --fields=2)"
echo "maintainer $MAINT_MAIL, builder $BUILDER_MAIL"
# test "$MAINT_MAIL" = "$BUILDER_MAIL" &&
# /bin/sed --in-place --expression="s/^Maintainer: .*$/Maintainer: $DEBFULLNAME <$DEBEMAIL>/" debian/control
else
/bin/sed --in-place --file=- debian/control <<-CONTROL
/^Maintainer:/ a\
Changed-By: $DEBFULLNAME <$DEBEMAIL>
CONTROL
fi
# generate the changelog with the right version number and release /usr/bin/debchange \
cat >debian/changelog <<_CHANGELOG --vendor "$DEBCHANGE_VENDOR" \
solaar ($VERSION-$BUILD_NUMBER$BUILD_EXTRA) $DIST_RELEASE; urgency=low --distribution "$DISTRIBUTION" \
--force-save-on-release \
--auto-nmu \
$@
* Debian packaging scripts, supports ubuntu ppa as well. if test "$DEBCHANGE_VENDOR" = debian; then
# if this is the main (Debian) build, update the source changelog
/bin/cp --archive --no-target-directory debian/changelog "$DEBIAN_FILES"/changelog
else
# else copy any additional files
/bin/cp --archive --target-directory=debian/ "$DEBIAN_FILES_VENDOR"/* || true
fi
-- $DEBFULLNAME <$DEBMAIL> $(date -R) if test "$DEBSIGN_KEYID"; then
# only build a source package, and sign it
_CHANGELOG DPKG_BUILPACKAGE_OPTS="-sa -S -k$DEBSIGN_KEYID"
else
# if this is the main (Debian) build, update the changelog # build an unsigned binary package
test "$BUILD_EXTRA" || cp -a debian/changelog "$DEBIAN_FILES"/changelog DPKG_BUILPACKAGE_OPTS="-b -us -uc"
fi
# other distros may have extra files to place in debian/ /usr/bin/debuild \
test "$DEBIAN_FILES_EXTRA" && cp -a $DEBIAN_FILES_EXTRA/* debian/ --lintian --tgz-check \
--preserve-envvar=DISPLAY \
# set the right maintainer email address $DPKG_BUILPACKAGE_OPTS \
sed -i -e "s/^Maintainer: .*$/Maintainer: $DEBFULLNAME <$DEBMAIL>/" debian/control --lintian-opts --profile "$DEBCHANGE_VENDOR"
export DEBUILD_LINTIAN_OPTS="--profile $DISTRIBUTION"
export DEBUILD_DPKG_BUILDPACKAGE_OPTS="-sa"
export DEBUILD_PRESERVE_ENVVARS='GPG_AGENT_INFO,DISPLAY'
/usr/bin/debuild $@
# #
# place the resulting files in dist/$DISTRIBUTION/ # place the resulting files in $DIST_TARGET
# #
/bin/rm --force "$DIST_TARGET"/*
/bin/mkdir --parents "$DIST_TARGET" /bin/mkdir --parents "$DIST_TARGET"
cp -a -t "$DIST_TARGET" ../solaar_$VERSION* /bin/cp --archive --backup=numbered --target-directory="$DIST_TARGET" ../solaar_$VERSION*
cp -a -t "$DIST_TARGET" ../solaar-*_$VERSION* || true /bin/cp --archive --backup=numbered --target-directory="$DIST_TARGET" ../solaar-*_$VERSION* || true

View File

@ -2,16 +2,15 @@
set -e set -e
export DEBSIGN_KEYID=07D8904B export DEBCHANGE_VENDOR=ubuntu
export DEBMAIL="daniel.pavel+launchpad@gmail.com" export DISTRIBUTION=precise
export DISTRIBUTION=ubuntu export DEBFULLNAME='Daniel Pavel'
export DIST_RELEASE=precise export DEBEMAIL='daniel.pavel+launchpad@gmail.com'
export DEBIAN_FILES_EXTRA="$PWD/packaging/ubuntu" export DEBSIGN_KEYID=07D8904B
export BUILD_EXTRA=ppa1
Z="$(readlink -f "$(dirname "$0")")" Z="$(readlink -f "$(dirname "$0")")"
"$Z"/build_deb.sh -S "$Z"/build_deb.sh --rebuild "$@"
cd "$Z/../dist/ubuntu/" /usr/bin/dput --config="$Z/dput.cf" solaar-snapshots-ppa \
/usr/bin/dput --config="$Z/dput.cf" solaar-snapshots-ppa solaar_*_source.changes "$Z/../dist/ubuntu"/solaar_*_source.changes

View File

@ -2,8 +2,15 @@
set -e set -e
Z="$(readlink -f "$(dirname "$0")")" export DEBCHANGE_VENDOR=debian
"$Z"/build_deb.sh -S export DISTRIBUTION=unstable
cd "$Z/../dist/debian/" export DEBFULLNAME='Daniel Pavel'
/usr/bin/dput --config="$Z/dput.cf" mentors solaar_*_source.changes export DEBEMAIL='daniel.pavel+debian@gmail.com'
export DEBSIGN_KEYID=0B34B1A7
Z="$(readlink -f "$(dirname "$0")")"
"$Z"/build_deb.sh --release "$@"
/usr/bin/dput --config="$Z/dput.cf" mentors \
"$Z/../dist/debian"/solaar_*_source.changes