From af53da995387148a49f9796c42be3e465db14bc6 Mon Sep 17 00:00:00 2001 From: John Morris Date: Sat, 11 Apr 2015 17:08:14 -0500 Subject: [PATCH] local config override, part 2 Package configs now parameterized using associative arrays and so can be overridden in `local-config.sh`. - Move package distro checks to distro.sh - Guess package compression from tarball - Move proxy functions out of `init-cli.sh` Completes #9, 'Add local config override file' --- dbuild | 2 +- scripts/architecture.sh | 10 ++- scripts/debian-binary-package.sh | 3 +- scripts/debian-debzn.sh | 31 ++++---- scripts/debian-orig-tarball.sh | 42 +++++------ scripts/debian-package.sh | 76 +++++++++++++++++++ scripts/debian-pkg-repo.sh | 1 + scripts/debian-source-package.sh | 37 +++++++--- scripts/distro.sh | 52 +++++++++---- scripts/init-cli.sh | 49 ++---------- scripts/package/czmq.sh | 10 ++- scripts/package/dovetail-automata-keyring.sh | 9 ++- scripts/package/linux-latest.sh | 21 ++++-- scripts/package/linux-tools.sh | 25 ++++--- scripts/package/linux.sh | 42 ++++++----- scripts/package/python-pyftpdlib.sh | 12 ++- scripts/package/pyzmq.sh | 25 ++++--- scripts/package/rtai.sh | 16 ++-- scripts/package/template.sh | 37 ++++++++++ scripts/package/xenomai.sh | 11 ++- scripts/sbuild.sh | 78 ++++++++++---------- scripts/schroot.conf | 8 ++ 22 files changed, 378 insertions(+), 219 deletions(-) create mode 100644 scripts/debian-package.sh create mode 100644 scripts/package/template.sh create mode 100644 scripts/schroot.conf diff --git a/dbuild b/dbuild index 5dfab21..a7c4a1c 100755 --- a/dbuild +++ b/dbuild @@ -13,7 +13,7 @@ case $MODE in ;; CONFIGURE_PKG) # -C: (Internal use) Pre-build configure script - ( cd $BUILD_SRC_DIR && configure_package; ) + run_configure_package_func ;; ##### Functions run inside Docker container ##### diff --git a/scripts/architecture.sh b/scripts/architecture.sh index 9813446..43f4fa5 100644 --- a/scripts/architecture.sh +++ b/scripts/architecture.sh @@ -10,12 +10,14 @@ arch_host() { local ARCH=$2 if test $ARCH = 'default'; then - ARCH=$(arch_default) + ARCH=$(arch_default $DISTRO) fi echo $ARCH } arch_build() { + # For non-binary pkg builds, simply return the host arch. + # # The build arch for a package is the host arch if the package # cannot be cross-built. Otherwise, if the host arch is a # 'personality' of the machine arch (e.g. amd64->i386), use the @@ -24,8 +26,10 @@ arch_build() { local ARCH=$2 local HOST_ARCH=$(arch_host $DISTRO $ARCH) - if $NATIVE_BUILD_ONLY || \ - ! distro_base_repo $DISTRO $HOST_ARCH >/dev/null; then + if ! mode BUILD_PACKAGE || \ + ${PACKAGE_NATIVE_BUILD_ONLY[$PACKAGE]} || \ + ! distro_base_repo $DISTRO $HOST_ARCH >/dev/null; + then echo $HOST_ARCH return fi diff --git a/scripts/debian-binary-package.sh b/scripts/debian-binary-package.sh index 41b5bfa..892b2d8 100644 --- a/scripts/debian-binary-package.sh +++ b/scripts/debian-binary-package.sh @@ -13,7 +13,7 @@ binary_package_check_arch() { local ARCH=$(arch_host $DISTRO $HOST_ARCH) # Check package's list of excluded arches - for a in $EXCLUDE_ARCHES; do + for a in ${PACKAGE_EXCLUDE_ARCHES[$PACKAGE]}; do if test $a = $ARCH; then error "Package $PACKAGE excluded from arch $ARCH" fi @@ -24,6 +24,7 @@ binary_package_build() { msg "Building binary package '$PACKAGE'" source_package_init binary_package_check_arch + distro_check_package $DISTRO $PACKAGE ccache_setup sbuild_build_package } diff --git a/scripts/debian-debzn.sh b/scripts/debian-debzn.sh index 1c26da6..3bd8778 100644 --- a/scripts/debian-debzn.sh +++ b/scripts/debian-debzn.sh @@ -7,7 +7,8 @@ parse_changelog() { } debianization_init() { - test -z "$PACKAGE_VERSION" || return + test -z "$DEBIANIZATION_INIT" || return 0 + DEBIANIZATION_INIT=1 # Don't do this twice PACKAGE_VERSION=$(parse_changelog version) debug " Upstream package version-release: $PACKAGE_VERSION" @@ -38,24 +39,24 @@ debianization_init() { } debianization_git_tree_update() { - if test -z "$GIT_URL"; then - debug " (No GIT_URL defined; not handling debianization git tree)" + if test -z "${PACKAGE_DEBZN_GIT_URL[$PACKAGE]}"; then + debug " (No PACKAGE_DEBZN_GIT_URL defined; not handling git tree)" return fi if test ! -d $DEBZN_GIT_DIR/.git; then msg " Cloning new debianization git tree" - debug " Source: $GIT_URL" + debug " Source: ${PACKAGE_DEBZN_GIT_URL[$PACKAGE]}" debug " Dir: $DEBZN_GIT_DIR" - debug " Git branch: ${GIT_BRANCH:-master}" - run_user git clone -o dbuild -b ${GIT_BRANCH:-master} --depth=1 \ - $GIT_URL $DEBZN_GIT_DIR + debug " Git branch: ${PACKAGE_DEBZN_GIT_BRANCH[$PACKAGE]}" + run_user git clone -o dbuild -b ${PACKAGE_DEBZN_GIT_BRANCH[$PACKAGE]} \ + --depth=1 ${PACKAGE_DEBZN_GIT_URL[$PACKAGE]} $DEBZN_GIT_DIR else msg " Updating debianization git tree" debug " Dir: $DEBZN_GIT_DIR" - debug " Git branch: ${GIT_BRANCH:-master}" + debug " Git branch: ${PACKAGE_DEBZN_GIT_BRANCH[$PACKAGE]}" run_user git --git-dir=$DEBZN_GIT_DIR/.git --work-tree=$DEBZN_GIT_DIR \ - pull --ff-only dbuild ${GIT_BRANCH:-master} + pull --ff-only dbuild ${PACKAGE_DEBZN_GIT_BRANCH[$PACKAGE]} fi debug " Saving original changelog" @@ -89,16 +90,16 @@ debianization_add_changelog() { } debianization_git_tree_unpack() { - if test -n "$GIT_URL"; then + if test -n "${PACKAGE_DEBZN_GIT_URL[$PACKAGE]}"; then msg " Copying debianization from git tree" debug " Debzn git dir: $DEBZN_GIT_DIR" debug " Dest dir: $BUILD_SRC_DIR/debian" - debug " Git branch: ${GIT_BRANCH:-master}" - run_user git --git-dir=$DEBZN_GIT_DIR/.git archive \ - --prefix=debian/ ${GIT_BRANCH:-master} | \ - run_user tar xCf $BUILD_SRC_DIR - + debug " Git branch: ${PACKAGE_DEBZN_GIT_BRANCH[$PACKAGE]}" + run_user bash -c "'git --git-dir=$DEBZN_GIT_DIR/.git archive \\ + --prefix=debian/ ${PACKAGE_DEBZN_GIT_BRANCH[$PACKAGE]} | \\ + tar xCf $BUILD_SRC_DIR -'" else - debug " (No GIT_URL defined; not unpacking debianization from git)" + debug " (No PACKAGE_DEBZN_GIT_URL defined; not unpacking from git)" fi } diff --git a/scripts/debian-orig-tarball.sh b/scripts/debian-orig-tarball.sh index cd4225e..9c27e1c 100644 --- a/scripts/debian-orig-tarball.sh +++ b/scripts/debian-orig-tarball.sh @@ -3,43 +3,37 @@ debug " Sourcing debian-orig-tarball.sh" source_tarball_init() { - case "$DEBIAN_PACKAGE_COMP" in - gz) - DPKG_BUILD_ARGS=-Zgzip - ;; - xz) - DPKG_BUILD_ARGS=-Zxz - ;; - # Default to bz2 - bz2|*) - DPKG_BUILD_ARGS=-Zbzip2 - DEBIAN_PACKAGE_COMP=bz2 - ;; + case "${PACKAGE_COMP[$PACKAGE]}" in + gz) DPKG_BUILD_ARGS=-Zgzip ;; + xz) DPKG_BUILD_ARGS=-Zxz ;; + bz2) DPKG_BUILD_ARGS=-Zbzip2 ;; + *) error "Package $PACKAGE: Unknown package compression format" ;; esac local BASENAME=${PACKAGE}_${PACKAGE_VER} - case "$DEBIAN_PACKAGE_FORMAT" in + case "${PACKAGE_FORMAT[$PACKAGE]}" in '3.0 (quilt)') - DEBIAN_TARBALL=${BASENAME}.orig.tar.${DEBIAN_PACKAGE_COMP} + ORIG_TARBALL=${BASENAME}.orig.tar.${PACKAGE_COMP[$PACKAGE]} ;; '3.0 (native)') - DEBIAN_TARBALL=${BASENAME}.tar.${DEBIAN_PACKAGE_COMP} + ORIG_TARBALL=${BASENAME}.tar.${PACKAGE_COMP[$PACKAGE]} ;; *) error "Package ${PACKAGE}:" \ - "Unknown package format '${DEBIAN_PACKAGE_FORMAT}'" + "Unknown package format '${PACKAGE_FORMAT[$PACKAGE]}'" ;; esac } source_tarball_download() { - if test -n "$TARBALL_URL"; then - if test ! -f $SOURCE_PKG_DIR/$DEBIAN_TARBALL; then + if test -n "${PACKAGE_TARBALL_URL[$PACKAGE]}"; then + if test ! -f $SOURCE_PKG_DIR/$ORIG_TARBALL; then msg " Downloading source tarball" - debug " Source: $TARBALL_URL" - debug " Dest: $SOURCE_PKG_DIR/$DEBIAN_TARBALL" + debug " Source: ${PACKAGE_TARBALL_URL[$PACKAGE]}" + debug " Dest: $SOURCE_PKG_DIR/$ORIG_TARBALL" run_user mkdir -p $SOURCE_PKG_DIR - run_user wget $TARBALL_URL -O $SOURCE_PKG_DIR/$DEBIAN_TARBALL + run_user wget ${PACKAGE_TARBALL_URL[$PACKAGE]} \ + -O $SOURCE_PKG_DIR/$ORIG_TARBALL else debug " (Source tarball exists; not downloading)" fi @@ -49,13 +43,13 @@ source_tarball_download() { } source_tarball_unpack() { - if test -z "$TARBALL_URL"; then - debug " (No TARBALL_URL defined; not unpacking source tarball)" + if test -z "${PACKAGE_TARBALL_URL[$PACKAGE]}"; then + debug " (No PACKAGE_TARBALL_URL defined; not unpacking)" return fi msg " Unpacking source tarball" - run_user tar xCf $BUILD_SRC_DIR $SOURCE_PKG_DIR/$DEBIAN_TARBALL \ + run_user tar xCf $BUILD_SRC_DIR $SOURCE_PKG_DIR/$ORIG_TARBALL \ --strip-components=1 } diff --git a/scripts/debian-package.sh b/scripts/debian-package.sh new file mode 100644 index 0000000..f9832db --- /dev/null +++ b/scripts/debian-package.sh @@ -0,0 +1,76 @@ +. $SCRIPTS_DIR/debian-source-package.sh +. $SCRIPTS_DIR/debian-binary-package.sh + +# List of all packages +declare PACKAGES + +# Package sources +declare -A PACKAGE_TARBALL_URL +declare -A PACKAGE_DEBZN_GIT_URL +declare -A PACKAGE_DEBZN_GIT_BRANCH +declare -A PACKAGE_COMP +declare -A PACKAGE_FORMAT + +# Build params +declare -A PACKAGE_SBUILD_RESOLVER +declare -A PACKAGE_NATIVE_BUILD_ONLY +declare -A PACKAGE_EXCLUDE_ARCHES + +# Source package configuration +declare -A PACKAGE_CONFIGURE_DEPS +declare -A PACKAGE_CONFIGURE_FUNC + +package_read_config() { + local PACKAGE=$1 + PACKAGES+=" $PACKAGE" + + # set up defaults + PACKAGE_TARBALL_URL[$PACKAGE]= + PACKAGE_DEBZN_GIT_URL[$PACKAGE]= + PACKAGE_DEBZN_GIT_BRANCH[$PACKAGE]="master" + PACKAGE_COMP[$PACKAGE]= + PACKAGE_FORMAT[$PACKAGE]="3.0 (quilt)" + PACKAGE_SBUILD_RESOLVER[$PACKAGE]= + PACKAGE_NATIVE_BUILD_ONLY[$PACKAGE]="false" + PACKAGE_EXCLUDE_ARCHES[$PACKAGE]= + PACKAGE_CONFIGURE_DEPS[$PACKAGE]= + PACKAGE_CONFIGURE_FUNC[$PACKAGE]= + + . $PACKAGE_CONFIG_DIR/$PACKAGE.sh + + # Package compression + if test -z "${PACKAGE_COMP[$PACKAGE]}"; then + case "${PACKAGE_TARBALL_URL[$PACKAGE]}" in + ""|*.xz) PACKAGE_COMP[$PACKAGE]="xz" ;; + *.bz2) PACKAGE_COMP[$PACKAGE]="bz2" ;; + *.gz) PACKAGE_COMP[$PACKAGE]="gz" ;; + *) error "Package $PACKAGE: Unknown package compression format" ;; + esac + fi +} + +package_read_all_configs() { + debug " Sourcing package configurations:" + for config in $PACKAGE_CONFIG_DIR/*.sh; do + local package=$(basename $config .sh) + test $package != 'template' || continue # skip template + debug " $package" + package_read_config $package + done +} + +package_debug() { + for p in $PACKAGES; do + debug "package $p:" + debug " tarball url: ${PACKAGE_TARBALL_URL[$p]}" + debug " debianization git url: ${PACKAGE_DEBZN_GIT_URL[$p]}" + debug " debianization git branch: ${PACKAGE_DEBZN_GIT_BRANCH[$p]}" + debug " compression: ${PACKAGE_COMP[$p]}" + debug " format: ${PACKAGE_FORMAT[$p]}" + debug " sbuild resolver: ${PACKAGE_SBUILD_RESOLVER[$p]}" + debug " native build only: ${PACKAGE_NATIVE_BUILD_ONLY[$p]}" + debug " excluded architectures: ${PACKAGE_EXCLUDE_ARCHES[$p]}" + debug " configuration deps: ${PACKAGE_CONFIGURE_DEPS[$p]}" + debug " configuration function: ${PACKAGE_CONFIGURE_FUNC[$p]}" + done +} diff --git a/scripts/debian-pkg-repo.sh b/scripts/debian-pkg-repo.sh index 9e1a1f1..0c6c50b 100644 --- a/scripts/debian-pkg-repo.sh +++ b/scripts/debian-pkg-repo.sh @@ -49,6 +49,7 @@ deb_repo_build() { deb_repo_init # repo config deb_repo_setup # set up repo, if needed source_package_init # source pkg config + distro_check_package $DISTRO $PACKAGE # add source pkg msg " Removing all packages for '$PACKAGE'" diff --git a/scripts/debian-source-package.sh b/scripts/debian-source-package.sh index 3c927e0..ad3a744 100644 --- a/scripts/debian-source-package.sh +++ b/scripts/debian-source-package.sh @@ -11,9 +11,11 @@ debug " Sourcing debian-source-package.sh" ######################################## # Source package init vars source_package_init() { + distro_check_package $DISTRO $PACKAGE + debianization_init # Init vars after unpacking - debug " Package format: ${DEBIAN_PACKAGE_FORMAT:=3.0 (quilt)}" + debug " Package format: ${PACKAGE_FORMAT[$PACKAGE]}" } ######################################## @@ -22,19 +24,34 @@ source_package_setup() { msg " Preparing source directory $BUILD_SRC_DIR" run_user rm -rf $BUILD_SRC_DIR run_user mkdir -p $BUILD_SRC_DIR/debian + + # Proxy + if test -n "$HTTP_PROXY"; then + debug " Setting proxy: $HTTP_PROXY" + export http_proxy="$HTTP_PROXY" + export https_proxy="$HTTP_PROXY" + fi + } ######################################## # Source package configuration -configure_package_wrapper() { - # Some packages may define a configuration step - if declare -f configure_package >/dev/null; then - msg " Configuring source package" - sbuild_configure_package - else - debug " (No configure_package function defined)" +configure_package() { + if test -z "${PACKAGE_CONFIGURE_FUNC[$PACKAGE]}"; then + debug " (No source pkg configure function defined)" + return fi + + sbuild_configure_package +} + +run_configure_package_func() { + debug " Running configure function: ${PACKAGE_CONFIGURE_FUNC[$PACKAGE]}" + ( + cd $BUILD_SRC_DIR + run ${PACKAGE_CONFIGURE_FUNC[$PACKAGE]} + ) } ######################################## @@ -46,7 +63,7 @@ source_package_build_from_tree() { ( cd $BUILD_SRC_DIR run_user dpkg-source -b \ - --format="'${DEBIAN_PACKAGE_FORMAT}'" . + --format="'${PACKAGE_FORMAT[$PACKAGE]}'" . ) } @@ -80,7 +97,7 @@ source_package_build() { debianization_add_changelog # Some packages may define a configuration step - configure_package_wrapper + configure_package # Build the source package and clean up source_package_build_from_tree diff --git a/scripts/distro.sh b/scripts/distro.sh index 6722e8b..5f5d243 100644 --- a/scripts/distro.sh +++ b/scripts/distro.sh @@ -84,6 +84,22 @@ repo_has_arch() { return $RES } +distro_check_package() { + # Be sure package is valid for distro + local DISTRO=$1 + local PACKAGE=$2 + local DISTRO_PKG_OK=false + + for p in ${DISTRO_PACKAGES[$DISTRO]}; do + if test $p = $PACKAGE; then + DISTRO_PKG_OK=true + break + fi + done + $DISTRO_PKG_OK || error "Package $PACKAGE excluded from distro $DISTRO" + debug " Package $PACKAGE included in distro $DISTRO: OK" +} + distro_base_repo() { local DISTRO=$1 local ARCH=$2 @@ -164,42 +180,46 @@ distro_configure_apt() { for repo in ${DISTRO_REPOS[$DISTRO]} local; do repo_configure $repo done +} +distro_set_apt_proxy() { # Set apt proxy if test -n "$HTTP_PROXY"; then - debug " Setting apt proxy: $HTTP_PROXY" + debug " Setting http proxy: $HTTP_PROXY" run bash -c "echo Acquire::http::Proxy \\\"$HTTP_PROXY\\\"\\; > \ $CHROOT_DIR/etc/apt/apt.conf.d/05proxy" run_debug cat $CHROOT_DIR/etc/apt/apt.conf.d/05proxy - fi + export http_proxy="$HTTP_PROXY" + export https_proxy="$HTTP_PROXY" + fi } distro_debug() { for d in $DISTROS; do - echo "distro $d:" - echo " codename ${DISTRO_CODENAME[$d]}" - echo " arches ${DISTRO_ARCHES[$d]}" - echo " repos ${DISTRO_REPOS[$d]}" + debug "distro $d:" + debug " codename ${DISTRO_CODENAME[$d]}" + debug " arches ${DISTRO_ARCHES[$d]}" + debug " repos ${DISTRO_REPOS[$d]}" for a in ${DISTRO_ARCHES[$d]}; do - echo " arch $a:" - echo " base repo: $(distro_base_repo $d $a)" - echo " base mirror: $(distro_base_mirror $d $a)" - echo " base components: $(distro_base_components $d $a)" + debug " arch $a:" + debug " base repo: $(distro_base_repo $d $a)" + debug " base mirror: $(distro_base_mirror $d $a)" + debug " base components: $(distro_base_components $d $a)" repos= for r in ${DISTRO_REPOS[$d]}; do if repo_has_arch $r $a; then repos+=" $r" fi done - echo " repos: $repos" + debug " repos: $repos" done done for r in $REPOS; do - echo "repo $r:" - echo " mirror ${REPO_MIRROR[$r]}" - echo " components ${REPO_COMPONENTS[$r]}" - echo " arches ${REPO_ARCHES[$r]}" - echo " key ${REPO_KEY[$r]:-(none)}" + debug "repo $r:" + debug " mirror ${REPO_MIRROR[$r]}" + debug " components ${REPO_COMPONENTS[$r]}" + debug " arches ${REPO_ARCHES[$r]}" + debug " key ${REPO_KEY[$r]:-(none)}" done } diff --git a/scripts/init-cli.sh b/scripts/init-cli.sh index f195698..ec1f8e1 100644 --- a/scripts/init-cli.sh +++ b/scripts/init-cli.sh @@ -188,26 +188,24 @@ debug "Sourcing include scripts" . $SCRIPTS_DIR/docker.sh . $SCRIPTS_DIR/sbuild.sh . $SCRIPTS_DIR/distro.sh -. $SCRIPTS_DIR/debian-source-package.sh -. $SCRIPTS_DIR/debian-binary-package.sh +. $SCRIPTS_DIR/debian-package.sh . $SCRIPTS_DIR/debian-pkg-repo.sh # Source distro, repo and package configs distro_read_all_configs repo_read_all_configs -NATIVE_BUILD_ONLY=false -if test -n "$PACKAGE"; then - debug " Sourcing config for package '$PACKAGE'" - . $PACKAGE_CONFIG_DIR/$PACKAGE.sh -fi +package_read_all_configs + # Source optional config override file if test -f $BASE_DIR/local-config.sh; then debug " Sourcing local config" . $BASE_DIR/local-config.sh fi -# Print distro debug info -#distro_debug +# Print config debug info +# distro_debug +# package_debug +# exit 1 # Debug ! $DDEBUG || set -x @@ -216,36 +214,3 @@ fi if $IN_DOCKER && ! $IN_SCHROOT; then docker_set_user fi - - -# Package sanity checks -if test -n "$PACKAGE"; then - if mode BUILD_SOURCE_PACKAGE BUILD_PACKAGE BUILD_APT_REPO; then - # Be sure package is valid for distro - DISTRO_PKG_OK=false - for p in ${DISTRO_PACKAGES[$DISTRO]}; do - if test $p = $PACKAGE; then - DISTRO_PKG_OK=true - break - fi - done - $DISTRO_PKG_OK || error "Package $PACKAGE excluded from distro $DISTRO" - fi - - if mode BUILD_PACKAGE BUILD_APT_REPO; then - # Be sure package is valid for arch - for a in $EXCLUDE_ARCHES; do - if test $a = $HOST_ARCH; then - error "Package $PACKAGE excluded from arch $HOST_ARCH" - fi - done - fi -fi - - -# Proxy -if test -n "$HTTP_PROXY"; then - debug " Setting proxy: $HTTP_PROXY" - export http_proxy="$HTTP_PROXY" - export https_proxy="$HTTP_PROXY" -fi diff --git a/scripts/package/czmq.sh b/scripts/package/czmq.sh index 2bf4d49..c5c24b5 100644 --- a/scripts/package/czmq.sh +++ b/scripts/package/czmq.sh @@ -1,4 +1,6 @@ -VERSION=2.2.0 -TARBALL_URL=http://download.zeromq.org/czmq-${VERSION}.tar.gz -GIT_URL=https://github.com/zultron/czmq-deb.git -DEBIAN_PACKAGE_COMP=gz +PKG="czmq" +VERSION="2.2.0" + +# Package sources +PACKAGE_TARBALL_URL[$PKG]="http://download.zeromq.org/czmq-${VERSION}.tar.gz" +PACKAGE_DEBZN_GIT_URL[$PKG]="https://github.com/zultron/czmq-deb.git" diff --git a/scripts/package/dovetail-automata-keyring.sh b/scripts/package/dovetail-automata-keyring.sh index 76eced2..ba6eac6 100644 --- a/scripts/package/dovetail-automata-keyring.sh +++ b/scripts/package/dovetail-automata-keyring.sh @@ -1,3 +1,6 @@ -GIT_URL=https://github.com/zultron/dovetail-automata-keyring-deb.git -DEBIAN_PACKAGE_FORMAT='3.0 (native)' -DEBIAN_PACKAGE_COMP=gz +PKG="dovetail-automata-keyring" +GIT_BASEURL="https://github.com/zultron" + +# Package sources +PACKAGE_DEBZN_GIT_URL[$PKG]="$GIT_BASEURL/$PKG-deb.git" +PACKAGE_FORMAT[$PKG]="3.0 (native)" diff --git a/scripts/package/linux-latest.sh b/scripts/package/linux-latest.sh index d04f251..24a56df 100644 --- a/scripts/package/linux-latest.sh +++ b/scripts/package/linux-latest.sh @@ -1,12 +1,19 @@ -GIT_URL=https://github.com/zultron/linux-latest-deb.git -DEBIAN_PACKAGE_FORMAT='3.0 (native)' -DEBIAN_PACKAGE_COMP=xz -SBUILD_RESOLVER=aptitude # Default 'apt' resolver chokes on linux-support-3.8-1 -GIT_BRANCH=3.8.13 +PKG="linux-latest" -CONFIGURE_PACKAGE_DEPS="python debhelper linux-support-3.8-1" +# Package sources +PACKAGE_DEBZN_GIT_URL[$PKG]="https://github.com/zultron/linux-latest-deb.git" +PACKAGE_DEBZN_GIT_BRANCH[$PKG]="3.8.13" +PACKAGE_FORMAT[$PKG]='3.0 (native)' -configure_package() { +# Build params +# Default 'apt' resolver chokes on linux-support-3.8-1 +PACKAGE_SBUILD_RESOLVER[$PKG]="aptitude" + +# Source package configuration +PACKAGE_CONFIGURE_DEPS[$PKG]="python debhelper linux-support-3.8-1" +PACKAGE_CONFIGURE_FUNC[$PKG]="configure_linux_latest" + +configure_linux_latest() { debian/rules debian/control || true # always fails debian/rules clean } diff --git a/scripts/package/linux-tools.sh b/scripts/package/linux-tools.sh index 861a413..476208a 100644 --- a/scripts/package/linux-tools.sh +++ b/scripts/package/linux-tools.sh @@ -1,14 +1,21 @@ -VERSION=3.8.13 -TARBALL_URL=http://www.kernel.org/pub/linux/kernel/v3.0/linux-${VERSION}.tar.xz -GIT_URL=https://github.com/zultron/linux-tools-deb.git -DEBIAN_PACKAGE_COMP=xz -# 'apt' resolver chokes on libperl-dev:armhf -> perl:armhf -# 'aptitude' resolver installs a bunch of amd64-arch pkgs -NATIVE_BUILD_ONLY=true +PKG="linux-tools" +VERSION="3.8.13" +BASEURL="http://www.kernel.org/pub/linux/kernel/v3.0" -CONFIGURE_PACKAGE_DEPS="python debhelper" +# Package sources +PACKAGE_TARBALL_URL[$PKG]="$BASEURL/linux-${VERSION}.tar.xz" +PACKAGE_DEBZN_GIT_URL[$PKG]="https://github.com/zultron/linux-tools-deb.git" -configure_package() { +# Build params +# 'apt' resolver chokes on libperl-dev:armhf -> perl:armhf +# 'aptitude' resolver installs a bunch of amd64-arch pkgs +PACKAGE_NATIVE_BUILD_ONLY[$PKG]="true" + +# Source package configuration +PACKAGE_CONFIGURE_DEPS[$PKG]="python debhelper" +PACKAGE_CONFIGURE_FUNC[$PKG]="configure_linux_tools" + +configure_linux_tools() { debian/rules debian/control || true # always fails debian/rules clean } diff --git a/scripts/package/linux.sh b/scripts/package/linux.sh index 39028fb..2fe22db 100644 --- a/scripts/package/linux.sh +++ b/scripts/package/linux.sh @@ -1,29 +1,33 @@ -VERSION=3.8.13 -TARBALL_URL=http://www.kernel.org/pub/linux/kernel/v3.0/linux-${VERSION}.tar.xz -GIT_URL=https://github.com/zultron/linux-ipipe-deb.git -GIT_BRANCH=${VERSION} -DEBIAN_PACKAGE_COMP=xz -NATIVE_BUILD_ONLY=true # Build-Depends: gcc-4.9 +PKG="linux" +VERSION="3.8.13" +BASEURL="http://www.kernel.org/pub/linux/kernel/v3.0" -FEATURESETS="xenomai rtai" -DISABLED_FEATURESETS="" # Set to 'xenomai' or 'rtai' to skip build +# Disable 'xenomai' or 'rtai' build +LINUX_DISABLED_FEATURESETS="" -CONFIGURE_PACKAGE_DEPS=python -# Add xenomai-kernel-source if not disabled -DISABLED_FEATURESETS=" $DISABLED_FEATURESETS " -test "${DISABLED_FEATURESETS/xenomai/}" != "$DISABLED_FEATURESETS" || \ -CONFIGURE_PACKAGE_DEPS+=" xenomai-kernel-source" -# Add rtai-source if not disabled -DISABLED_FEATURESETS=" $DISABLED_FEATURESETS " -test "${DISABLED_FEATURESETS/rtai/}" != "$DISABLED_FEATURESETS" || \ -CONFIGURE_PACKAGE_DEPS+=" rtai-source" +# Package sources +PACKAGE_TARBALL_URL[$PKG]="$BASEURL/linux-${VERSION}.tar.xz" +PACKAGE_DEBZN_GIT_URL[$PKG]="https://github.com/zultron/linux-ipipe-deb.git" +PACKAGE_DEBZN_GIT_BRANCH[$PKG]="${VERSION}" -configure_package() { +# Build params +PACKAGE_NATIVE_BUILD_ONLY[$PKG]="true" # Build-Depends: gcc-4.9 + +# Source package configuration +PACKAGE_CONFIGURE_DEPS[$PKG]="python" +# Install Xenomai and RTAI source packages, if applicable +case " ${LINUX_DISABLED_FEATURESETS} " in + "* xenomai *") PACKAGE_CONFIGURE_DEPS[$PKG]+=" xenomai-kernel-source" ;; + "* rtai *") PACKAGE_CONFIGURE_DEPS[$PKG]+=" rtai-source" ;; +esac +PACKAGE_CONFIGURE_FUNC[$PKG]="configure_linux" + +configure_linux() { if test $DISTRO = trusty; then debug " Setting gcc to 'gcc-4.8'" sed -ie '/^compiler:/ s/gcc-.*/gcc-4.8/' debian/config/defines fi - for featureset in $DISABLED_FEATURESETS; do + for featureset in $LINUX_DISABLED_FEATURESETS; do debug " Disabling featureset $featureset" sed -i 's/^\( *'$featureset'$\)/#\1/' debian/config/defines done diff --git a/scripts/package/python-pyftpdlib.sh b/scripts/package/python-pyftpdlib.sh index 9fead25..f5bb0ff 100644 --- a/scripts/package/python-pyftpdlib.sh +++ b/scripts/package/python-pyftpdlib.sh @@ -1,4 +1,8 @@ -VERSION=1.2.0 -TARBALL_URL=https://github.com/giampaolo/pyftpdlib/archive/release-$VERSION.tar.gz -GIT_URL=https://github.com/zultron/python-pyftpdlib-deb.git -DEBIAN_PACKAGE_COMP=gz +PKG="python-pyftpdlib" +VERSION="1.2.0" +BASEURL="https://github.com/giampaolo/pyftpdlib/archive" +GIT_BASEURL="https://github.com/zultron" + +# Package sources +PACKAGE_TARBALL_URL[$PKG]="$BASEURL/release-$VERSION.tar.gz" +PACKAGE_DEBZN_GIT_URL[$PKG]="$GIT_BASEURL/python-pyftpdlib-deb.git" diff --git a/scripts/package/pyzmq.sh b/scripts/package/pyzmq.sh index 4d0af1c..88251fa 100644 --- a/scripts/package/pyzmq.sh +++ b/scripts/package/pyzmq.sh @@ -1,10 +1,15 @@ -VERSION=14.3.0 -TARBALL_URL=https://github.com/zeromq/pyzmq/archive/v${VERSION}.tar.gz -GIT_URL=https://github.com/zultron/pyzmq-deb.git -DEBIAN_PACKAGE_COMP=gz -# 'apt' resolver: 'Build-Depends dependency for -# sbuild-build-depends-pyzmq-dummy cannot be satisfied because the -# package python-nose cannot be found' -# 'aptitude' resolver installs a bunch of amd64 pkgs -# 'xapt' unavailable in Jessie -NATIVE_BUILD_ONLY=true +PKG="pyzmq" +VERSION="14.3.0" +BASEURL="https://github.com/zeromq/pyzmq/archive" + +# Package sources +PACKAGE_TARBALL_URL[$PKG]="$BASEURL/v${VERSION}.tar.gz" +PACKAGE_DEBZN_GIT_URL[$PKG]="https://github.com/zultron/pyzmq-deb.git" + +# Build params +# 'apt' resolver: 'Build-Depends dependency for +# sbuild-build-depends-pyzmq-dummy cannot be satisfied because the +# package python-nose cannot be found' +# 'aptitude' resolver installs a bunch of amd64 pkgs +# 'xapt' unavailable in Jessie +PACKAGE_NATIVE_BUILD_ONLY[$PKG]="true" diff --git a/scripts/package/rtai.sh b/scripts/package/rtai.sh index 7bced1c..77cbeb8 100644 --- a/scripts/package/rtai.sh +++ b/scripts/package/rtai.sh @@ -1,6 +1,10 @@ -GIT_REV=a416758 -TARBALL_URL=https://github.com/ShabbyX/RTAI/archive/${GIT_REV}.tar.gz -GIT_URL=https://github.com/zultron/rtai-deb.git -GIT_REPO=rtai-deb -DEBIAN_PACKAGE_COMP=gz -EXCLUDE_ARCHES=armhf +PKG="rtai" +GIT_REV="a416758" +GIT_BASEURL="https://github.com/ShabbyX/RTAI/archive" + +# Package sources +PACKAGE_TARBALL_URL[$PKG]="$GIT_BASEURL/${GIT_REV}.tar.gz" +PACKAGE_DEBZN_GIT_URL[$PKG]="https://github.com/zultron/rtai-deb.git" + +# Build params +PACKAGE_EXCLUDE_ARCHES[$PKG]="armhf" diff --git a/scripts/package/template.sh b/scripts/package/template.sh new file mode 100644 index 0000000..690bfc3 --- /dev/null +++ b/scripts/package/template.sh @@ -0,0 +1,37 @@ +# Example package configuration with all params + +# Convenience variables only used in this file +PKG="mypkg" # Name of source package + +# Package sources +# +# These parameters describe the package sources. The only mandatory +# ones are the tarball url and/or the debianization url. + +PACKAGE_TARBALL_URL[$PKG]="http://www.example.com/mypkg-1.0.tar.gz" +PACKAGE_DEBZN_GIT_URL[$PKG]="https://github.com/octocat/mypkg-deb.git" +#PACKAGE_DEBZN_GIT_BRANCH[$PKG]="maint" # Default "master" +#PACKAGE_COMP[$PKG]="gz" # Default: guess from tarball +#PACKAGE_FORMAT[$PKG]="3.0 (native)" # Default "3.0 (quilt)" + +# Build params +# +# These optional parameters affect when and how the package is built + +#PACKAGE_SBUILD_RESOLVER[$PKG]="aptitude" # See sbuild(1) +#PACKAGE_NATIVE_BUILD_ONLY[$PKG]="true" # Cross-compile broken; use qemu +#PACKAGE_EXCLUDE_ARCHES[$PKG]="armhf" # Don't build these arches + +# Source package configuration +# +# Some packages need an extra configuration step before building the +# source package from the debianized source tree. These configure a +# function that will be run in the distro schroot, along with needed +# package deps. + +#PACKAGE_CONFIGURE_DEPS[$PKG]="python" # Required +#PACKAGE_CONFIGURE_FUNC[$PKG]="configure_mypkg" # Below function + +#configure_mypkg() { +# do_something +#} diff --git a/scripts/package/xenomai.sh b/scripts/package/xenomai.sh index d32bd03..1a8fab0 100644 --- a/scripts/package/xenomai.sh +++ b/scripts/package/xenomai.sh @@ -1,4 +1,7 @@ -VERSION=2.6.4 -TARBALL_URL=http://download.gna.org/xenomai/stable/xenomai-$VERSION.tar.bz2 -GIT_URL=https://github.com/zultron/xenomai-deb.git -DEBIAN_PACKAGE_COMP=bz2 +PKG="xenomai" +BASEURL="http://download.gna.org/xenomai/stable" +PACKAGE_VERSION="2.6.4" + +# Package sources +PACKAGE_TARBALL_URL[$PKG]="$BASEURL/xenomai-$VERSION.tar.bz2" +PACKAGE_DEBZN_GIT_URL[$PKG]="https://github.com/zultron/xenomai-deb.git" diff --git a/scripts/sbuild.sh b/scripts/sbuild.sh index 4a5c4d6..0687e30 100644 --- a/scripts/sbuild.sh +++ b/scripts/sbuild.sh @@ -2,7 +2,7 @@ debug " Sourcing sbuild.sh" sbuild_chroot_init() { # By default, only build arch-indep packages on build arch - if arch_is_foreign $DISTRO $HOST_ARCH || $FORCE_INDEP; then + if test $HOST_ARCH = $(arch_default $DISTRO) || $FORCE_INDEP; then BUILD_INDEP="--arch-all" else BUILD_INDEP="--no-arch-all" @@ -18,6 +18,19 @@ sbuild_chroot_init() { BUILD_SCHROOT_SETUP_ONLY=--setup-only fi + if test -n "$PACKAGE" && test -n "${PACKAGE_SBUILD_RESOLVER[$PACKAGE]}" + then + local r=${PACKAGE_SBUILD_RESOLVER[$PACKAGE]} + debug " Using sbuild resolver $r" + SBUILD_RESOLVER_ARG=--build-dep-resolver=$r + fi + + if test $HOST_ARCH = i386; then + SCHROOT_PERSONALITY=linux32 + else + SCHROOT_PERSONALITY=linux + fi + # sbuild verbosity if $DEBUG; then SBUILD_VERBOSE=--verbose @@ -79,38 +92,17 @@ sbuild_install_keys() { } sbuild_install_config() { - if test -f $CONFIG_DIR/chroot.d/$SBUILD_CHROOT; then - debug " Installing saved schroot config $SBUILD_CHROOT" - run cp $CONFIG_DIR/chroot.d/$SBUILD_CHROOT /etc/schroot/chroot.d - debug " Contents of /etc/schroot/chroot.d/$SBUILD_CHROOT:" - run_debug cat /etc/schroot/chroot.d/$SBUILD_CHROOT - else - debug " (No saved config for $SBUILD_CHROOT)" - fi -} - -sbuild_save_config() { - SBUILD_CHROOT=$DISTRO-$SBUILD_CHROOT_ARCH-sbuild - SBUILD_CHROOT_GEN=$(readlink -e \ - /etc/schroot/chroot.d/${DISTRO_CODENAME[$DISTRO]}-$SBUILD_CHROOT_ARCH-sbuild-* || true) - if test -n "$SBUILD_CHROOT_GEN"; then - debug " Saving generated schroot config from Docker" - run_user mkdir -p $CONFIG_DIR/chroot.d - run_user cp $SBUILD_CHROOT_GEN \ - $CONFIG_DIR/chroot.d/$SBUILD_CHROOT - - if test $DISTRO != ${DISTRO_CODENAME[$DISTRO]}; then - debug " Patching schroot config name" - run sed -i $CONFIG_DIR/chroot.d/$SBUILD_CHROOT \ - -e '1 s/.*/[raspbian-jessie-amd64-sbuild]/' - fi + local BUILD_ARCH=$(arch_build $DISTRO $HOST_ARCH) + debug " Installing schroot config: $DISTRO-$BUILD_ARCH" - debug " Chroot config:" - run_debug cat $CONFIG_DIR/chroot.d/$SBUILD_CHROOT + run bash -c "sed $SCRIPTS_DIR/schroot.conf \\ + -e 's/@DISTRO@/$DISTRO/g' \\ + -e 's/@BUILD_ARCH@/$BUILD_ARCH/g' \\ + -e 's/@SCHROOT_PERSONALITY@/$SCHROOT_PERSONALITY/g' \\ + > /etc/schroot/chroot.d/$SBUILD_CHROOT" - else - debug " (No new schroot config found in /etc/schroot/chroot.d)" - fi + debug " Contents of /etc/schroot/chroot.d/$SBUILD_CHROOT:" + run_debug cat /etc/schroot/chroot.d/$SBUILD_CHROOT } sbuild_chroot_setup() { @@ -121,8 +113,9 @@ sbuild_chroot_setup() { sbuild_install_sbuild_conf sbuild_install_keys - # Clean out any existing apt config + # Clean out any existing apt config and set http proxy distro_clear_apt + distro_set_apt_proxy if arch_is_foreign $DISTRO $HOST_ARCH && test $BUILD_ARCH=armhf; then debug " Pre-seeding chroot with qemu-arm-static binary" @@ -139,9 +132,6 @@ sbuild_chroot_setup() { ${DISTRO_CODENAME[$DISTRO]} $CHROOT_DIR \ $(distro_base_mirror $DISTRO $BUILD_ARCH) - # Save generated sbuild config from Docker - sbuild_save_config - # Set up apt configuration distro_configure_apt $DISTRO @@ -157,26 +147,32 @@ sbuild_configure_package() { # FIXME run with union-type=aufs in schroot.conf - debug " Installing extra packages in schroot:" - debug " $CONFIGURE_PACKAGE_DEPS" + if test -z "${PACKAGE_CONFIGURE_DEPS[$PACKAGE]}"; then + debug " (No source pkg configure deps to install)" + return + fi + + debug " Installing source package configure deps in schroot:" + debug " ${PACKAGE_CONFIGURE_DEPS[$PACKAGE]}" run schroot -c $SBUILD_CHROOT $SBUILD_VERBOSE -- \ apt-get update run schroot -c $SBUILD_CHROOT $SBUILD_VERBOSE -- \ apt-get install --no-install-recommends -y \ - $CONFIGURE_PACKAGE_DEPS + ${PACKAGE_CONFIGURE_DEPS[$PACKAGE]} debug " Running configure function in schroot" run schroot -u user -c $SBUILD_CHROOT $SBUILD_VERBOSE -- \ ./$DBUILD -C $(! $DEBUG || echo -d) $DISTRO $PACKAGE - debug " Uninstalling extra packages" + debug " Removing source package configure deps" run schroot -c $SBUILD_CHROOT $SBUILD_VERBOSE -- \ apt-get purge -y --auto-remove \ - $CONFIGURE_PACKAGE_DEPS + ${PACKAGE_CONFIGURE_DEPS[$PACKAGE]} } sbuild_build_package() { local BUILD_ARCH=$(arch_build $DISTRO $HOST_ARCH) + local HOST_ARCH=$(arch_host $DISTRO $HOST_ARCH) debug " Build dir: $BUILD_DIR" debug " Source package .dsc file: $DSC_FILE" @@ -197,7 +193,7 @@ sbuild_build_package() { -d ${DISTRO_CODENAME[$DISTRO]} $BUILD_INDEP $SBUILD_VERBOSE \ $SBUILD_DEBUG $NUM_JOBS \ -c $SBUILD_CHROOT \ - ${SBUILD_RESOLVER:+--build-dep-resolver=$SBUILD_RESOLVER} \ + $SBUILD_RESOLVER_ARG \ $DSC_FILE ) } diff --git a/scripts/schroot.conf b/scripts/schroot.conf new file mode 100644 index 0000000..8a99ff6 --- /dev/null +++ b/scripts/schroot.conf @@ -0,0 +1,8 @@ +[@DISTRO@-@BUILD_ARCH@-sbuild] +type=directory +description=@DISTRO@/@BUILD_ARCH@ autobuilder +directory=/srv/chroots/@DISTRO@-@BUILD_ARCH@ +groups=root,sbuild +root-groups=root,sbuild +profile=sbuild +personality=@SCHROOT_PERSONALITY@