Debian Codegraph @

build-recipe-dsc

raw ◀ ▶
Source reconstructed at patch state 1 of 6 — not the installed (fully patched) source.
6 Debian patches touch this file
1 #
2 # dsc specific functions.
3 #
4 ################################################################
5 #
6 # Copyright (c) 1995-2014 SUSE Linux Products GmbH
7 #
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.
11 #
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.
16 #
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
21 #
22 ################################################################
23
24 recipe_setup_dsc() {
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"
36 CREATE_BASELIBS=true
37 fi
38 }
39
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"
44 DEB_TRANSFORM=
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
49 done
50 # remove rpm macros (everything after "%")
51 # they are not evaluated by the Debian build process
52 DEB_RELEASE=`sed 's/%.*$//' <<< $RELEASE`
53 OBS_DCH_RELEASE=""
54
55 if test -n "$DEB_TRANSFORM" ; then
56 CHANGELOGARGS=
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"
62 fi
63 if ! debtransform $CHANGELOGARGS $RELEASEARGS $BUILD_ROOT$TOPDIR/SOURCES $BUILD_ROOT$TOPDIR/SOURCES/$RECIPEFILE $BUILD_ROOT$TOPDIR/SOURCES.DEB ; then
64 cleanup_and_exit 1 "debian transforming failed."
65 fi
66 DEB_SOURCEDIR=$TOPDIR/SOURCES.DEB
67 for DEB_DSCFILE in $BUILD_ROOT/$DEB_SOURCEDIR/*.dsc ; do : ; done
68 DEB_DSCFILE="${DEB_DSCFILE##*/}"
69 fi
70 chroot $BUILD_ROOT su -c "dpkg-source -x $DEB_SOURCEDIR/$DEB_DSCFILE $TOPDIR/BUILD" - $BUILD_USER
71
72 # Alternative to debtransform: apply OBS release number if tag OBS-DCH-RELEASE is set.
73 if test -z "$DEB_TRANSFORM" && grep -Eq '^OBS-DCH-RELEASE: 1' $BUILD_ROOT$TOPDIR/SOURCES/$RECIPEFILE; then
74 OBS_DCH_RELEASE="+$DEB_RELEASE"
75 chroot $BUILD_ROOT su -c /bin/sh <<EOF
76 cd $TOPDIR/BUILD
77 [ ! -f debian/changelog ] && exit 0
78 # avoid devscripts dependency and mimic dch
79 PACKAGE=\$(dpkg-parsechangelog 2> /dev/null | grep -E '^Source:' | awk '{ print \$NF }')
80 VERSION=\$(dpkg-parsechangelog 2> /dev/null | grep -E '^Version:' | awk '{ print \$NF }')
81 sed -i "s/\${PACKAGE} (\${VERSION})/\${PACKAGE} (\${VERSION}$OBS_DCH_RELEASE)/" debian/changelog
82 EOF
83 fi
84
85 }
86
87 dsc_build() {
88 local buildroot=$1
89
90 DSC_BUILD_OPTIONS=
91 if test -n "$BUILD_JOBS" ; then
92 DSC_BUILD_OPTIONS="parallel=${BUILD_JOBS}"
93 fi
94 # Checks to see if a build script should be used
95 # this allows the build environment to be manipulated
96 # and alternate build commands can be used
97 DSC_BUILD_CMD="$(queryconfig --dist "$BUILD_DIST" --archpath "$BUILD_ARCH" --configdir "$CONFIG_DIR" substitute dsc:build_cmd)"
98 test -z "$DSC_BUILD_CMD" && DSC_BUILD_CMD="dpkg-buildpackage -us -uc -b"
99 if test -e $buildroot/$TOPDIR/SOURCES/build.script ; then
100 echo "Sourcing build.script to build - it should normally run 'dpkg-buildpackage -us -uc'"
101 DSC_BUILD_CMD="source $TOPDIR/SOURCES/build.script"
102 chmod +x $buildroot/$TOPDIR/SOURCES/build.script
103 fi
104
105 chroot $buildroot su -c "export DEB_BUILD_OPTIONS=${DSC_BUILD_OPTIONS} ; cd $TOPDIR/BUILD && $DSC_BUILD_CMD" - $BUILD_USER < /dev/null && BUILD_SUCCEEDED=true
106 if test "$BUILD_SUCCEEDED" = true -a "$DO_CHECKS" != "false" && ( chroot $buildroot su -c "which lintian > /dev/null" - $BUILD_USER < /dev/null ); then
107 DEB_CHANGESFILE=${DEB_DSCFILE%.dsc}$OBS_DCH_RELEASE"_"$(chroot $buildroot su -c 'dpkg-architecture -qDEB_BUILD_ARCH')".changes"
108 chroot $buildroot su -c "cd $TOPDIR && echo Running lintian && (set -x && lintian -i $TOPDIR/$DEB_CHANGESFILE)" - $BUILD_USER < /dev/null || BUILD_SUCCEEDED=false
109 fi
110 }
111
112 dsc_move_build_result() {
113 local changes
114
115 for changes in $BUILD_ROOT/$TOPDIR/*.changes ; do
116 while read f ; do
117 mv "$BUILD_ROOT/$TOPDIR/$f" "$BUILD_ROOT/$TOPDIR/DEBS/"
118 done < <(sed -ne '/Files:/,$s/^ ................................ [0-9][0-9]* [^ ]* [^ ]* //p' "$changes")
119 mv "$changes" "$BUILD_ROOT/$TOPDIR/DEBS"
120 done
121
122 # link used sources over to DEB directory
123 ln $BUILD_ROOT/$DEB_SOURCEDIR/$DEB_DSCFILE $BUILD_ROOT/$TOPDIR/DEBS/
124 while read f ; do
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)
127 }
128
129
130 recipe_build_dsc() {
131 dsc_build "$BUILD_ROOT"
132 dsc_move_build_result
133 }
134
135 recipe_resultdirs_dsc() {
136 echo DEBS
137 }
138
139 recipe_cleanup_dsc() {
140 :
141 }