From 2cff8041dce4d6f3628eeb49333cb3ed37bac36a Mon Sep 17 00:00:00 2001 From: William Petit Date: Wed, 23 Sep 2015 21:21:30 +0200 Subject: [PATCH] Build quilt packages --- ...-prebuild => 00-create-changelog-prebuild} | 25 +++++++++++++++---- hooks/00-detect-debian-format-prebuild | 15 +++++++++++ ...uild => 00-install-build-depends-prebuild} | 2 +- ...ebuild => 01-create-orig-archive-prebuild} | 6 +++-- ...ist-postbuild => 99-export-dist-postbuild} | 0 hooks/{00-git => }/install-git-containerbuild | 2 +- lib/util.sh | 7 +++--- package.sh | 4 +-- 8 files changed, 47 insertions(+), 14 deletions(-) rename hooks/{00-git/create-changelog-prebuild => 00-create-changelog-prebuild} (72%) create mode 100755 hooks/00-detect-debian-format-prebuild rename hooks/{01-debian/install-build-depends-prebuild => 00-install-build-depends-prebuild} (54%) rename hooks/{01-debian/create-orig-archive-prebuild => 01-create-orig-archive-prebuild} (52%) rename hooks/{02-tamarin/export-dist-postbuild => 99-export-dist-postbuild} (100%) rename hooks/{00-git => }/install-git-containerbuild (72%) diff --git a/hooks/00-git/create-changelog-prebuild b/hooks/00-create-changelog-prebuild similarity index 72% rename from hooks/00-git/create-changelog-prebuild rename to hooks/00-create-changelog-prebuild index e5a8c11..b60404e 100755 --- a/hooks/00-git/create-changelog-prebuild +++ b/hooks/00-create-changelog-prebuild @@ -22,7 +22,7 @@ else tagbranch="build-tag-${BUILD_TAG}" git checkout -b ${tagbranch} set_opt "tag_branch" "${tag_branch}" - tags="${BUILD_TAG}" + local tags="${BUILD_TAG}" fi if [[ -z ${tags} ]] @@ -44,16 +44,31 @@ do project_name=$(get_opt project_name) version=${tag#*/} #$(get_opt version 0.0.0) version=${version/_/-} #$(get_opt version 0.0.0) + distribution=$(get_opt distribution UNRELEASED) urgency=$(get_opt urgency low) commit_count=$(git rev-list --count --first-parent HEAD) current_commit=$(git log -n 1 --pretty=format:"%h") - version_suffix=${commit_count}~${current_commit} + version_suffix=tamarin${commit_count}~${current_commit} + package_version=${version}-${version_suffix} - package_version=${version}.tamarin${version_suffix} - # Share computed package version - set_opt package_version ${package_version} + # Define package_version opt if not defined + if [ -z "$(get_opt package_version)" ]; then + # Share computed package version + set_opt package_version "${package_version}" + fi + + # Define project_version opt if not defined + if [ -z "$(get_opt project_version)" ]; then + # Share computed package version + set_opt project_version "${version}" + fi + + # Native packages should not have a revision number + if [ $(get_opt package_format) == 'native' ]; then + package_version=$(echo ${version} | grep -oE '^[0-9.]+') + fi echo "${project_name} (${package_version}) ${distribution}; urgency=${urgency}" >> debian/changelog diff --git a/hooks/00-detect-debian-format-prebuild b/hooks/00-detect-debian-format-prebuild new file mode 100755 index 0000000..880b10d --- /dev/null +++ b/hooks/00-detect-debian-format-prebuild @@ -0,0 +1,15 @@ +#!/bin/bash + +source "${TAMARIN_UTIL}" + +if [ -f "debian/source/format" ]; then + format=$(cat debian/source/format) + case ${format} in + "3.0 (native)") + set_opt package_format "native" + ;; + "3.0 (quilt)") + set_opt package_format "quilt" + ;; + esac +fi diff --git a/hooks/01-debian/install-build-depends-prebuild b/hooks/00-install-build-depends-prebuild similarity index 54% rename from hooks/01-debian/install-build-depends-prebuild rename to hooks/00-install-build-depends-prebuild index 8b6fe2d..8864ee6 100755 --- a/hooks/01-debian/install-build-depends-prebuild +++ b/hooks/00-install-build-depends-prebuild @@ -4,5 +4,5 @@ source "${TAMARIN_UTIL}" if [ -f debian/control ]; then info "Installing build dependencies..." - mk-build-deps -t "apt-get --force-yes -y" --install debian/control + mk-build-deps -r -t "apt-get --force-yes -y --no-install-recommends" --install debian/control fi diff --git a/hooks/01-debian/create-orig-archive-prebuild b/hooks/01-create-orig-archive-prebuild similarity index 52% rename from hooks/01-debian/create-orig-archive-prebuild rename to hooks/01-create-orig-archive-prebuild index 91a8633..48bdd0a 100755 --- a/hooks/01-debian/create-orig-archive-prebuild +++ b/hooks/01-create-orig-archive-prebuild @@ -1,9 +1,11 @@ -#!/bin/bash +#!/usr/bin/env bash source "${TAMARIN_UTIL}" project_name=$(get_opt project_name) -src_tarball="../${project_name}_${package_version}.orig.tar.gz" +project_version=$(get_opt project_version) + +src_tarball="../${project_name}_${project_version}.orig.tar.gz" info "Creating sources tarball ${src_tarball}" diff --git a/hooks/02-tamarin/export-dist-postbuild b/hooks/99-export-dist-postbuild similarity index 100% rename from hooks/02-tamarin/export-dist-postbuild rename to hooks/99-export-dist-postbuild diff --git a/hooks/00-git/install-git-containerbuild b/hooks/install-git-containerbuild similarity index 72% rename from hooks/00-git/install-git-containerbuild rename to hooks/install-git-containerbuild index 223f1d8..585549f 100755 --- a/hooks/00-git/install-git-containerbuild +++ b/hooks/install-git-containerbuild @@ -1,3 +1,3 @@ #!/usr/bin/env bash -echo "RUN apt-get install --yes --no-install-recommends git-core git-buildpackage" >> Dockerfile +echo "RUN apt-get install --yes --no-install-recommends git-core" >> Dockerfile diff --git a/lib/util.sh b/lib/util.sh index cb404e2..9faca65 100644 --- a/lib/util.sh +++ b/lib/util.sh @@ -2,6 +2,7 @@ HOOKS_DIR="${BASE_DIR}/hooks" OPT_FILE="${BASE_DIR}/tmp/.tamarin_opts" +OPT_PREFIX="tamarin_opt_" function info { if [ -z "$@" ]; then @@ -50,7 +51,7 @@ function log { } function get_opt { - local opt_name=${1} + local opt_name=${OPT_PREFIX}${1} local default_value=${2} touch "${OPT_FILE}" source "${OPT_FILE}" @@ -61,8 +62,8 @@ function set_opt { local opt_name=${1} local opt_value=${2} touch "${OPT_FILE}" - sed -i "s/^${opt_name}*$//" "${OPT_FILE}" - echo "${opt_name}=\"${opt_value}\"" >> "${OPT_FILE}" + sed -i "s/^${OPT_PREFIX}${opt_name}*$//" "${OPT_FILE}" + echo "${OPT_PREFIX}${opt_name}=\"${opt_value}\"" >> "${OPT_FILE}" } function exec_hooks { diff --git a/package.sh b/package.sh index ec09d45..5b503ac 100755 --- a/package.sh +++ b/package.sh @@ -60,6 +60,8 @@ function create_container { VOLUME /dist EOF + exec_hooks "containerbuild" "$temp_dir" + if [[ -z ${BUILD_DIR} ]] then echo " CMD /root/.tamarin/lib/build.sh ${projectName} ${BUILD_BRANCH} /tmp ${BUILD_TAG}" >> "$temp_dir/Dockerfile" @@ -68,8 +70,6 @@ EOF echo " CMD /root/.tamarin/lib/build.sh ${projectName} ${BUILD_BRANCH} /build ${BUILD_TAG}" >> "$temp_dir/Dockerfile" fi - exec_hooks "containerbuild" "$temp_dir" - # Build image tar -C "$temp_dir" -czh . | docker build -t "$container_tag" - 2> >(error) 1> >(info)