]> pere.pagekite.me Git - homepage.git/blob - blog/images/2024-05-04-debian-snap-to-salsa.sh
Generated.
[homepage.git] / blog / images / 2024-05-04-debian-snap-to-salsa.sh
1 #!/bin/sh
2 #
3 # See also https://bugs.debian.org/804722#31
4
5 set -e
6
7 # Move to this Standards-Version.
8 SV_LATEST=4.7.0
9
10 PKG="$1"
11
12 if [ -z "$PKG" ]; then
13 echo "usage: $0 <PACKAGE>"
14 exit 1
15 fi
16
17 if [ -e "${PKG}-salsa" ]; then
18 echo "error: ${PKG}-salsa already exist, aborting."
19 exit 1
20 fi
21
22 if [ -z "ALLOWFAILURE" ] ; then
23 ALLOWFAILURE=false
24 fi
25
26 # Fetch every snapshotted source package. Manually loop until all
27 # transfers succeed, as 'gbp import-dscs --debsnap' do not fail on
28 # download failures.
29 until debsnap --force -v $PKG || $ALLOWFAILURE ; do sleep 1; done
30 mkdir ${PKG}-salsa; cd ${PKG}-salsa
31 git init
32 # Specify branches to override any debian/gbp.conf file present in the
33 # source package. Use DEP-14 branch layout.
34 gbp import-dscs \
35 --debian-branch=debian/latest \
36 --upstream-branch=upstream/latest \
37 --pristine-tar ../source-$PKG/*.dsc
38
39 # Document branch layout for gbp
40 inifile +inifile debian/gbp.conf +create +section DEFAULT +key debian-branch +value debian/latest
41 inifile +inifile debian/gbp.conf +section DEFAULT +key upstream-branch +value upstream/latest
42 git add debian/gbp.conf
43 git commit -m "Added d/gbp.conf to describe branch layout." debian/gbp.conf
44
45 # Add Vcs pointing to Salsa Debian project (must be manually created
46 # and pushed to).
47 if ! grep -q ^Vcs- debian/control ; then
48 awk "BEGIN { s=1 } /^\$/ { if (s==1) { print \"Vcs-Browser: https://salsa.debian.org/debian/$PKG\"; print \"Vcs-Git: https://salsa.debian.org/debian/$PKG.git\" }; s=0 } { print }" < debian/control > debian/control.new && mv debian/control.new debian/control
49 git commit -m "Updated vcs in d/control to Salsa." debian/control
50 fi
51
52 # Tell gbp to enforce the use of pristine-tar.
53 inifile +inifile debian/gbp.conf +section DEFAULT +key pristine-tar +value True
54 git add debian/gbp.conf
55 git commit -m "Updated d/gbp.conf to enforce the use of pristine-tar." debian/gbp.conf
56
57 # Update to latest Standards-Version.
58 SV="$(grep ^Standards-Version: debian/control|awk '{print $2}')"
59 if [ $SV_LATEST != $SV ]; then
60 sed -i "s/\(Standards-Version: \)\(.*\)/\1$SV_LATEST/" debian/control
61 git commit -m "Updated Standards-Version from $SV to $SV_LATEST." debian/control
62 fi
63
64 # Sort debian control files
65 wrap-and-sort -at
66 git commit -m "Use wrap-and-sort -at for debian control files" debian/*
67
68 if [ ! -e debian/source/format ] ; then
69 mkdir debian/source
70 echo '3.0 (quilt)' > debian/source/format
71 git add debian/source/format
72 git commit -m "Set Debian source package format to 3.0 (quilt)." debian/source/format
73 fi
74
75 if grep -q pkg-config debian/control; then
76 sed -i s/pkg-config/pkgconf/ debian/control
77 git commit -m "Replaced obsolete pkg-config build dependency with pkgconf." debian/control
78 fi
79
80 if grep -q libncurses5-dev debian/control; then
81 sed -i s/libncurses5-dev/libncurses-dev/ debian/control
82 git commit -m "Replaced obsolete libncurses5-dev build dependency with libncurses-dev." debian/control
83 fi
84
85 lintian-brush --no-update-changelog
86
87 # Create changelog entry
88 gbp dch --qa