6 echo "usage: dcp-init [-sh] [-C key=val] [-d REPODIR] PACKAGE [(PATCH|-m)...]"
7 echo " PATCH ::= [-p LEVEL] [-bB BRANCH] FILE"
8 echo " -b creates a new branch at the current patch"
9 echo " -B creates a new branch at the upstream sources"
10 echo " -m merges the current branch into the master branch"
22 (cd "$td/apt-tmp"; apt-get source "$1") || false
25 for f in "$td/apt-tmp"/*; do
27 if [ -z "$sdir" ]; then
30 echo "dcp-init: got more than one directory from apt-get; cannot continue" >&2
35 if [ -z "$sdir" ]; then
36 echo "dcp-init: could not find any source directory" >&2
48 touch "$td/control/conf"
50 rungit commit -q -m "Initial repo"
55 mkdir "$td/control/build.d"
56 mkdir "$td/control/update.d"
57 cat >"$td/control/functions" <<EOF
59 if [ -r "\$HOME/.dcp-build-conf" ]; then
60 while read key val; do
61 export "CONF_\$key"="\$val"
62 done <"\$HOME/.dcp-build-conf"
64 if [ -r "/etc/dcp-conf" ]; then
65 while read key val; do
66 export "CONF_\$key"="\$val"
69 while read key val; do
70 export "CONF_\$key"="\$val"
75 (cd repo; git "\$@") || false
79 tag="\${CONF_VERTAG:-dcp}"
80 ver="\$(dpkg-parsechangelog -lrepo/src/debian/changelog | sed -n 's/^Version: \(.*\)$/\1/p')"
82 maint="\$CONF_MAINTAINER"
83 if [ -z "\$maint" ]; then
84 maint="\$(id -un) <\$(id -un)@\$(hostname -f)>"
86 cat - repo/src/debian/changelog >repo/src/debian/changelog.new <<ENDCL
87 \${CONF_APTPKG} (\${ver}+\${tag}1) unstable; urgency=low
89 * Remerged changes in DCP
91 -- \${maint} \$(date -R)
93 mv -f repo/src/debian/changelog.new repo/src/debian/changelog
96 cat >"$td/control/build" <<EOF
104 for file in control/build.d/*; do
105 if [ -x "\$file" ]; then "\$file"; fi
108 chmod 755 "$td/control/build"
109 cat >"$td/control/update" <<EOF
118 for branch in repo/.git/refs/heads/*; do
119 branch="\${branch##*/}"
120 if [ -x "control/update.d/\$branch" ]; then
121 rungit checkout "\$branch"
122 lastrev="\$(rungit rev-parse HEAD)"
123 "control/update.d/\$branch"
124 newrev="\$(rungit rev-parse HEAD)"
125 rungit checkout master
126 if [ "\$newrev" != "\$lastrev" ]; then
127 rungit merge -n "\$branch"
133 if [ "\$updated" = y ]; then
134 for file in control/update.d/post-*; do
135 if [ -x "\$file" ]; then "\$file"; fi
139 chmod 755 "$td/control/update"
144 cat >"$td/control/build.d/99dpkg" <<EOF
149 cmd=(dpkg-buildpackage -b -rfakeroot)
150 if [ -n "\$CONF_MAINTAINER" ]; then
151 cmd=("\${cmd[@]}" "-m\$CONF_MAINTAINER")
153 if [ -n "\$CONF_GPGKEY" ]; then
154 cmd=("\${cmd[@]}" "-k\$CONF_GPGKEY")
156 (cd repo/src; "\${cmd[@]}") || false
157 mv repo/*.deb output/
159 chmod 755 "$td/control/build.d/99dpkg"
160 rungit add control/build.d/99dpkg
161 cat >"$td/control/update.d/upstream" <<EOF
169 dcp-update-apt "\$CONF_APTPKG"
171 chmod 755 "$td/control/update.d/upstream"
172 rungit add control/update.d/upstream
173 cat >"$td/control/update.d/post-logchange" <<EOF
180 rungit add src/debian/changelog
181 rungit commit -q -m "Added changelog entry"
184 echo "APTPKG $pkg" >>"$td/control/conf"
185 rungit add control/conf
193 while [ "${1:0:1}" = - ]; do
196 if [ "$opt" = d ]; then
199 elif [ "$opt" = h ]; then
202 elif [ "$opt" = s ]; then
204 elif [ "$opt" = C ]; then
205 confopts=("${confopts[@]}" "$1")
208 echo "dcp-init: unknown option '$opt'" >&2
213 if [ $# -lt 1 ]; then
219 if [ -z "$repodir" ]; then repodir="$pkg"; fi
220 if [[ "$repodir" != */* ]]; then
221 repodir="$defdir/${repodir}.git"
224 td="$(mktemp -d "/tmp/dcp-XXXXXX")"
228 rungit commit -q -m "Base control files"
230 if [ "${#confopts[@]}" -gt 0 ]; then
231 for opt in "${confopts[@]}"; do
234 echo "$key $val" >>"$td/control/conf"
236 rungit add control/conf
237 rungit commit -q -m "Custom configuration file"
240 rungit checkout -q -b upstream empty
242 rungit commit -q -m "Initial upstream import"
243 rungit checkout master
244 rungit merge -n upstream
247 rungit commit -q -m "APT control files"
254 while [ $# -gt 0 ]; do
257 if [ "${arg:0:1}" = - ]; then
258 if [ "$arg" = -p ]; then
261 elif [ "$arg" = -b ]; then
264 rungit checkout -q -b "$curbranch"
265 elif [ "$arg" = -B ]; then
268 rungit checkout -q -b "$curbranch" upstream
269 elif [ "$arg" = -m ]; then
270 rungit checkout -q master
271 rungit merge -n "$curbranch"
273 echo "dcp-init: unknown patch option '$arg'" >&2
278 if [[ "$arg" == *.gz ]]; then
283 ) | patch -d "$td/src" -p"$level"
285 rungit commit -q -m "Applied $(basename "$arg")"
290 git clone -q --bare "$td" "$repodir"
291 if [ "$shared" = y ]; then
292 chmod -R g+w "$repodir"
293 td="$repodir" rungit config core.sharedrepository 1