| 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 |
deb_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" -a -n "$DEB_RELEASE"; then |
| 74 |
if grep -Eq '^OBS-DCH-RELEASE: 1' $BUILD_ROOT$TOPDIR/SOURCES/$RECIPEFILE; then |
| 75 |
OBS_DCH_RELEASE="+$DEB_RELEASE" |
| 76 |
else |
| 77 |
OBS_DCH_RELEASE="$DEB_RELEASE" |
| 78 |
fi |
| •79 |
deb_chroot $BUILD_ROOT su -c /bin/sh <<EOF |
| 80 |
cd $TOPDIR/BUILD |
| 81 |
[ ! -f debian/changelog ] && exit 0 |
| 82 |
# avoid devscripts dependency and mimic dch |
| 83 |
PACKAGE=\$(dpkg-parsechangelog 2> /dev/null | grep -E '^Source:' | awk '{ print \$NF }') |
| 84 |
VERSION=\$(dpkg-parsechangelog 2> /dev/null | grep -E '^Version:' | awk '{ print \$NF }') |
| •85 |
DISTRO=\$(dpkg-parsechangelog 2> /dev/null | grep -E '^Distribution:' | awk '{ print \$NF }') |
| 86 |
URGENCY=\$(dpkg-parsechangelog 2> /dev/null | grep -E '^Urgency:' | awk '{ print \$NF }') |
| 87 |
DATE=\$(dpkg-parsechangelog 2> /dev/null | grep -E '^Date:' | awk '{ \$1=""; print substr(\$0,2) }') |
| 88 |
|
| 89 |
echo "\${PACKAGE} (\${VERSION}${OBS_DCH_RELEASE}) \${DISTRO}; urgency=\${URGENCY}" > .changelog.tmp |
| 90 |
echo "" >> .changelog.tmp |
| 91 |
echo " * OBS build ${OBS_DCH_RELEASE}" >> .changelog.tmp |
| 92 |
echo "" >> .changelog.tmp |
| 93 |
echo " -- OBS Build <obs@buildd> \${DATE}" >> .changelog.tmp |
| 94 |
echo "" >> .changelog.tmp |
| 95 |
cat debian/changelog >> .changelog.tmp |
| 96 |
mv .changelog.tmp debian/changelog |
| 97 |
EOF |
| 98 |
fi |
| 99 |
|
| 100 |
} |
| 101 |
|
| 102 |
dsc_build() { |
| 103 |
local buildroot=$1 |
| •104 |
local changes |
| 105 |
local f |
| 106 |
|
| •107 |
echo "==== Kernel ====" |
| 108 |
echo |
| 109 |
uname -a || true |
| 110 |
echo |
| 111 |
|
| 112 |
echo "==== Filesystems in build chroot ====" |
| 113 |
echo |
| •114 |
su_deb_chroot "$buildroot" "cat /proc/self/mountinfo" || true |
| 115 |
echo |
| 116 |
|
| 117 |
echo "==== User identity in build chroot ====" |
| 118 |
echo |
| •119 |
su_deb_chroot "$buildroot" "id" || true |
| 120 |
echo |
| 121 |
|
| 122 |
echo "==== Environment variables in build chroot ====" |
| 123 |
echo |
| •124 |
su_deb_chroot "$buildroot" "env | LC_ALL=C sort -u" || true |
| 125 |
echo |
| 126 |
|
| 127 |
echo "==== Packages installed in build chroot ====" |
| 128 |
echo |
| •129 |
su_deb_chroot "$buildroot" "dpkg-query -W" || true |
| 130 |
echo |
| 131 |
|
| 132 |
DSC_BUILD_OPTIONS= |
| 133 |
if test -n "$BUILD_JOBS" ; then |
| 134 |
DSC_BUILD_OPTIONS="parallel=${BUILD_JOBS}" |
| 135 |
fi |
| 136 |
# Checks to see if a build script should be used |
| 137 |
# this allows the build environment to be manipulated |
| 138 |
# and alternate build commands can be used |
| 139 |
DSC_BUILD_CMD="$(queryconfig --dist "$BUILD_DIST" --archpath "$BUILD_ARCH" --configdir "$CONFIG_DIR" substitute dsc:build_cmd)" |
| •140 |
test -z "$DSC_BUILD_CMD" && DSC_BUILD_CMD="dpkg-buildpackage -us -uc -b" |
| 141 |
if test -e $buildroot/$TOPDIR/SOURCES/build.script ; then |
| 142 |
echo "Sourcing build.script to build - it should normally run 'dpkg-buildpackage -us -uc'" |
| 143 |
DSC_BUILD_CMD="source $TOPDIR/SOURCES/build.script" |
| 144 |
chmod +x $buildroot/$TOPDIR/SOURCES/build.script |
| 145 |
fi |
| 146 |
|
| •147 |
su_deb_chroot $buildroot "export DEB_BUILD_OPTIONS=${DSC_BUILD_OPTIONS} ; cd $TOPDIR/BUILD && $DSC_BUILD_CMD" && BUILD_SUCCEEDED=true |
| •148 |
|
| 149 |
for changes in "$buildroot/$TOPDIR"/*.changes ; do |
| 150 |
echo |
| 151 |
echo "==== $(basename "$changes") ====" |
| 152 |
echo |
| 153 |
cat "$changes" |
| 154 |
echo |
| 155 |
|
| 156 |
while read f ; do |
| 157 |
case "$f" in |
| 158 |
(*.buildinfo) |
| 159 |
echo "==== $f ====" |
| 160 |
echo |
| 161 |
cat "$buildroot/$TOPDIR/$f" |
| 162 |
echo |
| 163 |
esac |
| 164 |
done < <(sed -ne '/Files:/,$s/^ ................................ [0-9][0-9]* [^ ]* [^ ]* //p' "$changes") |
| 165 |
|
| 166 |
while read f ; do |
| 167 |
case "$f" in |
| 168 |
(*.deb|*.ddeb|*.udeb) |
| 169 |
echo "==== $f ====" |
| 170 |
echo |
| •171 |
su_deb_chroot "$buildroot" "dpkg-deb --info $(printf '%q' "$TOPDIR/$f")" || true |
| 172 |
echo |
| •173 |
su_deb_chroot "$buildroot" "dpkg-deb --contents $(printf '%q' "$TOPDIR/$f")" || true |
| 174 |
echo |
| 175 |
esac |
| 176 |
done < <(sed -ne '/Files:/,$s/^ ................................ [0-9][0-9]* [^ ]* [^ ]* //p' "$changes") |
| 177 |
done |
| 178 |
|
| •179 |
if test "$BUILD_SUCCEEDED" = true -a "$DO_CHECKS" != "false" && ( chroot $buildroot su -c "which lintian > /dev/null" - $BUILD_USER < /dev/null ); then |
| 180 |
DEB_CHANGESFILE=${DEB_DSCFILE%.dsc}$OBS_DCH_RELEASE"_"$(chroot $buildroot su -c 'dpkg-architecture -qDEB_BUILD_ARCH')".changes" |
| 181 |
su_deb_chroot $buildroot "cd $TOPDIR && echo Running lintian && (set -x && lintian -i $TOPDIR/$DEB_CHANGESFILE)" || BUILD_SUCCEEDED=false |
| 182 |
fi |
| 183 |
} |
| 184 |
|
| 185 |
dsc_move_build_result() { |
| 186 |
local changes |
| 187 |
|
| 188 |
for changes in $BUILD_ROOT/$TOPDIR/*.changes ; do |
| 189 |
while read f ; do |
| 190 |
mv "$BUILD_ROOT/$TOPDIR/$f" "$BUILD_ROOT/$TOPDIR/DEBS/" |
| 191 |
done < <(sed -ne '/Files:/,$s/^ ................................ [0-9][0-9]* [^ ]* [^ ]* //p' "$changes") |
| 192 |
mv "$changes" "$BUILD_ROOT/$TOPDIR/DEBS" |
| 193 |
done |
| 194 |
|
| 195 |
# link used sources over to DEB directory |
| 196 |
ln $BUILD_ROOT/$DEB_SOURCEDIR/$DEB_DSCFILE $BUILD_ROOT/$TOPDIR/DEBS/ |
| 197 |
while read f ; do |
| 198 |
ln $BUILD_ROOT/$DEB_SOURCEDIR/$f $BUILD_ROOT/$TOPDIR/DEBS/ |
| 199 |
done < <(sed -ne '/^Files:/,$s/^ ................................ [0-9][0-9]* //p' < $BUILD_ROOT/$DEB_SOURCEDIR/$DEB_DSCFILE) |
| 200 |
} |
| 201 |
|
| 202 |
|
| 203 |
recipe_build_dsc() { |
| 204 |
dsc_build "$BUILD_ROOT" |
| 205 |
dsc_move_build_result |
| 206 |
} |
| 207 |
|
| 208 |
recipe_resultdirs_dsc() { |
| 209 |
echo DEBS |
| 210 |
} |
| 211 |
|
| 212 |
recipe_cleanup_dsc() { |
| 213 |
: |
| 214 |
} |