File: pkgos-bop

package info (click to toggle)
openstack-pkg-tools 139
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 940 kB
  • sloc: sh: 4,216; makefile: 31
file content (131 lines) | stat: -rwxr-xr-x 3,672 bytes parent folder | download
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/sh
# Build an OpenStack team's package and write it in /home/ftp

set -e

if ! [ -r /etc/pkgos/pkgos.conf ] ; then
	echo "Could not read /etc/pkgos/pkgos.conf"
	exit 1
else
	. /etc/pkgos/pkgos.conf
fi

command_exists () {
	type "$1" >/dev/null 2>&1
}

# Alias git-buildpackage
if ! command_exists git-buildpackage ; then
	alias git-buildpackage="gbp buildpackage"
fi

# Some quick calculation
BPO_DISTRO_NUM=~bpo${TARGET_DISTRO_NUM}+1

cleanup_old_build () {
	echo "===> Cleaning-up old builds"
	rm -rf ../*.orig.tar.xz ../*.orig.tar.gz ../build-area
}  

# Finds the current version of the package
get_deb_version() {
	PKG_NAME=`dpkg-parsechangelog -SSource`
	DEB_VERS=`dpkg-parsechangelog -SVersion`
	NO_EPOC=`echo ${DEB_VERS} | cut -d":" -f2`
	UPSTREAM_VERS=`echo ${NO_EPOC} | cut -d"-" -f1`
	if [ "${DEB_VERS}" = "${UPSTREAM_VERS}" ] ; then IS_NATIVE="yes" ; else IS_NATIVE="no" ; fi
	ORIG=${PKG_NAME}_${UPSTREAM_VERS}.orig.tar.xz
	CHANGE=${PKG_NAME}_${NO_EPOC}_${ARCH}.changes
	PKG_NAME_FIRST_CHAR=`echo ${PKG_NAME} | awk '{print substr($0,1,1)}'`
}

create_orig_tar () {
	if grep pristine-tar debian/gbp.conf | grep -q -i true ; then
		echo "===> Calling gbp export-orig to generate the tarball"
		gbp export-orig
		echo "===> Copying tarball in ../build-area"
		mkdir -p ../build-area
		cp ../*.orig.tar.* ../build-area
	else
		if [ "${IS_NATIVE}" = "no" ] ; then
			COMPRESSION_TYPE=xz
			if [ -r debian/gbp.conf ] ; then
				COMPRESSION_IN_FILE=`cat debian/gbp.conf | grep compression | cut -d'=' -f2 | awk '{print $1}'`
				if [ "${COMPRESSION_IN_FILE}" = "gz" ] ; then
					COMPRESSION_TYPE=gz
				elif [ "${COMPRESSION_IN_FILE}" = "bzip2" ] ; then
					COMPRESSION_TYPE=bzip2
				fi
			fi
			if [ "${COMPRESSION_TYPE}" = "gz" ] ; then
				./debian/rules gen-orig-gz
			elif [ "${COMPRESSION_TYPE}" = "bzip2" ] ; then
				./debian/rules gen-orig-bz2
			else
				./debian/rules gen-orig-xz
			fi
		fi
	fi
}

bop_it () {
	echo "===> Building using git-buildpackage"
	LAST_GIT_COMMIT=`git log | head -n 1 | awk '{print $2}'`
	dch --newversion ${DEB_VERS}${BPO_DISTRO_NUM} -b --allow-lower-version -m  "Rebuilt by bop."
	git commit debian/changelog -m "Rebuilt by bop."
	pkgos-check-changelog || true
	if [ "${PKGOS_RUN_UNIT_TESTS_AT_BUILD}" = "no" ] ; then
		if ! DEB_BUILD_OPTIONS=nocheck git-buildpackage ; then
			git reset --hard ${LAST_GIT_COMMIT}
			echo "There was an error when bop called git-buildpackage: exiting."
			exit 1
		else
			git reset --hard ${LAST_GIT_COMMIT}
		fi
	else
		if ! git-buildpackage ; then
			git reset --hard ${LAST_GIT_COMMIT}
			echo "There was an error when bop called git-buildpackage: exiting."
			exit 1
		else
			git reset --hard ${LAST_GIT_COMMIT}
		fi
	fi
}

test_the_package () {
	echo "===> Lintian"
	lintian -I -E --pedantic --profile debian/openstack ../build-area/*.changes

	if [ x"$RUN_AUTOPKGTEST" = x"yes" ] ; then
		echo "===> Autopkgtest"
		set +e
		adt-run ../build-area/*.changes --- schroot "$AUTOPKGTEST_SCHROOT"
		RET=$?
		if [ $RET != 0 ] && [ $RET != 8 ] ; then
			echo "adt-run failed: $RET"
			exit $RET
		fi
		set -e
	fi
}

copy_to_ftparchive () {
	echo "===> Copying to the FTP repo"
	rm ../build-area/${PKG_NAME}_${NO_EPOC}${BPO_DISTRO_NUM}_*.build
	TARGET_FOLDER=${REPO_ROOT}/debian/pool/${TARGET_DISTRO}-${TARGET_OPENSTACK_REL}-backports/main/${PKG_NAME_FIRST_CHAR}/${PKG_NAME}
	rm -rf ${TARGET_FOLDER}
	mkdir -p ${TARGET_FOLDER}
	cp ../build-area/* ${TARGET_FOLDER}
}

cleanup_old_build
get_deb_version
create_orig_tar
bop_it
#test_the_package
copy_to_ftparchive
# Scan the repo to add the new package
pkgos-scan-repo
# Trigger webhook for rsync and status update
pkgos-trigger-odrm-hook