Debian Codegraph @

build-tools/pkgos-bop

raw
1 #!/bin/sh
2 # Build an OpenStack team's package and write it in /home/ftp
3
4 set -e
5
6 if ! [ -r /etc/pkgos/pkgos.conf ] ; then
7 echo "Could not read /etc/pkgos/pkgos.conf"
8 exit 1
9 else
10 . /etc/pkgos/pkgos.conf
11 fi
12
13 command_exists () {
14 type "$1" >/dev/null 2>&1
15 }
16
17 # Alias git-buildpackage
18 if ! command_exists git-buildpackage ; then
19 alias git-buildpackage="gbp buildpackage"
20 fi
21
22 # Some quick calculation
23 BPO_DISTRO_NUM=~bpo${TARGET_DISTRO_NUM}+1
24
25 cleanup_old_build () {
26 echo "===> Cleaning-up old builds"
27 rm -rf ../*.orig.tar.xz ../*.orig.tar.gz ../build-area
28 }
29
30 # Finds the current version of the package
31 get_deb_version() {
32 PKG_NAME=`dpkg-parsechangelog -SSource`
33 DEB_VERS=`dpkg-parsechangelog -SVersion`
34 NO_EPOC=`echo ${DEB_VERS} | cut -d":" -f2`
35 UPSTREAM_VERS=`echo ${NO_EPOC} | cut -d"-" -f1`
36 if [ "${DEB_VERS}" = "${UPSTREAM_VERS}" ] ; then IS_NATIVE="yes" ; else IS_NATIVE="no" ; fi
37 ORIG=${PKG_NAME}_${UPSTREAM_VERS}.orig.tar.xz
38 CHANGE=${PKG_NAME}_${NO_EPOC}_${ARCH}.changes
39 PKG_NAME_FIRST_CHAR=`echo ${PKG_NAME} | awk '{print substr($0,1,1)}'`
40 }
41
42 create_orig_tar () {
43 if grep pristine-tar debian/gbp.conf | grep -q -i true ; then
44 echo "===> Calling gbp export-orig to generate the tarball"
45 gbp export-orig
46 echo "===> Copying tarball in ../build-area"
47 mkdir -p ../build-area
48 cp ../*.orig.tar.* ../build-area
49 else
50 if [ "${IS_NATIVE}" = "no" ] ; then
51 COMPRESSION_TYPE=xz
52 if [ -r debian/gbp.conf ] ; then
53 COMPRESSION_IN_FILE=`cat debian/gbp.conf | grep compression | cut -d'=' -f2 | awk '{print $1}'`
54 if [ "${COMPRESSION_IN_FILE}" = "gz" ] ; then
55 COMPRESSION_TYPE=gz
56 elif [ "${COMPRESSION_IN_FILE}" = "bzip2" ] ; then
57 COMPRESSION_TYPE=bzip2
58 fi
59 fi
60 if [ "${COMPRESSION_TYPE}" = "gz" ] ; then
61 ./debian/rules gen-orig-gz
62 elif [ "${COMPRESSION_TYPE}" = "bzip2" ] ; then
63 ./debian/rules gen-orig-bz2
64 else
65 ./debian/rules gen-orig-xz
66 fi
67 fi
68 fi
69 }
70
71 bop_it () {
72 echo "===> Building using git-buildpackage"
73 LAST_GIT_COMMIT=`git log | head -n 1 | awk '{print $2}'`
74 dch --newversion ${DEB_VERS}${BPO_DISTRO_NUM} -b --allow-lower-version -m "Rebuilt by bop."
75 git commit debian/changelog -m "Rebuilt by bop."
76 pkgos-check-changelog || true
77 if [ "${PKGOS_RUN_UNIT_TESTS_AT_BUILD}" = "no" ] ; then
78 if ! DEB_BUILD_OPTIONS=nocheck git-buildpackage ; then
79 git reset --hard ${LAST_GIT_COMMIT}
80 echo "There was an error when bop called git-buildpackage: exiting."
81 exit 1
82 else
83 git reset --hard ${LAST_GIT_COMMIT}
84 fi
85 else
86 if ! git-buildpackage ; then
87 git reset --hard ${LAST_GIT_COMMIT}
88 echo "There was an error when bop called git-buildpackage: exiting."
89 exit 1
90 else
91 git reset --hard ${LAST_GIT_COMMIT}
92 fi
93 fi
94 }
95
96 test_the_package () {
97 echo "===> Lintian"
98 lintian -I -E --pedantic --profile debian/openstack ../build-area/*.changes
99
100 if [ x"$RUN_AUTOPKGTEST" = x"yes" ] ; then
101 echo "===> Autopkgtest"
102 set +e
103 adt-run ../build-area/*.changes --- schroot "$AUTOPKGTEST_SCHROOT"
104 RET=$?
105 if [ $RET != 0 ] && [ $RET != 8 ] ; then
106 echo "adt-run failed: $RET"
107 exit $RET
108 fi
109 set -e
110 fi
111 }
112
113 copy_to_ftparchive () {
114 echo "===> Copying to the FTP repo"
115 rm ../build-area/${PKG_NAME}_${NO_EPOC}${BPO_DISTRO_NUM}_*.build
116 TARGET_FOLDER=${REPO_ROOT}/debian/pool/${TARGET_DISTRO}-${TARGET_OPENSTACK_REL}-backports/main/${PKG_NAME_FIRST_CHAR}/${PKG_NAME}
117 rm -rf ${TARGET_FOLDER}
118 mkdir -p ${TARGET_FOLDER}
119 cp ../build-area/* ${TARGET_FOLDER}
120 }
121
122 cleanup_old_build
123 get_deb_version
124 create_orig_tar
125 bop_it
126 #test_the_package
127 copy_to_ftparchive
128 # Scan the repo to add the new package
129 pkgos-scan-repo
130 # Trigger webhook for rsync and status update
131 pkgos-trigger-odrm-hook