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 scripts/release_helper.sh >/home/grml-live-git/grml-live-build.log
23 # Tip: To find out the build date of the installed grml-live package just run:
25 # % apt-cache policy grml-live | grep 'Installed.*autobuild'
26 # Installed: 0.13.1~autobuild1300450381
28 # and run "date -ud @$STRING" where $STRING is the number
29 # behind the "autobuild", like:
30 # % date -ud @1300450081
31 # Fri Mar 18 12:08:01 UTC 2011
32 ################################################################################
43 autobuild_branch="autobuild_$(date +%Y%m%d_%H%M%S)"
45 if [ -n "${AUTOBUILD:-}" ] ; then
48 git checkout -b "$autobuild_branch"
50 if git status --porcelain | grep -q '^?? '; then
51 printf "Uncommited changes in current working tree. Please commit/clean up.\n"
56 printf "Building debian/changelog: "
57 if [ -n "${AUTOBUILD:-}" ] ; then
58 # since=$(git show -s --pretty="tformat:%h")
59 eval $(grep '^GRML_LIVE_VERSION=' grml-live)
63 cat > debian/changelog << EOF
64 grml-live (${GRML_LIVE_VERSION}~autobuild${UNIXTIME}) UNRELEASED; urgency=low
66 * Automatically built package based on the state of
67 git repository at http://git.grml.org/?p=grml-live.git
70 $(git log --format=oneline -1)
72 -- grml-live Auto Build <grml-live-git@$(hostname)> $DATE
75 git add debian/changelog
76 git commit -m "Releasing ${GRML_LIVE_VERSION}-~autobuild${UNIXTIME} (auto build)"
78 since=v$(dpkg-parsechangelog | awk '/^Version:/ {print $2}')
79 git-dch --ignore-branch --since=$since \
80 --id-length=7 --meta --multimaint-merge -S
84 if [ -z "${AUTOBUILD:-}" ] ; then
85 if ! $EDITOR debian/changelog ; then
86 printf "Exiting as editing debian/changelog returned an error." >&2
91 debian_version="$(dpkg-parsechangelog | awk '/^Version:/ {print $2}')"
94 if echo "$debian_version" | grep -q '\.gbp' ; then
95 printf "Building snapshot version, not releasing.\n"
99 printf "Updating GRML_LIVE_VERSION string in grml-live script: "
100 sed -i "s/^GRML_LIVE_VERSION=.*/GRML_LIVE_VERSION='$debian_version'/" grml-live
103 printf "Comparing versions of debian/changelog with grml-live version string: "
104 script_version="$(awk -F= '/^GRML_LIVE_VERSION=/ {print $2}' grml-live | sed "s/'//g")"
105 debian_version="$(dpkg-parsechangelog | awk '/^Version:/ {print $2}')"
107 if [[ "$script_version" == "$debian_version" ]] ; then
111 printf "Debian package version ($debian_version) does not match script version ($script_version).\n"
115 if $dorelease || [ -n "${AUTOBUILD:-}" ] ; then
116 git add debian/changelog grml-live
117 git commit -s -m "Release new version ${debian_version}."
120 printf "Building debian packages:\n"
121 if [ -n "${AUTOBUILD:-}" ] ; then
122 [ -d ../grml-live.build-area ] || mkdir ../grml-live.build-area
123 rm -rf ../grml-live.build-area/grml-live* # otherwise we're keeping files forever...
124 git-buildpackage --git-ignore-branch --git-ignore-new --git-export-dir=../grml-live.build-area -us -uc
126 git-buildpackage --git-ignore-branch --git-ignore-new $*
127 printf "Finished execution of $(basename $0). Do not forget to tag release ${debian_version}\n"
130 if [ -n "${AUTOBUILD:-}" ] ; then
132 cd ../grml-live.build-area
133 dpkg-scanpackages . /dev/null > Packages
136 git branch -D ${autobuild_branch} || true
138 PACKAGES=$(dpkg --list grml-live\* | awk '/^ii/ {print $2}')
139 sudo apt-get -y --allow-unauthenticated install $PACKAGES
142 ## END OF FILE #################################################################