1 | #!/bin/bash
|
---|
2 |
|
---|
3 | #
|
---|
4 | # svn_build_prepare.sh:
|
---|
5 | # erzeugen des SPEC und der tar.gz. Ablegen in $DEST/buildsrc/src/PACKETNAME
|
---|
6 | # überprüfen ob projekt exisitert
|
---|
7 | # osc commit
|
---|
8 | # osc build
|
---|
9 | #
|
---|
10 | #
|
---|
11 |
|
---|
12 | [ -z "$BUILD_USES_SVN" ] && BUILD_USES_SVN="yes"
|
---|
13 |
|
---|
14 | BUILDUSER=$USER
|
---|
15 | [ -z $DEST_DIR ] && DEST_DIR="/tmp/build.$BUILDUSER"
|
---|
16 | BUILDTEMP=$DEST_DIR/buildsrc/
|
---|
17 |
|
---|
18 | if [ ! -r OSC_PACKAGE ]; then
|
---|
19 | echo "failed to read config file OSC_PACKAGE"
|
---|
20 | exit 1
|
---|
21 | fi
|
---|
22 |
|
---|
23 | OSC_PACKAGE=`cat OSC_PACKAGE`
|
---|
24 |
|
---|
25 |
|
---|
26 |
|
---|
27 | if [ -z "$1" ]; then
|
---|
28 | # without parameter, we are in source directory
|
---|
29 | SPECFILE=$(ls *.spec | awk '{print $1}')
|
---|
30 | PACKAGE=$(sed -n -e 's/^Name:\W*//pi' <$SPECFILE)
|
---|
31 | VERSION=$(sed -n -e 's/^Version:\W*//pi' <$SPECFILE)
|
---|
32 | elif [ -r "$1" ]; then
|
---|
33 | # parameter is src.rpm file
|
---|
34 | PACKAGE=`rpm -qp --qf "%{NAME}" $1`
|
---|
35 | VERSION=`rpm -qp --qf "%{VERSION}" $1`
|
---|
36 | fi
|
---|
37 |
|
---|
38 |
|
---|
39 | if [ -z "$PACKAGE" ]; then
|
---|
40 | echo "nothing to build found!"
|
---|
41 | exit 1
|
---|
42 | fi
|
---|
43 |
|
---|
44 | BUILDSRC_DIR=${BUILDTEMP}/src/${PACKAGE}
|
---|
45 |
|
---|
46 |
|
---|
47 | svn_build_prepare.sh $* || {
|
---|
48 | echo "failed to prepare sources"
|
---|
49 | exit 1
|
---|
50 | }
|
---|
51 |
|
---|
52 | osc co $OSC_PACKAGE || {
|
---|
53 | # error message already from osc
|
---|
54 | exit 1
|
---|
55 | }
|
---|
56 | # rsync is not usable, because ":" is interpretaded as remote host
|
---|
57 | #rsync -av "$BUILDSRC_DIR/*" "$OSC_PACKAGE/."
|
---|
58 | cp -av $BUILDSRC_DIR/* $OSC_PACKAGE/.
|
---|
59 |
|
---|
60 | if [ "$BUILD_USES_SVN" = "yes" ]; then
|
---|
61 | echo "receiving subversion information ..."
|
---|
62 | # set RELEASE number (last modification in this directory)
|
---|
63 | # requires subversion (but connection to server isn't neccessary)
|
---|
64 | SVN_BUILD_RELEASE=$(unset LANG; svn info . | sed -n 's/^Last Changed Rev: \([0-9]*\)/\1/p')
|
---|
65 | # in case of local modification a "m" is added to the release number
|
---|
66 | SVN_BUILD_MODIFIED=$(svn status -v | grep "^ *M" | wc -l)
|
---|
67 | # checks if a file is commited,
|
---|
68 | # but update on its directory is not performed
|
---|
69 | SVN_LAST_MODIFICATION=$(svn status -v | sed -n 's/^ *[0-9]* *\([0-9]*\) .*/\1/p' | sort -n | tail -1)
|
---|
70 | if [ $SVN_BUILD_MODIFIED -gt 0 ]; then
|
---|
71 | SVN_BUILD_RELEASE=${SVN_BUILD_RELEASE}m
|
---|
72 | elif [ $SVN_LAST_MODIFICATION -ne $SVN_BUILD_RELEASE ]; then
|
---|
73 | SVN_BUILD_RELEASE=${SVN_BUILD_RELEASE}p
|
---|
74 | fi
|
---|
75 | echo "SVN_BUILD_RELEASE: $SVN_BUILD_RELEASE"
|
---|
76 | fi
|
---|
77 |
|
---|
78 | cd $OSC_PACKAGE
|
---|
79 | pwd
|
---|
80 | #echo "OSC_PACKAGE"
|
---|
81 | # osc build DIST ARCH
|
---|
82 | osc add *
|
---|
83 | if [ "$SVN_BUILD_RELEASE" ]; then
|
---|
84 | osc commit -m "release $SVN_BUILD_RELEASE"
|
---|
85 | fi |
---|