add gerrit release file
[profile/ivi/audiomanager.git] / packaging / 0007-scripts-added-obs-export.sh.patch
1 From bc532427d6848210ab4e2bf81a6ab43a74f13338 Mon Sep 17 00:00:00 2001
2 From: Jaska Uimonen <jaska.uimonen@helsinki.fi>
3 Date: Wed, 6 Jun 2012 17:59:11 +0300
4 Subject: [PATCH 7/8] scripts: added obs-export.sh.
5
6 ---
7  obs-export.sh |   92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
8  1 files changed, 92 insertions(+), 0 deletions(-)
9  create mode 100755 obs-export.sh
10
11 diff --git a/obs-export.sh b/obs-export.sh
12 new file mode 100755
13 index 0000000..c13853a
14 --- /dev/null
15 +++ b/obs-export.sh
16 @@ -0,0 +1,92 @@
17 +#!/bin/bash
18 +
19 +# This needs a bit more work, mostly on the "discplined engineering" front.
20 +# IOW, instead of this UPSTREAM_BASE hack it would be better to have 3
21 +# branches:
22 +#   1) pristine upstream: for tracking upstream progress/retrogression
23 +#   2) patched upstream: pristine upstream with outr patches applied
24 +#   3) working local: patches upstream + a set of scripts (like this) to
25 +#      do everyday stuff like making new releases, exporting stuff to
26 +#      OBS, etc...
27 +
28 +
29 +PKG="$(basename `pwd` | tr [:upper:] [:lower:])"
30 +UPSTREAM_BASE="06476e68a42077a0597628dca1c4a53cd20f5236"
31 +VERSION="`date +'%Y%m%d'`"
32 +
33 +
34 +while [ "${1#-}" != "$1" -a -n "$1" ]; do
35 +    case $1 in
36 +        --name|-n)
37 +            PKG="$2"
38 +            shift 2
39 +            ;;
40 +        --version|-v)
41 +            VERSION="$2"
42 +            shift 2
43 +           ;;
44 +        --base|-b)
45 +            UPSTREAM_BASE="$2"
46 +            shift 2
47 +            ;;
48 +        --help|-h)
49 +           echo "usage: $0 [-n <name>][-v <version>][-b <upstream-base>]"
50 +           echo ""
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 "OBS tarball from and base your patches on top of. The output"
55 +           echo "will be generated in a directory called obs-$VERSION."
56 +          echo ""
57 +           echo "E.g.:"
58 +           echo "  $0 -n pulseaudio -v 2.0 -b pulseaudio-2.0"
59 +           echo ""
60 +           echo "This will produce an OBS export with version 2.0 against the"
61 +           echo "SHA1 pulseaudio-2.0 and place the result in obs-2.0."
62 +           exit 0
63 +           ;;
64 +        *) echo "usage: $0 [-n <name>][-v <version>][-b <upstream-base>]"
65 +           exit 1
66 +           ;;
67 +    esac
68 +done
69 +
70 +echo "PKG=$PKG"
71 +echo "VERSION=$VERSION"
72 +echo "UPSTREAM_BASE=$UPSTREAM_BASE"
73 +
74 +rm -fr obs-$VERSION
75 +mkdir obs-$VERSION && \
76 +    git archive --format=tar --prefix=$PKG-$VERSION/ $UPSTREAM_BASE \
77 +        > obs-$VERSION/$PKG-$VERSION.tar && \
78 +    gzip obs-$VERSION/$PKG-$VERSION.tar && \
79 +cd obs-$VERSION && \
80 +    git format-patch -n $UPSTREAM_BASE && \
81 +    cat ../$PKG.spec.in | sed "s/@VERSION@/$VERSION/g" > $PKG.spec.in && \
82 +cd -
83 +
84 +cd obs-$VERSION
85 +patchlist="`ls *.patch`"
86 +cat $PKG.spec.in | while read line; do
87 +    case $line in
88 +        @DECLARE_PATCHES@)
89 +            i=0
90 +            for patch in $patchlist; do
91 +                echo "Patch$i: $patch"
92 +                let i=$i+1
93 +            done
94 +            ;;
95 +        @APPLY_PATCHES@)
96 +            i=0
97 +            for patch in $patchlist; do
98 +                echo "%patch$i -p1"
99 +                let i=$i+1
100 +            done
101 +            ;;
102 +        *)
103 +            echo "$line"
104 +            ;;
105 +    esac
106 +done > $PKG.spec
107 +cd -
108 +rm -f obs-$VERSION/$PKG.spec.in
109 -- 
110 1.7.7.6
111