3 # This needs a bit more work, mostly on the "discplined engineering" front.
4 # IOW, instead of this UPSTREAM_BASE hack it would be better to have 3
6 # 1) pristine upstream: for tracking upstream progress/retrogression
7 # 2) patched upstream: pristine upstream with outr patches applied
8 # 3) working local: patches upstream + a set of scripts (like this) to
9 # do everyday stuff like making new releases, exporting stuff to
13 PKG="$(basename `pwd`)"
14 UPSTREAM_BASE="upstream"
15 VERSION="`date +'%Y%m%d'`"
19 AUTHOR="Policy Team <policy.team@intel.com>"
21 while [ "${1#-}" != "$1" -a -n "$1" ]; do
44 echo "usage: $0 [options], where the possible options are"
45 echo " -n <name> name of your package"
46 echo " -v <version> version to in rpm/SPEC file"
47 echo " -B <upstream-base> name or SHA1 of baseline"
48 echo " -H <taget-head> name or SHA1 of release HEAD"
49 echo " --obs include tarball for OBS"
51 echo "<name> is the name of the package, <version> is the version"
52 echo "you want to export to OBS, and <upstream-base> is the name of"
53 echo "the upstream git branch or the SHA1 you want to generate your"
54 echo "release from and base your patches on top of. On OBS mode the"
55 echo "output will be generated in a directory called obs-$VERSION."
56 echo "Otherwise in gerrit mode, the output will be generated in a"
57 echo "directory called packaging."
60 echo " $0 -n pulseaudio -v 2.0 -B pulseaudio-2.0 -H tizen"
62 echo "This will produce a gerrit export with version 2.0 against the"
63 echo "SHA1 pulseaudio-2.0, producing patches up till tizen and"
64 echo "place the result in a directory called packaging."
70 --big-hammer|--release|-r)
78 *) echo "usage: $0 [-n <name>][-v <version>][--obs]"
79 echo " [-b <upstream-base>] [-H <head>"
91 TARBALL=$PKG-$VERSION.tar
95 echo "invalid mode: $MODE"
100 echo "Package name: $PKG"
101 echo "Package version: $VERSION"
102 echo "Package baseline: $UPSTREAM_BASE"
103 echo "Package head: $HEAD"
104 echo "Output directory: $DIR"
109 if [ -n "$TARBALL" ]; then
110 echo "Generating tarball..."
111 git archive --format=tar --prefix=$PKG-$VERSION/ $UPSTREAM_BASE \
116 echo "Generating patches, creating spec file..."
118 git format-patch -n $UPSTREAM_BASE..$HEAD && \
119 cat ../$PKG.spec.in | sed "s/@VERSION@/$VERSION/g" > $PKG.spec.in && \
123 patchlist="`ls *.patch`"
124 cat $PKG.spec.in | while read -r line; do
128 for patch in $patchlist; do
129 echo "Patch$i: $patch"
135 for patch in $patchlist; do
147 rm -f $DIR/$PKG.spec.in
149 if [ "$MODE" = "gerrit" -a "$RELEASE" = "yes" ]; then
150 stamp="$(date -u +%Y%m%d.%H%M%S)"
151 branch="gerrit-release-$stamp"
152 tag="submit/trunk/$stamp"
153 chlog=packaging/$PKG.changes
155 echo "Preparing release branch $branch with tag $tag..."
157 git branch $branch $UPSTREAM_BASE && \
158 git checkout $branch && \
159 git add packaging && \
160 git commit -n -m "release: added packaging for gerrit." packaging && \
161 echo "* $(date '+%a %b %d %H:%M:%S %Z %Y') $AUTHOR - $VERSION" \
163 echo "- release: releasing $VERSION..." >> $chlog && \
166 echo "Okay, branch $branch is prepared for release." && \
167 echo "To proceed with the release, please" && \
169 echo " 1) vi $chlog (and add a real changelog entry)" && \
170 echo " 2) git commit -m \"release: updated changelog.\" $chlog" && \
171 echo " 3) git tag -a -m \"release: tagged release.\" $tag HEAD" && \
172 echo " 4) git push --force tzgerrit HEAD^:refs/heads/master" && \
173 echo " 5) git push tzgerrit HEAD:refs/for/master $tag"
175 if [ "$?" = "0" ]; then
178 echo "Failed to prepare release..."
179 git branch -D $branch