2 # Filename: scripts/release_helper.sh
3 # Purpose: helper script to build grml-live Debian packages
4 # Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports: see http://grml.org/bugs/
6 # License: This file is licensed under the GPL v2 or any later version.
7 ################################################################################
8 ## How to set up autobuild (for automatically updating grml-live.git and
9 ## build packages out of git tree and install them, e.g. for usage on
11 # echo "deb file:/home/grml-live-git/grml-live.build-area/ ./" >> /etc/apt/sources.list.d/grml-live.list
12 # adduser --disabled-login --disabled-password grml-live-git
13 # visudo -> add "grml-live-git ALL=NOPASSWD: /usr/bin/apt-get"
15 # mkdir /home/grml-live-git/grml-live.build-area
16 # git clone git://git.grml.org/grml-live.git
17 # git config --global user.name "Grml-Live Git Autobuild"
18 # git config --global user.email "grml-live-git@$(hostname)"
20 # Finally install a cron job (as user grml-live-git) like:
21 # 30 00 * * * cd /home/grml-live-git/grml-live.git/ && env AUTOBUILD=1 /home/grml-live-git/release_helper.sh >/home/grml-live-git/grml-live-build.log
22 ################################################################################
33 autobuild_branch="autobuild_$(date +%Y%m%d_%H%M%S)"
35 if [ -n "${AUTOBUILD:-}" ] ; then
38 git checkout -b "$autobuild_branch"
40 if git status --porcelain | grep -q '^?? '; then
41 printf "Uncommited changes in current working tree. Please commit/clean up.\n"
46 printf "Building debian/changelog: "
47 if [ -n "${AUTOBUILD:-}" ] ; then
48 # since=$(git show -s --pretty="tformat:%h")
49 eval $(grep '^GRML_LIVE_VERSION=' grml-live)
53 cat > debian/changelog << EOF
54 grml-live (${GRML_LIVE_VERSION}~autobuild${UNIXTIME}) UNRELEASED; urgency=low
56 * Automatically built package based on the state of
57 git repository at http://git.grml.org/?p=grml-live.git
60 -- grml-live Auto Build <mika@grml.org> $DATE
63 git add debian/changelog
64 git commit -m "Releasing ${GRML_LIVE_VERSION}-~autobuild${UNIXTIME} (auto build)"
66 since=v$(dpkg-parsechangelog | awk '/^Version:/ {print $2}')
67 git-dch --ignore-branch --since=$since \
68 --id-length=7 --meta --multimaint-merge -S
72 if [ -z "${AUTOBUILD:-}" ] ; then
73 if ! $EDITOR debian/changelog ; then
74 printf "Exiting as editing debian/changelog returned an error." >&2
79 debian_version="$(dpkg-parsechangelog | awk '/^Version:/ {print $2}')"
82 if echo "$debian_version" | grep -q '\.gbp' ; then
83 printf "Building snapshot version, not releasing.\n"
87 printf "Updating GRML_LIVE_VERSION string in grml-live script: "
88 sed -i "s/^GRML_LIVE_VERSION=.*/GRML_LIVE_VERSION='$debian_version'/" grml-live
91 printf "Comparing versions of debian/changelog with grml-live version string: "
92 script_version="$(awk -F= '/^GRML_LIVE_VERSION=/ {print $2}' grml-live | sed "s/'//g")"
93 debian_version="$(dpkg-parsechangelog | awk '/^Version:/ {print $2}')"
95 if [[ "$script_version" == "$debian_version" ]] ; then
99 printf "Debian package version ($debian_version) does not match script version ($script_version).\n"
103 if $dorelease || [ -n "${AUTOBUILD:-}" ] ; then
104 git add debian/changelog grml-live
105 git commit -s -m "Release new version ${debian_version}."
108 printf "Building debian packages:\n"
109 if [ -n "${AUTOBUILD:-}" ] ; then
110 [ -d ../grml-live.build-area ] || mkdir ../grml-live.build-area
111 git-buildpackage --git-ignore-branch --git-ignore-new --git-export-dir=../grml-live.build-area -us -uc
113 git-buildpackage --git-ignore-branch --git-ignore-new $*
114 printf "Finished execution of $(basename $0). Do not forget to tag release ${debian_version}\n"
117 if [ -n "${AUTOBUILD:-}" ] ; then
119 cd ../grml-live.build-area
120 dpkg-scanpackages . /dev/null > Packages
123 git branch -D ${autobuild_branch} || true
125 PACKAGES=$(dpkg --list grml-live\* | awk '/^ii/ {print $2}')
126 sudo apt-get -y --allow-unauthenticated install $PACKAGES
129 ## END OF FILE #################################################################