diff options
author | wsnipex <wsnipex@a1.net> | 2013-05-12 12:33:49 +0200 |
---|---|---|
committer | wsnipex <wsnipex@a1.net> | 2013-06-07 12:42:57 +0200 |
commit | 93ef8123895b49f04503534584ae75ee8321daf0 (patch) | |
tree | dd2f99db8676ba7f0b431a9d2b21708ffae93b56 /tools/Linux/packaging | |
parent | ccdb5142476c2a5537090d2fd6700d86789670fd (diff) |
[tools] add debian packaging script
Diffstat (limited to 'tools/Linux/packaging')
-rw-r--r-- | tools/Linux/packaging/README.debian | 31 | ||||
-rwxr-xr-x | tools/Linux/packaging/mk-debian-package.sh | 170 |
2 files changed, 201 insertions, 0 deletions
diff --git a/tools/Linux/packaging/README.debian b/tools/Linux/packaging/README.debian new file mode 100644 index 0000000000..6313c5833d --- /dev/null +++ b/tools/Linux/packaging/README.debian @@ -0,0 +1,31 @@ +--- How to build a XBMC debian package --- + +There are two available build methods: +1.) debuild / debhelper + Requirements: debhelper, devscripts, all Xbmc build deps + sudo apt-get install debhelper devscripts + sudo apt-get build-dep xbmc (if you have on of our repos/ppas added, else read docs/README.linux or docs/README.ubuntu) + + Result: debian package for your host distribution and architecture only + Recommended for local installs + + Example Usage: ./mk-debian-package.sh + +2.) pdebuild / pbuilder + Requirements: pbuilder, devscripts, proper pbuilder environment + For a comprehensive example how to setup pbuilder read: + https://wiki.ubuntu.com/PbuilderHowto + + Result: debian package for arbitrary debian based distributions and architectures + Recommended for hosting your own apt repository or (clean room) compile testing for various distributions + + Example Usage: + RELEASEV=13 \ + DISTS=-"unstable" \ + ARCHS="i386 amd64" \ + BUILDER="pdebuild" \ + PDEBUILD_OPTS="--debbuildopts \"-j4\"" \ + PBUILDER_BASE="/home/$USER/xbmc-packaging/pbuilder" \ + DPUT_TARGET="local" \ + ./mk-debian-package.sh + diff --git a/tools/Linux/packaging/mk-debian-package.sh b/tools/Linux/packaging/mk-debian-package.sh new file mode 100755 index 0000000000..711c0a94b1 --- /dev/null +++ b/tools/Linux/packaging/mk-debian-package.sh @@ -0,0 +1,170 @@ +#!/bin/bash +# +# Copyright (C) 2013 Team XBMC +# http://www.xbmc.org +# +# This Program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This Program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with XBMC; see the file COPYING. If not, see +# <http://www.gnu.org/licenses/>. +# + + +RELEASEV=${RELEASEV:-"auto"} +TAG=${TAG} +REPO_DIR=${WORKSPACE:-$(cd "$(dirname $0)/../../../" ; pwd)} +[[ $(which lsb_release) ]] && DISTS=${DISTS:-$(lsb_release -cs)} || DISTS=${DISTS:-"stable"} +ARCHS=${ARCHS:-$(dpkg --print-architecture)} +BUILDER=${BUILDER:-"debuild"} +DEBUILD_OPTS=${DEBUILD_OPTS:-""} +PDEBUILD_OPTS=${PDEBUILD_OPTS:-""} +PBUILDER_BASE=${PBUILDER_BASE:-"/var/cache/pbuilder"} +DPUT_TARGET=${DPUT_TARGET:-"local"} +DEBIAN=${DEBIAN:-"https://github.com/xbmc/xbmc-packaging/archive/master.tar.gz"} + +function usage { + echo "$0: this script builds a Xbmc debian package from a git repository." + echo "The build is controlled by ENV variables, which van be overridden as appropriate:" + echo "BUILDER is either debuild(default) or pdebuild(needs a proper pbuilder setup)" + checkEnv +} + +function checkEnv { + echo "#------ build environment ------#" + echo "REPO_DIR: $REPO_DIR" + [[ $RELEASEV == "auto" ]] && getVersion + echo "RELEASEV: $RELEASEV" + [[ -n $TAG ]] && echo "TAG: $TAG" + echo "DISTS: $DISTS" + echo "ARCHS: $ARCHS" + echo "DEBIAN: $DEBIAN" + echo "BUILDER: $BUILDER" + echo "CONFIGURATION: $Configuration" + + if ! [[ $(which $BUILDER) ]] + then + echo "Error: can't find ${BUILDER}, consider using full path to [debuild|pdebuild]" + exit 1 + fi + + if [[ "$BUILDER" =~ "pdebuild" ]] + then + if ! [[ -d $PBUILDER_BASE ]] ; then echo "Error: $PBUILDER_BASE does not exist"; exit 1; fi + echo "PBUILDER_BASE: $PBUILDER_BASE" + echo "PDEBUILD_OPTS: $PDEBUILD_OPTS" + else + echo "DEBUILD_OPTS: $DEBUILD_OPTS" + fi + + echo "#-------------------------------#" +} + +function getVersion { + local MAJORVER=$(grep VERSION_MAJOR $REPO_DIR/xbmc/GUIInfoManager.h | awk '{ print $3 }') + local MINORVER=$(grep VERSION_MINOR $REPO_DIR/xbmc/GUIInfoManager.h | awk '{ print $3 }') + RELEASEV=${MAJORVER}.${MINORVER} +} + +function getGitRev { + cd $REPO_DIR || exit 1 + REV=$(git log -1 --pretty=format:"%h") + [[ -z $TAG ]] && TAG=$REV + [[ -z $TAGREV ]] && TAGREV=0 +} + +function archiveRepo { + cd $REPO_DIR || exit 1 + git clean -xfd + getGitRev + echo $REV > VERSION + DEST="xbmc-${RELEASEV}~git$(date '+%Y%m%d.%H%M')-${TAG}" + [[ -d debian ]] && rm -rf debian + cd .. + tar -czf ${DEST}.tar.gz -h --exclude .git $(basename $REPO_DIR) + ln -s ${DEST}.tar.gz ${DEST/-/_}.orig.tar.gz + echo "Output Archive: ${DEST}.tar.gz" + + cd $REPO_DIR || exit 1 + getDebian +} + +function getDebian { + if [[ -d $DEBIAN ]] + then + cp -r $DEBIAN . + else + mkdir tmp && cd tmp + curl -L -s $DEBIAN -o debian.tar.gz + tar xzf debian.tar.gz + cd xbmc-packaging-* + for FILE in *.unified; do mv $FILE debian/${FILE%.unified}; done + mv debian $REPO_DIR + cd $REPO_DIR ; rm -rf tmp + fi +} + +function buildDebianPackages { + archiveRepo + cd $REPO_DIR || exit 1 + sed -e "s/#PACKAGEVERSION#/${DEST#xbmc-}/g" -e "s/#TAGREV#/${TAGREV}/g" debian/changelog.in > debian/changelog.tmp + [ "$Configuration" == "Debug" ] && sed -i "s/XBMC_RELEASE = yes/XBMC_RELEASE = no/" debian/rules + + for dist in $DISTS + do + sed "s/#DIST#/${dist}/g" debian/changelog.tmp > debian/changelog + for arch in $ARCHS + do + cd $REPO_DIR + echo "building: DIST=$dist ARCH=$arch" + if [[ "$BUILDER" =~ "pdebuild" ]] + then + DIST=$dist ARCH=$arch $BUILDER $PDEBUILD_OPTS + [ $? -eq 0 ] && uploadPkg || exit 1 + else + $BUILDER $DEBUILD_OPTS + echo "output directory: $REPO_DIR/.." + fi + done + done +} + +function uploadPkg { + PKG="${PBUILDER_BASE}/${dist}-${arch}/result/${DEST/-/_}-${TAGREV}_${arch}.changes" + echo "signing package" + debsign $PKG + echo "uploading $PKG to $DPUT_TARGET" + dput $DPUT_TARGET $PKG + UPLOAD_DONE=$? +} + +function cleanup { + if [[ $UPLOAD_DONE -eq 0 ]] && [[ "$BUILDER" =~ "pdebuild" ]] + then + cd $REPO_DIR/.. || exit 1 + rm ${DEST}* + rm ${DEST/-/_}* + fi +} + +### +# main +### +if [[ $1 = "-h" ]] || [[ $1 = "--help" ]] +then + usage + exit +fi + +checkEnv +buildDebianPackages +cleanup + |