Skip to content
GitLab
Explore
Sign in
Register
Commits on Source (3)
Add script to semi-automate backports
· f82311ce
Andreas Tille
authored
May 02, 2019
f82311ce
Automatic d/changelog editing seems to work as expected
· a06f37fc
Andreas Tille
authored
May 06, 2019
a06f37fc
Exit in case of error if appropriate
· fa1224a7
Andreas Tille
authored
May 10, 2019
fa1224a7
Show whitespace changes
Inline
Side-by-side
do_backport
0 → 100755
View file @
fa1224a7
#!/bin/sh -e
# automate all steps to backport a package
# Should be turned into a command line option later
FORCE
=
1
TARGETDIST
=
stretch
BRANCH
=
debian/
${
TARGETDIST
}
-backports
set
-x
git checkout
--quiet
master
tmppull
=
`
mktemp
/tmp/
$(
basename
$0
)
.XXXXXX
`
# not all error return codes of gbp pull are critical
gbp pull 2>&1 |
tee
>
$tmppull
||
true
# do not tolerate "uncommitted changes"
if
grep
'gbp:error: You have uncommitted changes in your source tree'
$tmppull
;
then
cat
$tmppull
rm
$tmppull
exit
1
fi
rm
$tmppull
DIST
=
`
dpkg-parsechangelog |
awk
'/^Distribution:/ {print $2}'
`
SPKG
=
`
dpkg-parsechangelog |
awk
'/^Source:/ {print $2}'
`
if
[
"
$DIST
"
!=
"unstable"
]
;
then
echo
'Current state of Git is not targeting "unstable"'
exit
1
fi
PKG
=
`
grep
"Package:"
debian/control |
head
-n1
|
awk
'/^Package:/ {print $2}'
`
VERSION
=
`
dpkg-parsechangelog |
awk
'/^Version:/ {print $2}'
|
sed
's/-[^-]\+$//'
`
if
!
apt-cache policy
$PKG
|
grep
-A3
$VERSION
|
grep
-q
testing
;
then
# FIXME: That's a bit weak
echo
"Package
$PKG
version
$VERSION
does not seem to be in testing (according local apt-cache)"
if
[
$FORCE
-ne
1
]
;
then
exit
1
fi
fi
exists
=
$(
git show-ref refs/heads/
$BRANCH
)
||
true
if
[
-n
"
$exists
"
]
;
then
git checkout
$BRANCH
LASTBACKPORTVERSION
=
$(
dpkg-parsechangelog |
awk
'/^Version:/ {print $2}'
)
git merge master
||
true
if
!
grep
-q
"
$LASTBACKPORTVERSION
"
debian/changelog
;
then
echo
"Last backports paragraph from version
$LASTBACKPORTVERSION
is missing in debian/changelog"
exit
1
fi
if
grep
-q
-e
'^<<<<<<<'
-e
'^======='
debian/changelog
;
then
echo
"There are merge issues in debian/changelog"
# try fixing sequence of changes in changelog
# Moving blocks in sed is not possible - thus use vim (== ex)
ex
"+2,/^=======/m/>>>>>>> master/"
-sc
'wq'
debian/changelog
sed
-i
-e
's/^>>>>>>> master$//'
-e
'/^=======$/d'
-e
'1d'
debian/changelog
# debug: check whether all is OK, if the above works several times remove next line
# edit debian/changelog
if
grep
-q
-e
'^<<<<<<<'
-e
'^======='
debian/control
;
then
echo
"There are merge issues in debian/changelog"
edit debian/changelog
fi
git commit
||
true
fi
dch
--bpo
""
else
git checkout
-b
$BRANCH
dch
--bpo
""
fi
git commit
-a
-m
"Rebuild for
${
TARGETDIST
}
-backports"
if
!
which gbp-build
>
/dev/null
;
then
echo
"Andreas Tille has a local script that cares for correct configuration of gbp for backports"
echo
"Either you create such a script yourself, nag Andreas to publish or call 'gbp buildpackage' manually"
exit
1
fi
gbp-build
if
[
-d
/var/cache/pbuilder/extra/
${
TARGETDIST
}
/packages/
]
;
then
cp
-a
../build-area/
${
SPKG
}
_
${
VERSION
}*
bpo
*
+1_a
*
.deb /var/cache/pbuilder/extra/
${
TARGETDIST
}
/packages/
fi
set
-x
TAG
=
debian/
`
dpkg-parsechangelog |
awk
'/^Version:/ {print $2}'
|
sed
-e
's/~/_/'
`
git tag
"
$TAG
"