Hi all,

At Matthias's suggestion, I'm attaching here a script that I've been using
in Ubuntu to trigger library package transitions for the g++5 ABI change. 
It needs a bit of tuning to be usable in Debian (for instance, you probably
don't want to pull the source package from Ubuntu...  or try to write
transition files to the Ubuntu instance of the release team transition
tracker, as checked out on my local machine...  or upload a source package
to the Debian archive without building/testing/including binaries), but
hopefully it's a useful starting point for maintainers (or NMUers) who need
to update their packages for this ABI change.

Hope that helps,
-- 
Steve Langasek                   Give me a lever long enough and a Free OS
Debian Developer                   to set it on, and I can move the world.
Ubuntu Developer                                    http://www.debian.org/
slanga...@ubuntu.com                                     vor...@debian.org
#!/bin/sh

set -e

bendir=/home/vorlon/devel/canonical/ubuntu-transition-tracker-configs/monitor/ongoing

dry_run=false
no_update=false

while [ $# -gt 0 ]; do
        case $1 in
                --dry-run)
                        dry_run=:
                        ;;
                --no-update)
                        no_update=:
                        ;;
                *)
                        echo "Unknown argument: $1"
                        exit 1
                        ;;
        esac
        shift
done

sudo apt-get install wget ubuntu-dev-tools grep-dctrl devscripts equivs dput

rename_package() {
        oldpkg="$1"
        newpkg="$2"
        if [ -z "$1" ] || [ -z "$2" ]; then
                echo "Error: rename_package called with args '$@'"
                return 1
        fi

        # warning: sed can be hazardous to your mental health.
        sed -i -e"s/\([ |,=/]\)$oldpkg\([ |,:]\|$\)/\1$newpkg\2/g" \
                debian/control debian/control.in debian/rules
        if sed -n -e"/^Package:[[:space:]]*$newpkg[[:space:]]*\$/,/^Package:/p" 
debian/control \
           | grep -q Conflicts:
        then
                sed -i 
-e"/^Package:[[:space:]]*$newpkg[[:space:]]*\$/,/^Package:/ { s/^Conflicts:/& 
$oldpkg,/; }" \
                        debian/control debian/control.in
        else
                sed -i 
-e"/^Package:[[:space:]]*$newpkg[[:space:]]*\$/,/^Package:/ { 
/^Description:/i\\" \
                    -e "Conflicts: $oldpkg" -e '}' \
                        debian/control debian/control.in
        fi
        if sed -n -e"/^Package:[[:space:]]*$newpkg[[:space:]]*\$/,/^Package:/p" 
debian/control \
           | grep -q Replaces:
        then
                sed -i 
-e"/^Package:[[:space:]]*$newpkg[[:space:]]*\$/,/^Package:/ { s/^Replaces:/& 
$oldpkg,/; }" \
                        debian/control debian/control.in
        else
                sed -i 
-e"/^Package:[[:space:]]*$newpkg[[:space:]]*\$/,/^Package:/ { 
/^Description:/i\\" \
                    -e "Replaces: $oldpkg" -e '}' \
                        debian/control debian/control.in
        fi
        for dh_old in debian/$oldpkg.*; do
                if [ -e "$dh_old" ]; then
                        dh_new=$(echo $dh_old | sed -e"s/$oldpkg/$newpkg/")
                        mv -v $dh_old $dh_new
                        sed -i -e"s/\(^\|[ |,/]\)$oldpkg\([ 
|,:/]\|$\)/\1$newpkg\2/g" $dh_new
                fi
        done
}

if ! $no_update; then
        echo '========== Downloading Debian build logs =========='
        wget -q --mirror -nH --cut-dirs=3 -np -R '*index.html*' -P 
"debian-build-logs" \
                https://people.debian.org/~doko/logs/gcc5-20150701/
fi

echo '=============== Rebuilding packages ==============='
# change this if you want to force a package name change for a
# particular package
for F in debian-build-logs/*.log
#for F in flightcrew
do
        binpkgs=
        #binpkgs=libflightcrew0
        srcpkg=$(basename ${F%%_*})
        echo "Source package: $srcpkg"
        if [ -e blacklist.txt ] && grep -q "^$srcpkg\$" blacklist.txt
        then
                echo "  package blacklisted; skipping"
                continue
        fi

        if [ -z "$binpkgs" ] \
           && ! binpkgs=$(awk '/===== BEGIN GCC CXX11 symbols/ { print $6 }' $F 
| grep -v DEBIAN/symbols | sort -u)
        then
                echo "Error: no binary packages found in log for $srcpkg"
                continue
        fi
        if nonnumpkgs=$(echo "$binpkgs" | grep -vE '[0-9](\+\+)?(c2a?)?$'); then
                echo "Skipping non-numeric bin packages: $nonnumpkgs"
        fi
        if ! binpkgs=$(echo "$binpkgs" | grep -E '[0-9](\+\+)?(c2a?)?$'); then
                continue
        fi
        binpkgs=$(echo $binpkgs)

        # Find the most recent available source package known to us and check
        # its binaries.  Better done with launchpadlib, but requires switching
        # to python (which is probably sensible anyway, but grep-dctrl)
        # But it can definitely give a wrong answer relative to pull-lp-source.
        # hopefully sort's -V comparison gives us the right answer in most cases
        latestver=$(apt-cache showsrc "$srcpkg" 2>/dev/null | grep-dctrl -n 
-FPackage -X "$srcpkg" -sVersion -n | sort -V | tail -n1)
        if [ -z "$latestver" ]; then
                echo "Source package $srcpkg does not exist in Ubuntu, skipping"
                continue
        fi
        latestbinlist=$(apt-cache showsrc "$srcpkg" | grep-dctrl -FPackage -X 
"$srcpkg" -a -FVersion -X "$latestver" -sBinary -n)
        rename_needed=false
        for binpkg in $binpkgs; do
                if echo $latestbinlist | grep -q "\(^\| \)$binpkg\(, \|$\)"; 
then
                        echo "$binpkg still present in latest source, update 
needed."
                        rename_needed=:
                        break
                fi
        done
        if ! $rename_needed; then
                echo "$srcpkg has already been transitioned (old binaries: 
$binpkgs; current binaries: $latestbinlist)"
                continue
        fi

        echo "Rebuilding $srcpkg"
        if $dry_run; then
                continue
        fi

        pull-lp-source $srcpkg
        build_failed=false
        (cd ${srcpkg}-*
         dch 'Rename library packages for g++5 ABI transition.'

         for binpkg in $binpkgs; do
                case $binpkg in
                        *[0-9]c2|*[0-9]c2a)
                                newpkg=${binpkg%c2*}v5
                                ;;
                        *)
                                newpkg=${binpkg}v5
                                ;;
                esac
                rename_package "$binpkg" "$newpkg"
                case $latestbinlist in
                        *${binpkg}-dbg*)
                                rename_package "${binpkg}-dbg" "${newpkg}-dbg"
                                ;;
                        *) ;;
                esac
         done
         update-maintainer
         dch -r -D wily ''
         sudo mk-build-deps -i -r -t 'apt-get --no-install-recommends -y'
         debuild -S
        ) || build_failed=:

        if $build_failed; then
                rm -r ${srcpkg}[-_]*
                continue
        fi

        fname="$bendir/${srcpkg}-g++5.ben"
        affected=
        good=
        bad=
        for binpkg in $binpkgs; do
                oldpkg=$(echo $binpkg | sed -e's/\+/\\+/g')
                case $oldpkg in
                        *[0-9]c2|*[0-9]c2a)
                                newpkg=${oldpkg%c2*}v5
                                ;;
                        *)
                                newpkg=${oldpkg}v5
                                ;;
                esac
                affected="$affected${affected:+|}$oldpkg|$newpkg"
                good="$good${good:+|}$newpkg"
                bad="$bad${bad:+|}$oldpkg"
                case $latestbinlist in
                        *${binpkg}-dbg*)
                                oldpkg=$(echo $binpkg | sed -e's/\+/\\+/g')-dbg
                                case $oldpkg in
                                        *[0-9]c2|*[0-9]c2a)
                                                newpkg=${oldpkg%c2*}v5-dbg
                                                ;;
                                        *)
                                                newpkg=${oldpkg}v5-dbg
                                                ;;
                                esac
                                
affected="$affected${affected:+|}$oldpkg|$newpkg"
                                good="$good${good:+|}$newpkg"
                                bad="$bad${bad:+|}$oldpkg"
                                ;;
                        *) ;;
                esac
        done
        echo 'title = "'"$srcpkg g++5 ABI transition"'";' > $fname
        echo "is_affected = .depends ~ /(^| )($affected)\s*([,(:]|$)/;" >> 
$fname
        echo "is_good = .depends ~ /(^| )($good)\s*([,(:]|$)/;" >> $fname
        echo "is_bad = .depends ~ /(^| )($bad)\s*([,(:]|$)/;" >> $fname
        (cd $bendir; bzr add $(basename $fname))

        if [ -n "$(find ${srcpkg}-*/debian -maxdepth 1 -name '*.symbols*' 
-print)" ]
        then
                echo "Error: package $srcpkg uses symbols files, needs manual 
attention."
                exit 1
        fi

        dput ${srcpkg}*_source.changes
        rm -r ${srcpkg}[-_]*
done
# bug closed by Debian maintainer as no transition required
cld2
cln
concordance
cppdb
curlpp
elektra
exempi
ffms2
geographiclib
gromacs
libabigail
libcsfml
libopendbx
librevisa
libsass
libsbsms
mp4v2
pgmodeler
qt4-x11
simple-tpm-pk11
sleuthkit

# removed from Debian, needs removed from Ubuntu...
dirac
libmath++
net6

# manually transitioned; no package name change for jackd2 binary
jackd2

# just-merged version has new soname vs. wily
libecap

# sort -V can't figure out which end is up
libmusicbrainz5

# should skip
llvm-toolchain-snapshot
qtwebkit-opensource-src
qttools-opensource-src
qt-gstreamer

# exclude until we know what's going on
kdepimlibs

# symbols files, and qt4+boost
libktorrent

# symbols files, skipping these.

Attachment: signature.asc
Description: Digital signature

Reply via email to