-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmakeforwardport
executable file
·219 lines (191 loc) · 8.57 KB
/
makeforwardport
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
#!/bin/bash -ev
set -o pipefail
SCRIPTDIR=`dirname $(readlink -f $0)`
echo makeforwardport starting command: makeforwardport $1 $2 $3 $4 $5 $6
PACKAGE=$1
OLDVERSION=$2
DEBVERSION=$3
NEWVERSION=$4
TARGETSUITE=$5
BRANCHNAME=$6
source <($SCRIPTDIR/afpg_readconfig.py main:workingrepo main:gitdir main:tmp main:AFPGCONFIG main:localmarker main:revertmarker main:forwardportname main:forwardportemail main:outputdir main:dosbuild main:dodgitpush)
$SCRIPTDIR/afpg_readconfig.py main:workingrepo main:gitdir main:tmp main:AFPGCONFIG main:localmarker main:revertmarker main:forwardportname main:forwardportemail main:outputdir main:dosbuild main:dodgitpush
NEWVERSIONNOEPOCH=`echo ${NEWVERSION} | sed -e s/^[^:]://`
OLDVERSIONNOEPOCH=`echo ${OLDVERSION} | sed -e s/^[^:]://`
DEBVERSIONNOEPOCH=`echo ${DEBVERSION} | sed -e s/^[^:]://`
NEWTAG=`$SCRIPTDIR/versiontotag ${NEWVERSION}`
OLDTAG=`$SCRIPTDIR/versiontotag ${OLDVERSION}`
DEBTAG=`$SCRIPTDIR/versiontotag ${DEBVERSION}`
if [[ $PACKAGE == lib* ]]; then
PACKAGEDIR=${PACKAGE:0:4}/$PACKAGE
else
PACKAGEDIR=${PACKAGE:0:1}/$PACKAGE
fi
cd $tmp
rm -rf makeforwardport
mkdir makeforwardport
cd makeforwardport
git clone --no-checkout $gitdir/${PACKAGEDIR} tempgit
cd tempgit
dgit setup-gitattributes
git config --local user.name "$forwardportname"
git config --local user.email "$forwardportemail"
#make sure there is no current branch
#comment this line out, I belive it is no longer needed now we use --no-checkout and it seems to cause problems
#in certain situations involving gitattributes.
#git checkout -q --detach || true
git show ${OLDTAG}:debian/changelog > ../c1
BASEVERSION=`$SCRIPTDIR/findchangelogunmarkedversion ../c1 $localmarker'$'$revertmarker`
BASETAG=`$SCRIPTDIR/versiontotag ${BASEVERSION}`
git branch -f debpsuedomerge $DEBTAG
git checkout debpsuedomerge
#echo git merge -s ours --ff $BASETAG
#git merge -s ours --ff -m 'pseudomerge to tie together broken upstream history' --allow-unrelated-histories $BASETAG
#use a replace graft instead of a pseudomerge, hopefully this should avoid issues with git finding multiple merge-heads
#and should make the resulting git history neater too.
#allow graft to fail, sometimes the commit already has the parents we want
echo $BASETAG
git replace --graft debpsuedomerge $BASETAG || true
#echo `git rev-parse --verify debpsuedomerge` `git rev-parse --verify $BASETAG` > .git/info/grafts
#also use a replace graft to remove the parents of BASETAG, this avoids issues when BASETAG is a child of NEWTAG
#(can happen when using makeforwardport to bring changes forward from stable to testing)
git replace --graft $BASETAG || true
git branch -f $BRANCHNAME $OLDTAG
git checkout -f $BRANCHNAME
git config merge.conflictstyle diff3
git merge debpsuedomerge || true #when a merge has conflicts git exits with a nonzero status code
git diff --name-only --diff-filter=U > ../conflicts
$SCRIPTDIR/fixupchangelog debian/changelog $NEWVERSION $TARGETSUITE "`date -uR`" $PACKAGE
git add debian/changelog
if grep ^debian/patches/series$ ../conflicts ; then
if grep '^<<<<<<< ' debian/patches/series ; then
$SCRIPTDIR/fixupseries debian/patches/series
git add debian/patches/series
else
#debian/patches/series is marked as conflicting but no conflict markers
#assume this means that upstream distribution no longer ships a
#debian/patches/series file.
git diff $BASETAG $OLDTAG | filterdiff -p1 -i debian/patches/series | egrep '^\+[^+]' | cut -c 2- > debian/patches/series
git add debian/patches/series
fi
fi
(if grep ^debian/control.md5sum$ ../conflicts ; then
#"kernel style" package,
(debian/rules clean || true) && debian/rules clean && git add debian/control.md5sum debian/control
if [ -f debian/config.defines.dump ]; then git add debian/config.defines.dump ; fi
if [ -f debian/rules.gen ]; then git add debian/rules.gen ; fi
if [ -f debian/tests/control ]; then git add debian/tests/control ; fi
if [ -f debian/rules.defs ]; then git add debian/rules.defs ; fi
if [ -f debian/.gitignore ]; then git add debian/.gitignore ; fi
fi) || true
if grep ^debian/control$ ../conflicts ; then
($SCRIPTDIR/fixupcontrol debian/control .. && git add debian/control) || true
fi
if grep ^debian/control.in$ ../conflicts ; then
($SCRIPTDIR/fixupcontrol debian/control.in .. && git add debian/control.in) || true
fi
if grep ^debian/control.source$ ../conflicts ; then
($SCRIPTDIR/fixupcontrol debian/control.source .. && git add debian/control.source) || true
fi
if egrep '^debian/.*\.symbols.*$' ../conflicts || egrep '^debian/symbols$' ../conflicts ; then
echo conflicting symbols file found
for FILE in `egrep '^debian/.*\.symbols.*$' ../conflicts` `egrep '^debian/symbols$' ../conflicts` ; do
($SCRIPTDIR/fixupsymbols $FILE .. && git add $FILE) || true
done
#($SCRIPTDIR/fixupcontrol debian/control .. && git add debian/control) || true
fi
if grep ^.gitattributes$ ../conflicts ; then
if ! git cat-file -e $OLDTAG:.gitattributes 2>/dev/null ; then
#if we have removed .gitattributes downstream then it should
#stay removed, even if it's upstream content has changed
git rm .gitattributes
fi
fi
#make sure no branch is checked out in our destination repo so that the push doesn't fail
cd $gitdir/${PACKAGEDIR}
git checkout -q --detach || true
cd $tmp/makeforwardport/tempgit
git push -f origin $BRANCHNAME
if ! git commit -m "Merge version $OLDVERSION and $DEBVERSION to produce $NEWVERSION" ; then
#push work in progress so it can be worked on manually
git diff --name-only --diff-filter=U > ../conflicts
echo conflicts found | cat - ../conflicts debian/changelog | sponge debian/changelog
git add debian/changelog
cat ../conflicts | while read CONFLICT; do
echo git add "$CONFLICT"
git add "$CONFLICT"
done
git commit -m "Failed merge of version $OLDVERSION and $DEBVERSION to produce $NEWVERSION, see list of conflicting files at the top of debian/changelog"
git push -f origin $BRANCHNAME
exit 1
fi
#defuzz patches (not yet ported to git)
#cd ..
#rm -rf extract.defuzz
#cp -a extract extract.defuzz
#cd extract.defuzz
#export QUILT_PATCHES=debian/patches
#quilt push -a --fuzz 0 || true
#while quilt push; do
# quilt refresh
# quilt push -a --fuzz 0 || true
#done
#cd ../extract
#rm -rf debian/patches
#mv ../extract.defuzz/debian/patches debian/ || true
#rm -rf ../extract.defuzz
git push -f origin $BRANCHNAME
dcmd --orig cp $workingrepo/pool/*/$PACKAGEDIR/${PACKAGE}_${DEBVERSIONNOEPOCH}.dsc ..
git status
#quilt fixup code, try dgit first if that fails it's time to be more
#aggressive.
if ! dgit -wgf --quilt=auto quilt-fixup; then
cd ..
dpkg-source --skip-patches -x $workingrepo/pool/*/$PACKAGEDIR/${PACKAGE}_${DEBVERSIONNOEPOCH}.dsc tempdefuzz
rm -rf tempdefuzz/debian/patches
cp -a tempgit/debian/patches tempdefuzz/debian/patches
rm -f tempdefuzz/debian/patches/series
cd tempdefuzz
touch debian/patches/series
while read patch; do
export QUILT_PATCHES=debian/patches
echo $patch >> debian/patches/series
if ! quilt push -a --fuzz 0; then
#this patch needs to be dealt with, try and fix it and if that
#is not possible remove it
if quilt push -a ; then
quilt refresh
else
head -n -1 debian/patches/series | sponge debian/patches/series
fi
fi
done < ../tempgit/debian/patches/series
cd ..
rm -rf tempgit/debian/patches
mv tempdefuzz/debian/patches tempgit/debian/patches
cd tempgit
git add debian/patches
git commit -m "Defuzz fuzzy quilt patches and/or disable broken quilt patches"
fi
dgit -wgf --quilt=auto -v_ build-source
cd $tmp/makeforwardport
if [[ $dosbuild == yes ]]; then
rm *.changes
#going forward it would be good to have more inteligent application of --force-orig-source, not a massive priority for now though
sbuild -snA --force-orig-source -d ${TARGETSUITE} `$SCRIPTDIR/getchrootoverride $PACKAGE $TARGETSUITE` ${PACKAGE}_${NEWVERSIONNOEPOCH}.dsc
else
#dgit build-source doens't seem to allow forced inclusion of the orig
#tarball, so use changestool to add it.
changestool ${PACKAGE}_${NEWVERSIONNOEPOCH}_*.changes includeallsources
fi
#we want to make sure that the result at this point gets preserved even dgit push fails for some reason.
cd $outputdir
pwd
dcmd cp $tmp/makeforwardport/${PACKAGE}_${NEWVERSIONNOEPOCH}_*.changes .
cd $tmp/makeforwardport/tempgit
if [[ $dodgitpush == yes ]]; then
$AFPGCONFIG/setup-dgit-for-push
PATH=$SCRIPTDIR/dummy-dput:$PATH dgit push --deliberately-not-fast-forward
cd $outputdir
dcmd cp $tmp/makeforwardport/${PACKAGE}_${NEWVERSIONNOEPOCH}_armhf.changes .
fi