From 9c261143b126cd88ceb34afeab25bd7ab86f3305 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Thu, 8 Aug 2013 18:24:29 +0200 Subject: [PATCH] Initial import from admin sys repository --- Makefile | 30 ++++++++++++ README.rst | 36 +++++++++++++++ TODO | 2 + dput.cf | 9 ++++ eobuilder | 122 +++++++++++++++++++++++++++++++++++++++++++++++++ eobuilder.orig | 120 ++++++++++++++++++++++++++++++++++++++++++++++++ gitconfig | 7 +++ pbuilderrc | 91 ++++++++++++++++++++++++++++++++++++ 8 files changed, 417 insertions(+) create mode 100644 Makefile create mode 100644 README.rst create mode 100644 TODO create mode 100644 dput.cf create mode 100755 eobuilder create mode 100755 eobuilder.orig create mode 100644 gitconfig create mode 100644 pbuilderrc diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9fa6b39 --- /dev/null +++ b/Makefile @@ -0,0 +1,30 @@ + + +all: install + +install: + apt-get install pbuilder devscripts debhelper cowbuilder git dput fakeroot sudo + if ! getent passwd eobuilder > /dev/null 2>&1; then useradd eobuilder --home-dir /var/lib/eobuilder --create-home; fi + su eobuilder -p -c "cp pbuilderrc /var/lib/eobuilder/.pbuilderrc" + su eobuilder -p -c "cp dput.cf /var/lib/eobuilder/.dput.cf" + su eobuilder -p -c "cp gitconfig /var/lib/eobuilder/.gitconfig" + cp eobuilder /usr/local/bin + +chroots: + if [ ! -d /var/cache/pbuilder/squeeze-i386 ]; then \ + mkdir /var/cache/pbuilder/squeeze-i386; \ + cowbuilder --create --basepath /var/cache/pbuilder/squeeze-i386/base.cow --distribution squeeze --debootstrapopts --arch --debootstrapopts i386; \ + fi + if [ ! -d /var/cache/pbuilder/squeeze-amd64 ]; then \ + mkdir /var/cache/pbuilder/squeeze-amd64; \ + cowbuilder --create --basepath /var/cache/pbuilder/squeeze-amd64/base.cow --distribution squeeze --debootstrapopts --arch --debootstrapopts amd64; \ + fi + if [ ! -d /var/cache/pbuilder/wheezy-i386 ]; then \ + mkdir /var/cache/pbuilder/wheezy-i386; \ + cowbuilder --create --basepath /var/cache/pbuilder/wheezy-i386/base.cow --distribution wheezy --debootstrapopts --arch --debootstrapopts i386; \ + fi + if [ ! -d /var/cache/pbuilder/wheezy-amd64 ]; then \ + mkdir /var/cache/pbuilder/wheezy-amd64; \ + cowbuilder --create --basepath /var/cache/pbuilder/wheezy-amd64/base.cow --distribution wheezy --debootstrapopts --arch --debootstrapopts amd64; \ + fi + diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..65f1afb --- /dev/null +++ b/README.rst @@ -0,0 +1,36 @@ +======= +README +======= + +Requirments +------------ + +Use must use a Debian OS. You need to install make. + +Installation +------------ + +Install eobuilder:: + + sudo make install + +Install chroots (if you want i386 - amd64 wheezy and squeeze):: + + sudo make chroots + +Configuration +------------- + +Generate a ssh key for eobuilder or use an existing one. +Configure your Debian repository to allow this key. + +You need to add thes line into your sudoers:: + + eobuilder ALL= SETENV:NOPASSWD:/usr/sbin/cowbuilder + +Quick start +------------ + +Example with python-entrouvert:: + + sudo -u eobuilder eobuilder python-entrouvert squeeze diff --git a/TODO b/TODO new file mode 100644 index 0000000..f56fec3 --- /dev/null +++ b/TODO @@ -0,0 +1,2 @@ + - Migrate to getopts + - Create a Jenkins version diff --git a/dput.cf b/dput.cf new file mode 100644 index 0000000..5114866 --- /dev/null +++ b/dput.cf @@ -0,0 +1,9 @@ +[squeeze-experimental] +method = scp +fqdn = deb.entrouvert.org +incoming = /var/vhosts/deb.entrouvert.org/incoming/squeeze-experimental + +[wheezy-experimental] +method = scp +fqdn = deb.entrouvert.org +incoming = /var/vhosts/deb.entrouvert.org/incoming/wheezy-experimental diff --git a/eobuilder b/eobuilder new file mode 100755 index 0000000..dc5ec78 --- /dev/null +++ b/eobuilder @@ -0,0 +1,122 @@ +#!/bin/sh + +USAGE="""Usage: $0 GIT_REPOSITORY_NAME DISTRIBUTION [ARCHITECTURE]\n +\n +GIT_REPOSITORY_NAME: respository name without .git\n +DISTRIBUTION: Debian distroibution like : squeeze, wheezy, ...\n +ARCHITECTURE: amd64 or i368 (Default: amd64)""" + +GIT_REPOSITORY_URL="git+ssh://git@repos.entrouvert.org" +GIT_PATH="/var/lib/eobuilder/git" +PBUILDER_RESULT="/var/lib/eobuilder/results" + + +error() +{ + echo $1 >& 2 + exit 1 +} + +if [ $# -lt 2 ]; then + error "$USAGE" +fi + +if [ "$(whoami)" != "eobuilder" ]; then + error "You must run be eobuilder to launch this script" +fi + +set -e + +GIT_NAME=$1 +DIST=$2 +if [ "$3" ]; then + ARCH=$3 +else + ARCH="amd64" +fi + +if [ ! -d $GIT_PATH ]; then + mkdir $GIT_PATH +fi + +PBUILDER_PROJECT_RESULT="${PBUILDER_RESULT}/${DIST}-${ARCH}/" +PROJECT_NAME=$GIT_NAME +BUILD_DIR="/var/tmp/$PROJECT_NAME" +GIT_PROJECT_PATH="$GIT_PATH/$GIT_NAME" + +echo "+ Cloning git repository" +if [ ! -d $GIT_PROJECT_PATH ]; then + echo "+ git clone $GIT_REPOSITORY_URL/$GIT_NAME.git" + cd $GIT_PATH + git clone $GIT_REPOSITORY_URL/$GIT_NAME.git +fi + +echo "+ Updating git repository and parsing configuration ..." +cd $GIT_PROJECT_PATH +git checkout master +git pull +VERSION=`git describe | tr - . | sed 's/^v//'` +COMMIT_NUMBER=`git log -n1 | grep 'commit' | sed 's/commit\s*//'` + +git checkout debian +git pull +PACKAGE_NAME=`cat debian/control | sed 's/^Source\s*:\s*//; t; d'` +LAST_DEBIAN_PACKAGE_VERSION=`dpkg-parsechangelog | sed 's/^Version: //; t; d'` +LAST_DEBIAN_INC=`echo $LAST_DEBIAN_PACKAGE_VERSION | cut -d '-' -f2` +LAST_VERSION=`echo $LAST_DEBIAN_PACKAGE_VERSION | cut -d '-' -f1` + +# Find and increment Debian version number +if [ "$LAST_VERSION" = "$VERSION" ]; then + INC_VERSION=$(($LAST_DEBIAN_INC + 1)) +else + INC_VERSION=1 +fi + +PACKAGE_VERSION="$VERSION-$INC_VERSION" + +echo "+ Generating sdist ..." +git checkout master +python setup.py sdist --formats=bztar + +echo "+ Prepararing debian build ($PACKAGE_NAME $PACKAGE_VERSION) ..." +git checkout debian +mkdir -p $BUILD_DIR +echo $GIT_PROJECT_PATH/dist/$PROJECT_NAME-$VERSION.tar.bz2 +mv $GIT_PROJECT_PATH/dist/$PROJECT_NAME-$VERSION.tar.bz2 /var/tmp/$PROJECT_NAME/${PACKAGE_NAME}_${VERSION}.orig.tar.bz2 +cd $BUILD_DIR +tar xfvj ${PACKAGE_NAME}_${VERSION}.orig.tar.bz2 +cp -r $GIT_PROJECT_PATH/debian $BUILD_DIR/$PROJECT_NAME-$VERSION +cd $PROJECT_NAME-$VERSION + +echo """${PACKAGE_NAME} (${PACKAGE_VERSION}) ${DIST}; urgency=low + + * Automatic version : commit ${COMMIT_NUMBER} + + -- Jérôme Schneider `date -R` +"" " > debian/new_changelog + +cat debian/changelog >> debian/new_changelog +mv debian/new_changelog debian/changelog + + +echo "+ Building package ..." +if [ ! -d $PBUILDER_PROJECT_RESULT ]; then + mkdir -p $PBUILDER_PROJECT_RESULT +fi + +DIST=$DIST ARCH=$ARCH pdebuild + +echo "+ Commit changelog" +cd $GIT_PROJECT_PATH +git checkout debian +git commit debian/changelog -m 'Automatic: new debian package' + +echo "+ Sending package ..." +cd $PBUILDER_PROJECT_RESULT +dput -u $DIST-experimental ${PACKAGE_NAME}_${PACKAGE_VERSION}_${ARCH}.changes + +echo "+ Cleanning ..." +if [ "$PROJECT_NAME" ]; then + rm -rf $BUILD_DIR +fi + diff --git a/eobuilder.orig b/eobuilder.orig new file mode 100755 index 0000000..718ea0d --- /dev/null +++ b/eobuilder.orig @@ -0,0 +1,120 @@ +#!/bin/sh + +USAGE="""Usage: $0 GIT_REPOSITORY_NAME DISTRIBUTION [ARCHITECTURE]\n +\n +GIT_REPOSITORY_NAME: respository name without .git\n +DISTRIBUTION: Debian distroibution like : squeeze, wheezy, ...\n +ARCHITECTURE: amd64 or i368 (Default: amd64)""" + +GIT_REPOSITORY_URL="git+ssh://git@repos.entrouvert.org" +GIT_PATH="/var/lib/eobuilder/git" +PBUILDER_RESULT="/var/lib/eobuilder/results" + + +error() +{ + echo $1 >& 2 + exit 1 +} + +if [ $# -lt 2 ]; then + error "$USAGE" +fi + +if [ "$(whoami)" != "eobuilder" ]; then + error "You must run be eobuilder to launch this script" +fi + +set -e + +GIT_NAME=$1 +DIST=$2 +if [ "$3" ]; then + ARCH=$3 +else + ARCH="amd64" +fi + +if [ ! -d $GIT_PATH ]; then + mkdir $GIT_PATH +fi + +PBUILDER_PROJECT_RESULT="${PBUILDER_RESULT}/${DIST}-${ARCH}/" +PROJECT_NAME=$GIT_NAME +BUILD_DIR="/var/tmp/$PROJECT_NAME" +GIT_PROJECT_PATH="$GIT_PATH/$GIT_NAME" + +echo "+ Cloning git repository" +if [ ! -d $GIT_PROJECT_PATH ]; then + echo "+ git clone $GIT_REPOSITORY_URL/$GIT_NAME.git" + cd $GIT_PATH + git clone $GIT_REPOSITORY_URL/$GIT_NAME.git +fi + +echo "+ Updating git repository and parsing configuration ..." +cd $GIT_PROJECT_PATH +git checkout master +git pull +VERSION=`git describe | tr - . | sed 's/^v//'` +COMMIT_NUMBER=`git log -n1 | grep 'commit' | sed 's/commit\s*//'` + +git checkout debian +PACKAGE_NAME=`cat debian/control | sed 's/^Source\s*:\s*//; t; d'` +LAST_DEBIAN_PACKAGE_VERSION=`dpkg-parsechangelog | sed 's/^Version: //; t; d'` +LAST_DEBIAN_INC=`echo $LAST_DEBIAN_PACKAGE_VERSION | cut -d '-' -f2` +LAST_VERSION=`echo $LAST_DEBIAN_PACKAGE_VERSION | cut -d '-' -f1` + +# Find and increment Debian version number +if [ "$LAST_VERSION" = "$VERSION" ]; then + INC_VERSION=$(($LAST_DEBIAN_INC + 1)) +else + INC_VERSION=1 +fi + +PACKAGE_VERSION="$VERSION-$INC_VERSION" + +echo "+ Generating sdist ..." +git checkout master +python setup.py sdist --formats=bztar + +echo "+ Prepararing debian build ($PACKAGE_NAME $PACKAGE_VERSION) ..." +git checkout debian +mkdir -p $BUILD_DIR +echo $GIT_PROJECT_PATH/dist/$PROJECT_NAME-$VERSION.tar.bz2 +mv $GIT_PROJECT_PATH/dist/$PROJECT_NAME-$VERSION.tar.bz2 /var/tmp/$PROJECT_NAME/${PACKAGE_NAME}_${VERSION}.orig.tar.bz2 +cd $BUILD_DIR +tar xfvj ${PACKAGE_NAME}_${VERSION}.orig.tar.bz2 +cp -r $GIT_PROJECT_PATH/debian $BUILD_DIR/$PROJECT_NAME-$VERSION +cd $PROJECT_NAME-$VERSION + +echo """${PACKAGE_NAME} (${PACKAGE_VERSION}) ${DIST}; urgency=low + + * Automatic version : commit ${COMMIT_NUMBER} + + -- Jérôme Schneider `date -R` +"" " > debian/new_changelog + +cat debian/changelog >> debian/new_changelog +mv debian/new_changelog debian/changelog + + +echo "+ Building package ..." +if [ ! -d $PBUILDER_PROJECT_RESULT ]; then + mkdir -p $PBUILDER_PROJECT_RESULT +fi +pdebuild + +echo "+ Commit changelog" +cd $GIT_PROJECT_PATH +git checkout debian +git commit debian/changelog -m 'Automatic: new debian package' + +echo "+ Sending package ..." +cd $PBUILDER_PROJECT_RESULT +dput -u $DIST-experimental ${PACKAGE_NAME}_${PACKAGE_VERSION}_${ARCH}.changes + +echo "+ Cleanning ..." +if [ "$PROJECT_NAME" ]; then + rm -rf $BUILD_DIR +fi + diff --git a/gitconfig b/gitconfig new file mode 100644 index 0000000..f657742 --- /dev/null +++ b/gitconfig @@ -0,0 +1,7 @@ +[core] + excludesfile = "/var/lib/eobuilder/.gitignore" + +[user] + name = EO builder bot + email = admin@entrouvert.com + diff --git a/pbuilderrc b/pbuilderrc new file mode 100644 index 0000000..a55c34f --- /dev/null +++ b/pbuilderrc @@ -0,0 +1,91 @@ +# Codenames for Debian suites according to their alias. Update these when +# needed. +UNSTABLE_CODENAME="sid" +TESTING_CODENAME="jessie" +STABLE_CODENAME="wheezy" +OLDSTABLE_CODENAME="squeeze" +STABLE_BACKPORTS_SUITE="$STABLE_CODENAME-backports" + +# Use cowbuilder +PDEBUILD_PBUILDER="cowbuilder" + +# List of Debian suites. +DEBIAN_SUITES=($UNSTABLE_CODENAME $TESTING_CODENAME $STABLE_CODENAME $OLDSTABLE_CODENAME + "unstable" "testing" "stable" "oldstable") + +# List of Ubuntu suites. Update these when needed. +UBUNTU_SUITES=("natty" "maverick" "lucid" "karmic" "jaunty" "hardy") + +# Mirrors to use. Update these to your preferred mirror. +MIRRORSITE=http://ftp.fr.debian.org/debian +DEBIAN_MIRROR="ftp.fr.debian.org" +UBUNTU_MIRROR="ftp.ubuntu.com" + +# Optionally use the changelog of a package to determine the suite to use if +# none set. +if [ -z "${DIST}" ] && [ -r "debian/changelog" ]; then + DIST=$(dpkg-parsechangelog | awk '/^Distribution: / {print $2}') + # Use the unstable suite for certain suite values. + if $(echo "experimental UNRELEASED" | grep -q $DIST); then + DIST="$UNSTABLE_CODENAME" + fi +fi + +# Optionally set a default distribution if none is used. Note that you can set +# your own default (i.e. ${DIST:="unstable"}). +: ${DIST:="$(lsb_release --short --codename)"} + +# Optionally change Debian release states in $DIST to their names. +case "$DIST" in + unstable) + DIST="$UNSTABLE_CODENAME" + ;; + testing) + DIST="$TESTING_CODENAME" + ;; + stable) + DIST="$STABLE_CODENAME" + ;; + oldstable) + DIST="$OLDSTABLE_CODENAME" + ;; +esac + +# Optionally set the architecture to the host architecture if none set. Note +# that you can set your own default (i.e. ${ARCH:="i386"}). +: ${ARCH:="$(dpkg --print-architecture)"} + +NAME="$DIST" +if [ -n "${ARCH}" ]; then + NAME="$NAME-$ARCH" + DEBOOTSTRAPOPTS=("--arch" "$ARCH" "${DEBOOTSTRAPOPTS[@]}") +fi +#BASETGZ="/var/cache/pbuilder/$NAME-base.tgz" +# Optionally, set BASEPATH (and not BASETGZ) if using cowbuilder +BASEPATH="/var/cache/pbuilder/$NAME/base.cow/" +DISTRIBUTION="$DIST" +BUILDRESULT="/var/lib/eobuilder/results/$NAME/" +APTCACHE="/var/cache/pbuilder/$NAME/aptcache/" +BUILDPLACE="/var/cache/pbuilder/build" + + +BUILDUSERNAME="eobuilder" + +OTHERMIRROR="deb http://$DEBIAN_MIRROR/debian $DIST-backports main | deb http://deb.entrouvert.org/ $DIST-experimental main" + +if $(echo ${DEBIAN_SUITES[@]} | grep -q $DIST); then + # Debian configuration + MIRRORSITE="http://$DEBIAN_MIRROR/debian/" + COMPONENTS="main contrib non-free" + DEBOOTSTRAPOPTS=("${DEBOOTSTRAPOPTS[@]}" "--keyring=/usr/share/keyrings/debian-archive-keyring.gpg") + +elif $(echo ${UBUNTU_SUITES[@]} | grep -q $DIST); then + # Ubuntu configuration + MIRRORSITE="http://$UBUNTU_MIRROR/ubuntu/" + COMPONENTS="main restricted universe multiverse" + DEBOOTSTRAPOPTS=("${DEBOOTSTRAPOPTS[@]}" "--keyring=/usr/share/keyrings/ubuntu-archive-keyring.gpg") +else + echo "Unknown distribution: $DIST" + exit 1 +fi +