Skip to content

Commit

Permalink
Add suffix to package version
Browse files Browse the repository at this point in the history
Add a suffix to package version; by default, e.g.
`~1jessie~1mk.dbuild`. This allows distribution packagers to give
unique versions to their packages, as well as combine packages for
different upstream distros into one `pool` directory (fixes #6).

- Build new changelog entry for source packages
  - Read upstream version from `changelog` file (fixes #8)
    - Remove `$RELEASE` from pkg configs
  - Add default suffix `~1mk.dbuild` to packages
- Unpack debianization first in order to get data from changelog early
- Set default pkg format to reduce verbosity

- Merge files formerly separated along upstream distro lines
  - `build/PACKAGE` dir; `repo/pool` dir

Also:
- Misc bug fixes
- Install `sbuild.conf` from template (will address issues in #9)
  • Loading branch information
zultron committed Apr 9, 2015
1 parent 31b7d5a commit 0115487
Show file tree
Hide file tree
Showing 17 changed files with 799 additions and 47 deletions.
6 changes: 4 additions & 2 deletions scripts/base-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ SOURCE_PKG_DIR=$BUILD_BASE_DIR
DEBZN_GIT_DIR=$BUILD_BASE_DIR/debzn-git

# Build directory for a distro codename
BUILD_DIR=$BUILD_BASE_DIR/$CODENAME
BUILD_DIR=$BUILD_BASE_DIR

# Where sources are built
BUILD_SRC_DIR=$BUILD_DIR/tree
BUILD_SRC_DIR=$BUILD_DIR/tree-$CODENAME

# Where the Apt package repo is built
REPO_DIR=repo
Expand Down Expand Up @@ -59,6 +59,8 @@ SCRIPTS_DIR=scripts
DISTRO_CONFIG_DIR=$SCRIPTS_DIR/distro
PACKAGE_CONFIG_DIR=$SCRIPTS_DIR/package

# Suffix for package version
PACKAGE_VERSION_SUFFIX=~1mk.dbuild

# TCL default version; override in distro config
TCL_VER=8.6
Expand Down
7 changes: 1 addition & 6 deletions scripts/debian-binary-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@ debug " Sourcing debian-binary-package.sh"
#
# These routines handle building the package.

binary_package_init() {
test -n "$DSC_FILE" || \
DSC_FILE=${PACKAGE}_${VERSION}${RELEASE:+-$RELEASE}.dsc
}

binary_package_build() {
msg "Building binary package '$PACKAGE'"
binary_package_init
source_package_init
sbuild_build_package
}

68 changes: 65 additions & 3 deletions scripts/debian-debzn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,40 @@
# Debianization git tree operations
debug " Sourcing debian-debzn.sh"

parse_changelog() {
dpkg-parsechangelog --file $BUILD_DIR/changelog.orig --show-field $1
}

debianization_init() {
test -z "$PACKAGE_VERSION" || return

PACKAGE_VERSION=$(parse_changelog version)
debug " Upstream package version-release: $PACKAGE_VERSION"
PACKAGE_VER=$(echo $PACKAGE_VERSION | sed 's/\(.*\)-.*/\1/')
debug " Package version: $PACKAGE_VER"
PACKAGE_RELEASE=$(echo $PACKAGE_VERSION | \
sed -e 's/^\([^-]*\)$/\1-/' -e 's/[^-]*-//')
debug " Upstream package release: $PACKAGE_RELEASE"
PACKAGE_DISTRIBUTION=$(parse_changelog distribution)
debug " Package distribution: $PACKAGE_DISTRIBUTION"
PACKAGE_URGENCY=$(parse_changelog urgency)
debug " Package urgency: $PACKAGE_URGENCY"
PACKAGE_NEW_VERSION_SUFFIX="~1${CODENAME}${PACKAGE_VERSION_SUFFIX}"
PACKAGE_NEW_VERSION="${PACKAGE_VERSION}${PACKAGE_NEW_VERSION_SUFFIX}"
debug " New package version-release: $PACKAGE_NEW_VERSION"
DSC_FILE=${PACKAGE}_${PACKAGE_NEW_VERSION}.dsc
debug " .dsc file name: $DSC_FILE"
CHANGELOG=/tmp/changelog-$PACKAGE-$CODENAME

if test -z "$MAINTAINER"; then
MAINTAINER="$(git config user.name)" || MAINTAINER="mk-dbuild user"
fi
if test -z "$EMAIL"; then
EMAIL="$(git config user.email)" || EMAIL="[email protected]"
fi
debug " Maintainer <email>: $MAINTAINER <$EMAIL>"
}

debianization_git_tree_update() {
if test -z "$GIT_URL"; then
debug " (No GIT_URL defined; not handling debianization git tree)"
Expand All @@ -22,6 +56,35 @@ debianization_git_tree_update() {
run_user git --git-dir=$DEBZN_GIT_DIR/.git --work-tree=$DEBZN_GIT_DIR \
pull --ff-only dbuild ${GIT_BRANCH:-master}
fi

debug " Saving original changelog"
run_user cp $DEBZN_GIT_DIR/changelog $BUILD_DIR/changelog.orig
}

debianization_add_changelog() {
# https://www.debian.org/doc/debian-policy/ch-source.html#s-dpkgchangelog
msg " Adding new changelog entry"

# Calculate first line of changelog entry
PACKAGE_CHANGELOG_HEAD="$(echo "${PACKAGE}" "(${PACKAGE_NEW_VERSION})" \
"${PACKAGE_DISTRIBUTION};" "urgency=${PACKAGE_URGENCY}")"

# Calculate trailer line of changelog entry
PACKAGE_CHANGELOG_TRAILER=" -- $MAINTAINER <$EMAIL> $(date -R)"

# Write changelog entry
(
echo "$PACKAGE_CHANGELOG_HEAD"
echo " * Rebuilt in mk-debuild"
echo " - See https://github.com/zultron/mk-dbuild"
echo "$PACKAGE_CHANGELOG_TRAILER"
echo
) > $CHANGELOG

debug " Full changelog:"
run_debug cat $CHANGELOG
run bash -c "cat $BUILD_DIR/changelog.orig >> $CHANGELOG"
run_user cp $CHANGELOG $BUILD_SRC_DIR/debian/changelog
}

debianization_git_tree_unpack() {
Expand All @@ -30,10 +93,9 @@ debianization_git_tree_unpack() {
debug " Debzn git dir: $DEBZN_GIT_DIR"
debug " Dest dir: $BUILD_SRC_DIR/debian"
debug " Git branch: ${GIT_BRANCH:-master}"
run_user mkdir -p $BUILD_SRC_DIR/debian
run_user git --git-dir=$DEBZN_GIT_DIR/.git archive \
--prefix=./ ${GIT_BRANCH:-master} | \
run_user tar xCf $BUILD_SRC_DIR/debian -
--prefix=debian/ ${GIT_BRANCH:-master} | \
run_user tar xCf $BUILD_SRC_DIR -
else
debug " (No GIT_URL defined; not unpacking debianization from git)"
fi
Expand Down
12 changes: 3 additions & 9 deletions scripts/debian-orig-tarball.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ source_tarball_init() {
;;
esac

local BASENAME=${PACKAGE}_${PACKAGE_VER}
case "$DEBIAN_PACKAGE_FORMAT" in
'3.0 (quilt)')
DEBIAN_TARBALL=${PACKAGE}_${VERSION}.orig.tar.${DEBIAN_PACKAGE_COMP}
DEBIAN_TARBALL=${BASENAME}.orig.tar.${DEBIAN_PACKAGE_COMP}
;;
'3.0 (native)')
DEBIAN_TARBALL=${PACKAGE}_${VERSION}.tar.${DEBIAN_PACKAGE_COMP}
DEBIAN_TARBALL=${BASENAME}.tar.${DEBIAN_PACKAGE_COMP}
;;
*)
error "Package ${PACKAGE}:" \
Expand Down Expand Up @@ -54,13 +55,6 @@ source_tarball_unpack() {
fi

msg " Unpacking source tarball"
debug " Tarball path: $SOURCE_PKG_DIR/$DEBIAN_TARBALL"
debug " Build dir: $BUILD_DIR"
debug " Linking original tarball to $BUILD_DIR"
run_user mkdir -p $BUILD_DIR
run_user ln -f $SOURCE_PKG_DIR/$DEBIAN_TARBALL $BUILD_DIR
debug " Unpacking tarball into $BUILD_SRC_DIR"
run_user rm -rf $BUILD_SRC_DIR; run_user mkdir -p $BUILD_SRC_DIR
run_user tar xCf $BUILD_SRC_DIR $SOURCE_PKG_DIR/$DEBIAN_TARBALL \
--strip-components=1
}
Expand Down
5 changes: 2 additions & 3 deletions scripts/debian-pkg-repo.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
debug " Sourcing debian-pkg-repo.sh"

deb_repo_init() {
test -z "$SIGNING_KEY" || return
test -z "$SIGNING_KEY" || return 0
REPO_DIR_ABS=$(readlink -f $REPO_DIR)
debug " Apt repo dir: $REPO_DIR_ABS"
debug " GPG key dir: $GNUPGHOME"
Expand All @@ -18,7 +18,6 @@ deb_repo_init() {

REPREPRO="run_user reprepro -VV -b ${REPO_DIR_ABS} \
--confdir +b/conf-${CODENAME} --dbdir +b/db-${CODENAME} \
--outdir +b/${CODENAME} \
--gnupghome $GNUPGHOME"
}

Expand Down Expand Up @@ -49,7 +48,7 @@ deb_repo_build() {
msg "Updating Debian Apt package repository"
deb_repo_init # repo config
deb_repo_setup # set up repo, if needed
binary_package_init # source pkg config
source_package_init # source pkg config

# add source pkg
msg " Removing all packages for '$PACKAGE'"
Expand Down
35 changes: 30 additions & 5 deletions scripts/debian-source-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@ debug " Sourcing debian-source-package.sh"
# Routines for cloning/copying the Debianization files
. $SCRIPTS_DIR/debian-debzn.sh

########################################
# Source package init vars
source_package_init() {
debianization_init # Init vars after unpacking

debug " Package format: ${DEBIAN_PACKAGE_FORMAT:=3.0 (quilt)}"
}

########################################
# Source package setup
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
}

########################################
# Source package configuration

Expand All @@ -30,7 +46,7 @@ source_package_build_from_tree() {
(
cd $BUILD_SRC_DIR
run_user dpkg-source -b \
--format="'${DEBIAN_PACKAGE_FORMAT:-3.0 (quilt)}'" .
--format="'${DEBIAN_PACKAGE_FORMAT}'" .
)
}

Expand All @@ -45,18 +61,27 @@ source_package_cleanup() {
# Source package build
source_package_build() {
msg "Building source package '$PACKAGE'"
# Download source tarball and unpack
source_tarball_init
source_tarball_download
source_tarball_unpack
# Initialize directories
source_package_setup

# Update debianization git tree and copy to source tree
debianization_git_tree_update
debianization_git_tree_unpack

# Init variables
source_package_init

# Download source tarball and unpack
source_tarball_init
source_tarball_download
source_tarball_unpack

# Some packages may define a configuration step
configure_package_wrapper

# Add new changelog
debianization_add_changelog

# Build the source package and clean up
source_package_build_from_tree
source_package_cleanup
Expand Down
2 changes: 0 additions & 2 deletions scripts/package/czmq.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
VERSION=2.2.0
RELEASE=0.4
TARBALL_URL=http://download.zeromq.org/czmq-${VERSION}.tar.gz
GIT_URL=https://github.com/zultron/czmq-deb.git
DEBIAN_PACKAGE_FORMAT='3.0 (quilt)'
DEBIAN_PACKAGE_COMP=gz
2 changes: 0 additions & 2 deletions scripts/package/dovetail-automata-keyring.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
VERSION=0.1
RELEASE=2
GIT_URL=https://github.com/zultron/dovetail-automata-keyring-deb.git
DEBIAN_PACKAGE_FORMAT='3.0 (native)'
DEBIAN_PACKAGE_COMP=gz
1 change: 0 additions & 1 deletion scripts/package/linux-latest.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
VERSION=60
GIT_URL=https://github.com/zultron/linux-latest-deb.git
DEBIAN_PACKAGE_FORMAT='3.0 (native)'
DEBIAN_PACKAGE_COMP=xz
Expand Down
2 changes: 0 additions & 2 deletions scripts/package/linux-tools.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
VERSION=3.8.13
RELEASE=3da
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_FORMAT='3.0 (quilt)'
DEBIAN_PACKAGE_COMP=xz
# 'apt' resolver chokes on libperl-dev:armhf -> perl:armhf
# 'aptitude' resolver installs a bunch of amd64-arch pkgs
Expand Down
4 changes: 1 addition & 3 deletions scripts/package/linux.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
VERSION=3.8.13
RELEASE=11
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=3.8.13
DEBIAN_PACKAGE_FORMAT='3.0 (quilt)'
GIT_BRANCH=${VERSION}
DEBIAN_PACKAGE_COMP=xz
NATIVE_BUILD_ONLY=true # Build-Depends: gcc-4.9

Expand Down
2 changes: 0 additions & 2 deletions scripts/package/python-pyftpdlib.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
VERSION=1.2.0
RELEASE=4
TARBALL_URL=https://github.com/giampaolo/pyftpdlib/archive/release-$VERSION.tar.gz
GIT_URL=https://github.com/zultron/python-pyftpdlib-deb.git
DEBIAN_PACKAGE_FORMAT='3.0 (quilt)'
DEBIAN_PACKAGE_COMP=gz
2 changes: 0 additions & 2 deletions scripts/package/pyzmq.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
VERSION=14.3.0
RELEASE=4
TARBALL_URL=https://github.com/zeromq/pyzmq/archive/v${VERSION}.tar.gz
GIT_URL=https://github.com/zultron/pyzmq-deb.git
DEBIAN_PACKAGE_FORMAT='3.0 (quilt)'
DEBIAN_PACKAGE_COMP=gz
# 'apt' resolver: 'Build-Depends dependency for
# sbuild-build-depends-pyzmq-dummy cannot be satisfied because the
Expand Down
3 changes: 0 additions & 3 deletions scripts/package/rtai.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
GIT_REV=a416758
VERSION=4.0.5.${GIT_REV}
RELEASE=1
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_FORMAT='3.0 (quilt)'
DEBIAN_PACKAGE_COMP=gz
EXCLUDE_ARCHES=armhf
2 changes: 0 additions & 2 deletions scripts/package/xenomai.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
VERSION=2.6.4
RELEASE=1
TARBALL_URL=http://download.gna.org/xenomai/stable/xenomai-$VERSION.tar.bz2
GIT_URL=https://github.com/zultron/xenomai-deb.git
DEBIAN_PACKAGE_FORMAT='3.0 (quilt)'
DEBIAN_PACKAGE_COMP=bz2
Loading

0 comments on commit 0115487

Please sign in to comment.