1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
|
#!/bin/bash
# Debian's Automated Developer a.k.a Dad
#
# Dad prepares an updated Debian package in an own Git repository and
# offers the update for review and possibly inclusion in the official
# packaging.
#
# Copyright (C) 2017 Balint Reczey <balint@balintreczey.hu>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
set -e
DEBEMAIL="debian-dad@example.com"
DEBFULLNAME="Debian's Assistant Developer"
usage() {
cat <<EOF
Usage: $0 [-h ] [--help] <command> [<args>]
Debian's Automated Developer for updating packages automatically
Commands:
init [source package] Set up workspace for updating the source package in
an identically named directory. If no source package
name is given the current directory name is used as
the source package name.
The workspace includes the Git packaging repository,
the "tarball" and "build-area" directories and
other meta-data.
update-upstream Update source package with latest upstream release
refreshing patches.
update-symbols Update symbols file(s) using latest Debian buildd
logs.
EOF
}
dad_init() {
local src repo
src="$1"
if [ -z "$src" ]; then
# assume the current directory is to be used and interpret its name as
# the package name
src="$(basename $(pwd))"
fi
if ! apt-cache showsrc "$src" 2>&1 | grep -q "^Package:"; then
(>&2 echo "Source package $src is not found.")
exit 1
fi
if [ "$1" != "" ]; then
mkdir $src || (>&2 echo "Directory $package already exists, exiting to avoid breaking something.")
cd $src
fi
mkdir -p build-area tarballs
# get original source, most likely for the original tarballs only
(cd build-area && apt-get source --download-only $src)
repo=$(apt-cache showsrc $src | grep -m 1 "^Vcs-Git:" | cut -d" " -f2)
if [ -n "$repo" ]; then
# start from the packaging dir
git clone $repo ${src}.git
# TODO figure out packaging layout, assume default gbp layout for now everywhere
else
# create a new temporary packaging repository
gbp import-dsc build-area/${src}_*.dsc ${src}.git
fi
pushd ${src}.git
git checkout upstream > /dev/null
git checkout pristine-tar > /dev/null 2>&1 || true
git checkout master
# mark Dad's commits clearly
git config user.name "Debian's Automated Developer"
# TODO maybe switch to Dad's development mailing list with the email
git config user.email "debian-dad@example.com"
if [ "$(dpkg-parsechangelog -S Distribution)" != "UNRELEASED" ]; then
EDITOR=touch dch -i --no-auto-nmu
git commit -m 'Start working on new upload' debian/changelog
fi
popd
}
# Try updating the package to latest upstream version
# (based on gbp-try-ff example)
dad_update_upstream() {
local src
src="$(basename $(pwd))"
pushd ${src}.git
if uscan --destdir ../tarballs; then
gbp pq import --force
# TODO assuming master to be default packaging branch here
git checkout master
gbp import-orig --no-interactive ../tarballs/$(ls -t ../tarballs/ | head -n1)
if ! gbp pq rebase; then
echo "Automatic rebase failed"
git rebase --abort
exit 1
fi
gbp pq export --commit
# TODO revise changelog update
gbp dch -S -a
fi
}
dad_collect_patches() {
# TODO download and apply patches from BTS & Launchpad bugs tagged as patch,
# like localizations & generic patches
return 0
}
dad_update_symbols() {
local src dad_tmp version
src="$(basename $(pwd))"
pushd ${src}.git
if ls debian/*symbols > /dev/null 2>&1 ; then
dad_tmp=$(mktemp -d)
trap "rm -rf $dad_tmp" EXIT
pkgkde-getbuildlogs -d $dad_tmp
version=$(grep -R -m 1 "Build log" $(ls $dad_tmp/* | head -n1) | sed 's/[^(]*(//;s/).*//')
# TODO error handling
pkgkde-symbolshelper batchpatch -v "$version~" $dad_tmp || true
if git diff --stat | grep -q symbols; then
git add -u
git commit -m 'Update symbols file(s)'
fi
rm -rf $dad_tmp
trap - EXIT
fi
popd
}
case "$1" in
-h|--help)
usage
exit 0
;;
-v|--version)
cat <<EOF
dad (Debian's Automated Developer) @version@
Copyright (C) 2017 Balint Reczey
License AGPLv3+: GNU Affero GPL version 3 or later
<https://gnu.org/licenses/agpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Balint Reczey
EOF
exit 0
;;
init)
shift
dad_init "$@"
;;
collect-patches)
dad_collect_patches
;;
update-symbols)
dad_update_symbols
;;
update-upstream)
dad_update_upstream
;;
update)
# perform all the updates
dad_update_symbols
dad_update_upstream
dad_collect_patches
# dad_update_... -
;;
*)
usage
exit 1
esac
|