-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsync_stable_source.sh
executable file
·86 lines (69 loc) · 2.8 KB
/
sync_stable_source.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
#!/bin/bash
set -eux
PROJECT="home:steven.hardy:testing:Cloud:OpenStack:Bobcat"
if [ $# != 1 ]; then
echo "Usasge: $0 <package name>"
exit 1
fi
PACKAGE=$1
# checkout the target package or update if it already exists
if [ -d "${PROJECT}/${PACKAGE}" ]; then
echo "${PROJECT}/${PACKAGE} exists"
osc -A https://api.opensuse.org revert ${PROJECT}/${PACKAGE}
osc -A https://api.opensuse.org update ${PROJECT}/${PACKAGE}
else
echo "${PROJECT}/${PACKAGE} does not exist"
osc -A https://api.opensuse.org checkout ${PROJECT}/${PACKAGE}
fi
NUM_SOURCES=$(grep "^Source0:" ${PROJECT}/${PACKAGE}/*.spec | wc -l)
if [ ${NUM_SOURCES} -ne 1 ]; then
echo "Error only one Source file supported"
exit 1
fi
TARGET_SOURCE=$(grep "^Source" ${PROJECT}/${PACKAGE}/*.spec)
TARGET_URL=$(echo ${TARGET_SOURCE} | awk '{print $2}')
# Update the source from upstream
REQ_NAME=$(echo ${PACKAGE} | sed 's/^python-//g' | sed 's/^openstack-//')
echo "REQ_NAME=${REQ_NAME}"
STABLE_VERSION=${STABLE_VERSION:-2023.2}
MINOR_VERSION=${MINOR_VERSION:-0}
STABLE_URL="https://opendev.org/openstack/${REQ_NAME}/archive/stable/${STABLE_VERSION}.tar.gz"
STABLE_TARBALL="${REQ_NAME}-%{version}.tar.xz"
if [ "${TARGET_URL}" == "${STABLE_TARBALL}" ]; then
echo "Spec already contains ${STABLE_TARBALL}, nothing to do"
exit 0
fi
if ! curl -sSfI ${STABLE_URL}; then
echo "${STABLE_URL}" | tee -a ${PROJECT}/failures.txt
exit 1
fi
cat > ${PROJECT}/${PACKAGE}/_service <<EOF
<services>
<service name="obs_scm">
<param name="url">https://opendev.org/openstack/${REQ_NAME}.git</param>
<param name="revision">stable/2023.2</param>
<param name="versionformat">2023.2.0</param>
<param name="scm">git</param>
</service>
<service mode="buildtime" name="tar" />
<service mode="buildtime" name="recompress">
<param name="file">*.tar</param>
<param name="compression">xz</param>
</service>
<service mode="buildtime" name="set_version" />
</services>
EOF
osc add ${PROJECT}/${PACKAGE}/_service
TARGET_SRC_FILE=$(basename ${TARGET_URL})
osc rm ${PROJECT}/${PACKAGE}/${TARGET_SRC_FILE}
sed -i "s;${TARGET_URL};${STABLE_TARBALL};" ${PROJECT}/${PACKAGE}/*.spec
NEW_SPEC_VERSION="Version: ${STABLE_VERSION}.${MINOR_VERSION}"
TARGET_SPEC_VERSION=$(grep "^Version:" ${PROJECT}/${PACKAGE}/*.spec)
sed -i "s;${TARGET_SPEC_VERSION};${NEW_SPEC_VERSION};" ${PROJECT}/${PACKAGE}/*.spec
NEW_SPEC_AUTOSETUP="%autosetup -p1 -n ${REQ_NAME}-%{version}"
TARGET_SPEC_AUTOSETUP=$(grep "^%autosetup" ${PROJECT}/${PACKAGE}/*.spec)
sed -i "s;${TARGET_SPEC_AUTOSETUP};${NEW_SPEC_AUTOSETUP};" ${PROJECT}/${PACKAGE}/*.spec
sed -i '/^%build/a export PBR_VERSION=%{version}' ${PROJECT}/${PACKAGE}/*.spec
sed -i '/^%install/a export PBR_VERSION=%{version}' ${PROJECT}/${PACKAGE}/*.spec
osc diff ${PROJECT}/${PACKAGE}
osc ci -m "Updated to $STABLE_VERSION" ${PROJECT}/${PACKAGE}