2 # dsc specific functions.
4 ################################################################
6 # Copyright (c) 1995-2014 SUSE Linux Products GmbH
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License version 2 or 3 as
10 # published by the Free Software Foundation.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program (see the file COPYING); if not, write to the
19 # Free Software Foundation, Inc.,
20 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 ################################################################
25 TOPDIR=/usr/src/packages
26 test "$DO_INIT_TOPDIR" = false || rm -rf "$BUILD_ROOT$TOPDIR"
27 mkdir -p "$BUILD_ROOT$TOPDIR"
28 mkdir -p "$BUILD_ROOT$TOPDIR/OTHER"
29 mkdir -p "$BUILD_ROOT$TOPDIR/SOURCES"
30 mkdir -p "$BUILD_ROOT/$TOPDIR/DEBS"
31 chown -R "$ABUILD_UID:$ABUILD_GID" "$BUILD_ROOT$TOPDIR"
32 cp -p "$MYSRCDIR"/* $BUILD_ROOT$TOPDIR/SOURCES/
33 # FIX to work with baselibs_$PROJ etc
34 if test -e "$MYSRCDIR/baselibs-deb.conf" ; then
35 echo "dsc build and baselibs-deb.conf present: forcing --baselibs to true"
40 recipe_prepare_dsc() {
41 rm -rf "$BUILD_ROOT$TOPDIR/BUILD"
42 mkdir -p "$BUILD_ROOT$TOPDIR/SOURCES.DEB"
43 chown -R "$ABUILD_UID:$ABUILD_GID" "$BUILD_ROOT$TOPDIR"
45 DEB_SOURCEDIR="$TOPDIR/SOURCES"
46 DEB_DSCFILE="$RECIPEFILE"
47 for f in $BUILD_ROOT$TOPDIR/SOURCES/debian.* ; do
48 test -f $f && DEB_TRANSFORM=true
50 # remove rpm macros (everything after "%")
51 # they are not evaluated by the Debian build process
52 DEB_RELEASE=`sed 's/%.*$//' <<< $RELEASE`
55 if test -n "$DEB_TRANSFORM" ; then
57 test -n "$CHANGELOG" -a -f "$BUILD_ROOT/.build-changelog" && CHANGELOGARGS="--changelog $BUILD_ROOT/.build-changelog"
58 echo "Found files matching debian.*, running debian transformer..."
59 if [ "$RELEASE" ]; then
60 echo "release: ($RELEASE), release (DEB) ($DEB_RELEASE)"
61 RELEASEARGS="--release $DEB_RELEASE"
63 if ! debtransform $CHANGELOGARGS $RELEASEARGS $BUILD_ROOT$TOPDIR/SOURCES $BUILD_ROOT$TOPDIR/SOURCES/$RECIPEFILE $BUILD_ROOT$TOPDIR/SOURCES.DEB ; then
64 echo "debian transforming failed."
67 DEB_SOURCEDIR=$TOPDIR/SOURCES.DEB
68 for DEB_DSCFILE in $BUILD_ROOT/$DEB_SOURCEDIR/*.dsc ; do : ; done
69 DEB_DSCFILE="${DEB_DSCFILE##*/}"
71 chroot $BUILD_ROOT su -c "dpkg-source -x $DEB_SOURCEDIR/$DEB_DSCFILE $TOPDIR/BUILD" - $BUILD_USER
73 # Alternative to debtransform: apply OBS release number if tag OBS-DCH-RELEASE is set.
74 if test -z "$DEB_TRANSFORM" && grep -Eq '^OBS-DCH-RELEASE: 1' $BUILD_ROOT$TOPDIR/SOURCES/$RECIPEFILE; then
75 OBS_DCH_RELEASE="+$DEB_RELEASE"
76 chroot $BUILD_ROOT su -c /bin/sh <<EOF
78 [ ! -f debian/changelog ] && exit 0
79 # avoid devscripts dependency and mimic dch
80 PACKAGE=\$(dpkg-parsechangelog 2> /dev/null | grep -E '^Source:' | awk '{ print \$NF }')
81 VERSION=\$(dpkg-parsechangelog 2> /dev/null | grep -E '^Version:' | awk '{ print \$NF }')
82 sed -i "s/\${PACKAGE} (\${VERSION})/\${PACKAGE} (\${VERSION}$OBS_DCH_RELEASE)/" debian/changelog
92 if test -n "$BUILD_JOBS" ; then
93 DSC_BUILD_OPTIONS="parallel=${BUILD_JOBS}"
95 # Checks to see if a build script should be used
96 # this allows the build environment to be manipulated
97 # and alternate build commands can be used
98 DSC_BUILD_CMD="$(queryconfig --dist "$BUILD_DIST" --archpath "$BUILD_ARCH" --configdir "$CONFIG_DIR" substitute dsc:build_cmd)"
99 test -z "$DSC_BUILD_CMD" && DSC_BUILD_CMD="dpkg-buildpackage -us -uc"
100 if test -e $buildroot/$TOPDIR/SOURCES/build.script ; then
101 echo "Sourcing build.script to build - it should normally run 'dpkg-buildpackage -us -uc'"
102 DSC_BUILD_CMD="source $TOPDIR/SOURCES/build.script"
103 chmod +x $buildroot/$TOPDIR/SOURCES/build.script
106 if test -n "$RUN_SHELL"; then
107 chroot $buildroot su -
109 chroot $buildroot su -c "export DEB_BUILD_OPTIONS=${DSC_BUILD_OPTIONS} ; cd $TOPDIR/BUILD && $DSC_BUILD_CMD" - $BUILD_USER < /dev/null && BUILD_SUCCEEDED=true
110 if test "$BUILD_SUCCEEDED" = true -a "$DO_CHECKS" != "false" && ( chroot $buildroot su -c "which lintian > /dev/null" - $BUILD_USER < /dev/null ); then
111 DEB_CHANGESFILE=${DEB_DSCFILE%.dsc}$OBS_DCH_RELEASE"_"$(chroot $buildroot su -c 'dpkg-architecture -qDEB_BUILD_ARCH')".changes"
112 chroot $buildroot su -c "cd $TOPDIR && echo Running lintian && (set -x && lintian -i $TOPDIR/$DEB_CHANGESFILE)" - $BUILD_USER < /dev/null || BUILD_SUCCEEDED=false
117 dsc_move_build_result() {
118 for DEB in $BUILD_ROOT/$TOPDIR/*.{deb,changes} ; do
119 test -e "$DEB" && mv "$DEB" "$BUILD_ROOT/$TOPDIR/DEBS"
122 # link used sources over to DEB directory
123 ln $BUILD_ROOT/$DEB_SOURCEDIR/$DEB_DSCFILE $BUILD_ROOT/$TOPDIR/DEBS/
125 ln $BUILD_ROOT/$DEB_SOURCEDIR/$f $BUILD_ROOT/$TOPDIR/DEBS/
126 done < <(sed -ne '/^Files:/,$s/^ ................................ [0-9][0-9]* //p' < $BUILD_ROOT/$DEB_SOURCEDIR/$DEB_DSCFILE)
131 dsc_build "$BUILD_ROOT"
132 dsc_move_build_result
135 recipe_resultdirs_dsc() {