-
Notifications
You must be signed in to change notification settings - Fork 0
/
droid_hal_prjconf_sync.sh
executable file
·89 lines (65 loc) · 2.17 KB
/
droid_hal_prjconf_sync.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
scriptdir="$(dirname -- "$( readlink -f -- "$0"; )")"
. $scriptdir/shared.sh
usage() {
cat <<EOF
usage: $0 [options] packages
options:
-r repository url
-P OBS source Project
-A API url to the target obs, defaults to $obs_api_url
-h Show this help
EOF
}
while getopts hr:b:P:p:A: arg ; do
case $arg in
r) repository=$OPTARG;;
P) obs_project=$OPTARG;;
A) obs_api_url=$OPTARG;;
h) usage; exit 0;;
?|*) usage; exit 1;;
esac
done
start_date="$(date -R)"
repository_basename=$(basename $repository |sed 's/\.git//')
obs_checkout_prj $obs_project
obs_project=$PWD/$obs_project
if [ ! -e $repository_basename ] ; then
git clone --recursive "$repository"
else
cd $repository_basename || exit 1
git pull --recurse-submodule=yes
fi
# droid-prjconf package copy start
# The lines marked as copy are copied from droid-hal-prjconf.inc:
# https://github.com/mer-hybris/droid-hal-prjconf/blob/master/droid-hal-prjconf.inc
CONFDIR=prjconf
SUBMODULE=droid-hal-prjconf
SRC_GENERIC=$SUBMODULE/$CONFDIR
SRC_SPECIFIC=$CONFDIR
DEST=$(obs_cd_project_path $obs_project)/prjconf_upload.xml
if grep -q "^Macros:" $SRC_GENERIC/prjconf.xml $SRC_SPECIFIC/prjconf.xml; then
echo "prjconf.xml must not contain Macros section. Put them to macros.xml"
exit 1
fi
cp -f $SRC_GENERIC/prjconf.xml $DEST
if [ -e $SRC_SPECIFIC/prjconf.xml ]; then
cat $SRC_SPECIFIC/prjconf.xml >> $DEST
fi
# droid-prjconf package interrupt
# Store the %device macro defined in prjconf spec in the prjconf
# so that later we can find out to which device and thus vendor and family
# the building project and it's droid-src package belong to.
device=$(parse_spec_stat rpm/droid-hal-prjconf.spec "name"|head -n1|
sed 's/droid-hal-prjconf-//')
echo "%define device $device" >> $DEST
# droid-prjconf package continue
if [ -e $SRC_SPECIFIC/macros.xml ]; then
echo "Macros:" >> $DEST
cat $SRC_SPECIFIC/macros.xml | grep -v "^Macros:" >> $DEST
fi
# droid-prjconf package end
pkg_ver=$(git describe --tags)
obs_cd_project "$obs_project" || exit 1
osc meta prjconf --file="$DEST" --message "Update to $pkg_ver on $start_date"
rm "$DEST"