This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository buildscripts. commit fcadf1529d919f2744790ae519747b567ed86791 Author: Mihai Moldovan <ionic@ionic.de> Date: Wed Apr 5 11:02:48 2017 +0200 bin: copy sbuild-deb-package as build-osx-package and create build+upload and upload symlinks. --- bin/build+upload-osx-package | 1 + bin/build-osx-package | 427 +++++++++++++++++++++++++++++++++++++++++++ bin/upload-osx-package | 1 + 3 files changed, 429 insertions(+) diff --git a/bin/build+upload-osx-package b/bin/build+upload-osx-package new file mode 120000 index 0000000..566f5c0 --- /dev/null +++ b/bin/build+upload-osx-package @@ -0,0 +1 @@ +build-osx-package \ No newline at end of file diff --git a/bin/build-osx-package b/bin/build-osx-package new file mode 100755 index 0000000..ccb4b86 --- /dev/null +++ b/bin/build-osx-package @@ -0,0 +1,427 @@ +#!/bin/bash + +# Copyright (C) 2011-2015 by Mike Gabriel <mike.gabriel@das-netzwerkteam.de> +# Copyright (C) 2016 by Mihai Moldovan <ionic@ionic.de> +# +# 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 3 of the License, 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 this program. If not, see <http://www.gnu.org/licenses/>. + +typeset script_path="$(dirname "$(readlink -e "${BASH_SOURCE}")")" + +. "${script_path}/common.sh" + +GIT_USER="gituser" +GIT_HOSTNAME="git.mydomain.org" + +DEBEMAIL="firstname.lastname@mydomain.org" +DEBFULLNAME="Firstname Lastname" +GPG_KEY="" +DEB_DISTS_SUPPORTED="debian ubuntu raspbian" +DEBIAN_DISTROS="lenny,squeeze,wheezy,jessie,stretch,sid" +RASPBIAN_DISTROS="jessie" +UBUNTU_DISTROS="lucid,precise,trusty,xenial,yakkety" + +COMPONENT_RELEASE="main" +COMPONENT_NIGHTLY="nightly" +COMPONENT_BUNDLES="bundle-release1 bundle-release2" +REPOS_SERVER="packages.mydomain.org" +PACKAGES_WITHOUT_OTHERMIRROR="keyring" +GNUPGHOME="${HOME}/.gnupg" + +test -z "${1}" && { + exec >&2 + echo "usage: $(basename "${0}") [<subpath>/]<git-project> {main,main/<codename>,nightly,nightly/<codename>} [<git-checkout>]" + exit 1 +} + +PREFIX="$(cut -d"-" -f1 <<< "$(basename "${0}")")" +test -f "${HOME}/.buildscripts/${PREFIX}.conf" && . "${HOME}/.buildscripts/${PREFIX}.conf" || { + exec >&2 + echo "${0} has no valid context prefix..." + exit 1; +} + +: ${NO_DELAY:="no"} +: ${FORCE_BUILD:="no"} +: ${DEB_BUILD_FOR:="debian:${DEBIAN_DISTROS} ubuntu:${UBUNTU_DISTROS} raspbian:${RASPBIAN_DISTROS}"} +: ${FLAVOR:="native"} + +# These parts are not user-serviceable. +typeset -ag temp_cleanup="" +# End of non-user-serviceable part. + +set -ex + +# Cleans up temporary directories and files. +# RFC SHOULD be called by trap handlers. +cleanup () { + typeset temp_dir="" + for temp_dir in "${temp_cleanup[@]}"; do + if [ -n "${temp_dir}" ] && [ -d "${temp_dir}" ]; then + rm -Rf -- "${temp_dir}" + fi + done +} + +# Run cleanup() automatically. +trap cleanup ERR EXIT SIGTERM SIGINT SIGHUP SIGPIPE SIGALRM SIGUSR1 SIGUSR2 + +set_vars() { + SBUILD="sbuild" + TEMP_BASE="${HOME}/tmp/" + mkdir -p -- "${TEMP_BASE}" + chmod 2770 -- "${TEMP_BASE}" + + # first argv is the name of the Git project + PROJECT_PATH="${1}" + PROJECT_PATH="${PROJECT_PATH/%.git/}" + PROJECT="$(basename "${PROJECT_PATH}")" + DEBSRCPKG="${PROJECT}" + + # grab repository component area from command line (2nd argv) or guess it + ARGV2_COMPONENT="$(cut -d"/" -f1 <<< "${2}/")" + ARGV2_CODENAME="$(cut -d"/" -f2 <<< "${2}/")" + COMPONENT="${ARGV2_COMPONENT:-${COMPONENT:-$COMPONENT_NIGHTLY}}" + CODENAMES="${ARGV2_CODENAME:-${CODENAMES}}" + [ -n "${ARGV2_CODENAME}" ] && FORCE_BUILD="yes" || true + DATE="${DATE:-$(date +%Y%m%d)}" + if [ "x${COMPONENT}" = "x${COMPONENT_RELEASE}" ] || [ "x${COMPONENT}" = "x${COMPONENT_RELEASE}-test" ] || grep -qs "$COMPONENT" <<< "${COMPONENT_RELEASES}"; then + CHECKOUT="${3:-build-${COMPONENT}}" + elif [ "x${COMPONENT}" = "x${COMPONENT_NIGHTLY}" ]; then + CHECKOUT="${3:-master}" + else + echo "error: no such package component area for this Git project. Aborting..." + exit 1 + fi + # the DATE might be given as ,,today'' from the command line + [ "x${DATE}" = "xtoday" ] && DATE="$(date +%Y%m%d)" + + # setting paths + PROJECT_DIR="${HOME}/build/${COMPONENT}/${PROJECT}" + PKGDIST="${HOME}/pkg-dist/${COMPONENT}/${PROJECT}" + + # lock file + LOCK_FILE="${PROJECT_DIR}/../.${PROJECT}.lock" + + # creating paths + mkdir -p -- "${PROJECT_DIR}" + mkdir -p -- "${PKGDIST}" + + # by default we build for all current debian versions + if [ "x${ARGV2_CODENAME}" != "x" ]; then + if [[ "$FLAVOR" = "raspbian" ]]; then + if grep -qs "${ARGV2_CODENAME}" <<< "${RASPBIAN_DISTROS}"; then + DEB_BUILD_FOR="raspbian:${ARGV2_CODENAME}" + fi + else + if grep -qs "${ARGV2_CODENAME}" <<< "${DEBIAN_DISTROS}"; then + DEB_BUILD_FOR="debian:${ARGV2_CODENAME}" + elif grep -qs "${ARGV2_CODENAME}" <<< "${UBUNTU_DISTROS}"; then + DEB_BUILD_FOR="ubuntu:${ARGV2_CODENAME}" + fi + fi + fi + + return 0 +} + +prepare_workspace() { + # make sure our local working copy is up to date... + if [ -d "${PROJECT_DIR}/.git" ]; then + cd "${PROJECT_DIR}" && { + git reset --hard + git checkout --force "${CHECKOUT}" || git checkout --force -b "${CHECKOUT}" + git pull origin "${CHECKOUT}" + git fetch origin upstream:upstream || true + git fetch origin pristine-tar:pristine-tar || true + # and again, get the ${CHECKOUT} refspec in pure state + git reset --hard + git clean -df + } || { + echo "Unable to switch to project directory \"${PROJECT_DIR}\". Check the permissions." >&2 + exit 1 + } + else + cd "$(dirname "${PROJECT_DIR}")" && { + git clone "git://${GIT_HOSTNAME}/${PROJECT_PATH}.git" + cd "${PROJECT}" + git checkout --force "${CHECKOUT}" || git checkout --force -b "${CHECKOUT}" + git fetch origin upstream:upstream + git fetch origin pristine-tar:pristine-tar || true + git clean -df + } || { + echo "Unable to switch to project directory \"$(dirname "${PROJECT_DIR}")\". Does it exist? Check the permissions." >&2 + exit 1 + } + fi + + GIT_OBJECT_ID="$(git rev-parse --verify HEAD)" + cd "${PROJECT_DIR}" + + # extract Debian source package name from debian/changelog + if [ -e debian/changelog ]; then + DEBSRCPKG="$(dpkg-parsechangelog -S Source)" + fi + + return 0 +} + +clear_pkgdist() { + # pkgdist directory cleanup + + # Do NOT spawn a subshell here. + # Allow changing global variables in the main process. + typeset -a deb_build_for_arr + typeset OLDIFS="${IFS}" + IFS=" " + read -a deb_build_for_arr <<< "${DEB_BUILD_FOR}" + IFS="${OLDIFS}" + + typeset line="" + for line in "${deb_build_for_arr[@]}"; do + l_DIST="$(cut -d":" -f1 <<< "${line/: /:}" | tr [:upper:] [:lower:])" + l_CODENAMES="${CODENAMES:-$(cut -d":" -f2- <<< "${line/: /:}" | sed -e 's/,/ /g' | tr [:upper:] [:lower:])}" + grep -qs "${l_DIST}" <<< "${DEB_DISTS_SUPPORTED}" && { + for l_CODENAME in ${l_CODENAMES}; do + + # in case we build a special CODENAME (squeeze, wheezy, lucid, ...) do skip + # the wrong distribution here... + test -z "${CODENAMES}" || grep "${CODENAMES}" <<< "${line}" || break + + typeset arch="amd64 i386" + + [ "${l_DIST}" = "raspbian" ] && arch="armhf" + + for l_ARCH in ${arch}; do + [ "x${SKIP_ARCH}" != "x${l_ARCH}" ] && { + mkdir -p -- "${PKGDIST}/${l_DIST}/${l_CODENAME}/${l_ARCH}" + rm -f -- "${PKGDIST}/${l_DIST}/${l_CODENAME}/${l_ARCH}/dupload.conf" + rm -f -- "${PKGDIST}/${l_DIST}/${l_CODENAME}/${l_ARCH}/"*_*.changes + rm -f -- "${PKGDIST}/${l_DIST}/${l_CODENAME}/${l_ARCH}/"*_*.upload + rm -f -- "${PKGDIST}/${l_DIST}/${l_CODENAME}/${l_ARCH}/"*_*.build + rm -f -- "${PKGDIST}/${l_DIST}/${l_CODENAME}/${l_ARCH}/"*_*.dsc + rm -f -- "${PKGDIST}/${l_DIST}/${l_CODENAME}/${l_ARCH}/"*_*.tar.gz + rm -f -- "${PKGDIST}/${l_DIST}/${l_CODENAME}/${l_ARCH}/"*.deb + } + done + done + } + done + return 0 +} + +build_packages() { + # use pbuilder for building all variants of this package + + # Do NOT spawn a subshell here. + # Allow changing global variables in the main process. + typeset -a deb_build_for_arr + typeset OLDIFS="${IFS}" + IFS=" " + read -a deb_build_for_arr <<< "${DEB_BUILD_FOR}" + IFS="${OLDIFS}" + + typeset line="" + for line in "${deb_build_for_arr[@]}"; do + l_DIST="$(cut -d":" -f1 <<< "${line/: /:}" | tr [:upper:] [:lower:])" + l_CODENAMES="${CODENAMES:-$(cut -d":" -f2- <<< "${line/: /:}" | sed -e 's/,/ /g' | tr [:upper:] [:lower:])}" + grep -qs "${l_DIST}" <<< "${DEB_DISTS_SUPPORTED}" && { + for l_CODENAME in ${l_CODENAMES}; do + + # in case we build a special CODENAME (squeeze, wheezy, lucid, ...) do skip + # the wrong distribution here... + test -z "${CODENAMES}" || grep "${CODENAMES}" <<< "${line}" || break + + TEMP_DIR="$(mktemp -d --tmpdir="${TEMP_BASE}" "tmp.$(repeat_str "X" "24")")" + temp_cleanup+=("${TEMP_DIR}") + mkdir -p -- "${TEMP_DIR}/${PROJECT}" + chmod 2770 -Rf -- "${TEMP_DIR}" + + cd "${PROJECT_DIR}" + git clone --no-hardlinks --no-local "${PROJECT_DIR}" "${TEMP_DIR}/${PROJECT}/" + cd "${TEMP_DIR}/${PROJECT}" + git checkout "${CHECKOUT}" || git checkout master + find "${PROJECT_DIR}/../" -maxdepth 0 -mindepth 0 -type f | grep -qs "${PROJECT}_"*.orig.tar.gz && cp -- "${PROJECT_DIR}/../${PROJECT}_"*.orig.tar.gz .. + GITREV="$(gitrevno)" + + # we always build native packages for our repos + SA_OPTION="" + test -f "debian/source/format" && grep -Eqs '^3.0.*\(quilt\)$' "debian/source/format" && { + git fetch origin upstream:upstream + UPSTREAM_VERSION="$(dpkg-parsechangelog | grep "Version:" | cut -d " " -f2 | sed -e 's/-.*//' -e 's/^.*://')" + REVISION="$(dpkg-parsechangelog | grep "Version:" | cut -d " " -f2 | sed -e 's/.*-//')" + git archive --prefix="${PROJECT}-${UPSTREAM_VERSION}/" -o "../${PROJECT}_${UPSTREAM_VERSION}.orig.tar.gz" "upstream/${UPSTREAM_VERSION}" && { + SA_OPTION="--debbuildopts=-sa" + } || echo "1.0" > "debian/source/format" + } + + # for Ubuntu version is the codename of the distribution release + if [ -n "${BASH_VERSINFO[0]}" ] && [ "${BASH_VERSINFO[0]}" -gt 3 ]; then + typeset -l codename="${l_CODENAME}" + else + typeset codename="$(tr '[:upper:]' '[:lower:]' <<< "${l_CODENAME}")" + fi + + # translate the version name for Debian releases + [ "x${l_CODENAME}" = "xsid" ] && codename="unstable" + #[ "x$l_CODENAME" = "xjessie" ] && codename=testing + #[ "x$l_CODENAME" = "xwheezy" ] && codename=stable + #[ "x$l_CODENAME" = "xoldstable" ] && codename=oldstable + + typeset numerical_version="" + typeset -i tmp_ret="1" + typeset pretty_dist="" + + if [ -n "${l_DIST}" ] && [ "${l_DIST}" = "debian" ] || [ "${l_DIST}" = "raspbian" ]; then + pretty_dist="Debian" + numerical_version="$("debian-codename-to-version.sh" "${codename}")" + tmp_ret="${?}" + fi + + if [ -n "${l_DIST}" ] && [ "${l_DIST}" = "ubuntu" ]; then + pretty_dist="Ubuntu" + numerical_version="$("ubuntu-codename-to-version.sh" "${codename}")" + tmp_ret="${?}" + fi + + if [ "${tmp_ret}" -ne "0" ] || [ -z "${numerical_version}" ]; then + echo "Error: unable to map code name \"${codename}\" to Debian or Ubuntu numerical versions. Unknown code name or not applicable to distribution \"${pretty_dist}\"? Aborting." >&2 + exit 1 + fi + + # modify the section for non-release package builds + [ "x${COMPONENT}" != "x${COMPONENT_RELEASE}" ] && { + mv -- "debian/control" "debian/control.tmp" + sed "s,Section:[\ ]*\(.*\),Section: ${COMPONENT}/\1,g" debian/control.tmp > debian/control + } + + # modify changelog for this build + if [ "${COMPONENT}" != "${COMPONENT_NIGHTLY}" ]; then + dch --distribution "${codename}" --force-distribution -l "+git${DATE}.${GITREV}+${numerical_version}.${COMPONENT}." "Auto-built ${pretty_dist} ${l_CODENAME} (${numerical_version}) package for ${REPOS_SERVER} repository (Git commit: ${GIT_OBJECT_ID})." + else + dch --distribution "${codename}" --force-distribution -l "~git${DATE}.${GITREV}+${numerical_version}.${COMPONENT}." "Development-Snapshot!!! Auto-built ${pretty_dist} ${l_CODENAME} (${numerical_version}) package for ${REPOS_SERVER} repository (Git commit: ${GIT_OBJECT_ID})." + fi + [ "${l_DIST}" = "raspbian" ] && mkdir -p -- "${PKGDIST}/${l_DIST}/${l_CODENAME}/armhf" || mkdir -p -- "${PKGDIST}/${l_DIST}/${l_CODENAME}/"{amd64,i386} + OTHERMIRROR="" + if [ "x${COMPONENT}" = "x${COMPONENT_NIGHTLY}" ]; then + grep -qs "${PROJECT}" <<< "${PACKAGE_WITHOUT_OTHERMIRROR}" || OTHERMIRROR="deb http://${REPOS_SERVER}/${l_DIST} ${l_CODENAME} ${COMPONENT_RELEASE} ${COMPONENT}" + else + grep "${PROJECT}" <<< "${PACKAGE_WITHOUT_OTHERMIRROR}" || OTHERMIRROR="deb http://${REPOS_SERVER}/${l_DIST} ${l_CODENAME} ${COMPONENT}" + fi + if [ "${PROJECT}" = "x2gomatebindings" ] && [ "${codename}" = "wheezy" ]; then + OTHERMIRROR="deb http://httpredir.debian.org/debian ${codename}-backports main" + fi + + # create git changelog immediately prior to building the package + git --no-pager log --since "2 years ago" --format="%ai %aN (%h) %n%n%x09*%w(68,0,10) %s%d%n" > ChangeLog.gitlog + + typeset -a sbuild_options + sbuild_options=("-n" "--jobs=2" "-sA" "--dist=${codename}" "--keyid=${GPG_KEY}" "--build-dep-resolver=aptitude") + + if [ -n "${SA_OPTION}" ]; then + sbuild_options+=("${SA_OPTION}") + fi + + if [ -n "${OTHERMIRROR}" ]; then + sbuild_options+=("--extra-repository=${OTHERMIRROR}") + fi + + typeset -a sbuild_options_64 sbuild_options_32 sbuild_options_armhf + sbuild_options_64=("${sbuild_options[@]}") + sbuild_options_32=("${sbuild_options[@]}" "--arch=i386" "--debbuildopts=-B") + sbuild_options_armhf=("${sbuild_options[@]}" "--arch=armhf" "--chroot=${codename}-armhf-raspbian-sbuild") + + if [ "${l_DIST}" = "raspbian" ]; then + [ "${SKIP_ARCH}" != "armhf" ] && grep -Eqs 'Architecture.*(all|any|armhf)' "${TEMP_DIR}/${PROJECT}/debian/control" && { + cd "${PKGDIST}/${l_DIST}/${l_CODENAME}/armhf" + nice ${SBUILD} "${sbuild_options_armhf[@]}" "${TEMP_DIR}/${PROJECT}" + } + else + [ "x${SKIP_ARCH}" != "xamd64" ] && grep -Eqs 'Architecture.*(all|any|amd64)' "${TEMP_DIR}/${PROJECT}/debian/control" && { + cd "${PKGDIST}/${l_DIST}/${l_CODENAME}/amd64" + nice ${SBUILD} "${sbuild_options_64[@]}" "${TEMP_DIR}/${PROJECT}" + } + [ "x${SKIP_ARCH}" != "xi386" ] && grep -Eqs 'Architecture.*(any|i386)' "${TEMP_DIR}/${PROJECT}/debian/control" && { + cd "${PKGDIST}/${l_DIST}/${l_CODENAME}/i386" + nice ${SBUILD} "${sbuild_options_32[@]}" "${TEMP_DIR}/${PROJECT}" + } + fi + done + } + done + return 0 +} + +upload_packages() { + # dupload the new packages to the reprepro repository + + # Do NOT spawn a subshell here. + # Allow changing global variables in the main process. + typeset -a deb_build_for_arr + typeset OLDIFS="${IFS}" + IFS=" " + read -a deb_build_for_arr <<< "${DEB_BUILD_FOR}" + IFS="${OLDIFS}" + + typeset line="" + for line in "${deb_build_for_arr[@]}"; do + l_DIST="$(cut -d":" -f1 <<< "${line/: /:}" | tr [:upper:] [:lower:])" + l_CODENAMES="${CODENAMES:-$(cut -d":" -f2- <<< "${line/: /:}" | sed -e 's/,/ /g' | tr [:upper:] [:lower:])}" + for l_CODENAME in ${l_CODENAMES}; do + + # in case we build a special CODENAME (squeeze, wheezy, lucid, ...) do skip + # the wrong distribution here... + test -z "${CODENAMES}" || grep "${CODENAMES}" <<< "${line}" || break + + typeset arch="amd64 i386" + + [ "${l_DIST}" = "raspbian" ] && arch="armhf" + + for l_ARCH in ${arch}; do + [ "x${SKIP_ARCH}" != "x${l_ARCH}" ] && { + cd "${PKGDIST}/${l_DIST}/${l_CODENAME}/${l_ARCH}" + test -f "./dupload.conf" || ln -s -- "${HOME}/.dupload.conf.${PREFIX}" "./dupload.conf" + ls -- "${DEBSRCPKG}_"*.changes >/dev/null 2>&1 && dupload -c --to "${PREFIX}-${l_DIST}-${l_CODENAME}" "${DEBSRCPKG}_"*.changes 0<&- + } + done + done + done + return 0 +} + + +### MAIN ### +set_vars "${@}" && { + if [ "x$(basename "${0}")" = "x${PREFIX}-sbuild-deb-package" ] || [ "x$(basename "${0}")" = "x${PREFIX}-sbuild+upload-deb-package" ]; then + FORCE_BUILD="$(make_boolean "${FORCE_BUILD}")" + NO_DELAY="$(make_boolean "${NO_DELAY}")" + + cd "${PROJECT_DIR}" && { + pkgneedsbuild "${CHECKOUT}" || [ "${FORCE_BUILD}" -eq "1" ] + } && { + if [ "${FORCE_BUILD}" -eq "1" ] && [ "${NO_DELAY}" -eq "0" ]; then + delay_build + fi + lock_workspace "${LOCK_FILE}" + prepare_workspace && { + unlock_workspace "${LOCK_FILE}" + clear_pkgdist + build_packages + } + unlock_workspace "${LOCK_FILE}" + } + fi + if [ "x$(basename "${0}")" = "x${PREFIX}-upload-deb-package" ] || [ "x$(basename "${0}")" = "x${PREFIX}-sbuild+upload-deb-package" ]; then + upload_packages + fi +} diff --git a/bin/upload-osx-package b/bin/upload-osx-package new file mode 120000 index 0000000..566f5c0 --- /dev/null +++ b/bin/upload-osx-package @@ -0,0 +1 @@ +build-osx-package \ No newline at end of file -- Alioth's /srv/git/code.x2go.org/buildscripts.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/buildscripts.git