-
Notifications
You must be signed in to change notification settings - Fork 1
/
forwardportdriver
executable file
·128 lines (112 loc) · 5.57 KB
/
forwardportdriver
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
#!/bin/bash -ev
#Copyright (c) 2009-2017 Peter M. Green and Adam D. Barratt
#
#Permission is hereby granted, free of charge, to any person obtaining a copy of
#this software and associated documentation files (the "Software"), to deal in
#the Software without restriction, including without limitation the rights to
#use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
#of the Software, and to permit persons to whom the Software is furnished to do
#so, subject to the following conditions:
#
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
#THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
#SOFTWARE.
#based on code by adsb from
#http://anonscm.debian.org/gitweb/?p=mirror/britney1.git;a=blob_plain;f=britney;h=094ec121d5bea3e68af76c493f2b9d91d734f45e;hb=HEAD
#I don't pretend to understand this perl code
process_pkg_list() {
perl "-MAptPkg::Config '\$_config'" -e '
my $versioning = $_config->system->versioning;
while (<>) {
$current .= $_;
if (/^Package: (.*)$/) {
$pkg = $1;
} elsif (/^Version: (.*)$/) {
$version = $1;
} elsif (/^\s*$/) {
$data{"$pkg"}{"$version"} = $current;
$pkg = ""; $version = ""; $current = "";
}
}
$data{"$pkg"}{"$version"} = $current if length $current;
for $pkg2 (sort keys %data) {
@versions = (reverse sort {$versioning->compare($a,$b)} keys %{$data{"$pkg2"}});
print "$pkg2 $versions[0]\n";
}
'
}
set -o pipefail
MAINSUITE=$1
SCRIPTDIR=`dirname $(readlink -f $0)`
$SCRIPTDIR/afpg_readconfig.py main:workingrepo main:gitdir main:tmp $MAINSUITE:STAGINGSUITE $MAINSUITE:UPSTREAMSUITE $MAINSUITE:WORKINGBRANCH main:outputdir main:AFPGCONFIG main:localmarker main:revertmarker
source <($SCRIPTDIR/afpg_readconfig.py main:workingrepo main:gitdir main:tmp $MAINSUITE:STAGINGSUITE $MAINSUITE:UPSTREAMSUITE $MAINSUITE:WORKINGBRANCH main:outputdir main:AFPGCONFIG main:localmarker main:revertmarker)
#update working repo
cd $workingrepo
for SUITE in ${MAINSUITE} ${STAGINGSUITE} ${UPSTREAMSUITE} ; do
sources=$workingrepo/dists/${SUITE}/main/source/Sources
cat $sources | process_pkg_list > $tmp/sources-${SUITE}-processed
done
for PACKAGE in $(cat $AFPGCONFIG/whitelist.${MAINSUITE}) ; do
echo ${PACKAGE}
MAINVERSION=`grep ^${PACKAGE}" " $tmp/sources-${MAINSUITE}-processed | cut -d " " -f 2`
STAGINGVERSION=`grep ^${PACKAGE}" " $tmp/sources-${STAGINGSUITE}-processed | cut -d " " -f 2`
DEBVERSION=`grep ^${PACKAGE}" " $tmp/sources-${UPSTREAMSUITE}-processed | cut -d " " -f 2`
echo ${PACKAGE}
echo main version $MAINVERSION
echo staging version $STAGINGVERSION
echo deb version $DEBVERSION
if [[ $STAGINGVERSION == *${localmarker}* ]] ; then
NEWVERSION=${DEBVERSION}${localmarker}1
OLDVERSION=${STAGINGVERSION}
elif [[ $MAINVERSION == *${localmarker}* ]] ; then
NEWVERSION=${DEBVERSION}${localmarker}1
OLDVERSION=${MAINVERSION}
elif [[ $STAGINGVERSION == *${revertmarker}* ]] ; then
if dpkg --compare-versions $STAGINGVERSION lt $DEBVERSION ; then
echo no need to forward port rvt version as debian version is higher
continue
fi
NEWVERSION=${DEBVERSION}${revertmarker}
OLDVERSION=${STAGINGVERSION}
else
echo no ${localmarker} version marker found in main version or staging version
echo and no ${revertmarker} marker found in staging version.
continue
fi
OLDBASEVERSION=`echo $OLDVERSION | sed "s/${localmarker}[0-9]*//" | sed "s/${revertmarker}[0-9]*//"`
if dpkg --compare-versions $OLDBASEVERSION lt $DEBVERSION; then
echo version ordering looks ok for forward porting
if dpkg --compare-versions $NEWVERSION lt $STAGINGVERSION;then
#sometimes Debian uses a version suffix that makes their new version
#with our suffix on the end lower than our old version, we need
#to take care of that.
#there may be some escaping issues in this code, needs testing.
echo "$localmarker" | sed 's/+/\\+/g'
localmarkerescaped="$(echo "$localmarker" | sed 's/+/\\+/g')"
revertmarkerescaped="$(echo "$revertmarker" | sed 's/+/\\+/g')"
STAGINGPREMARKERVERSION=`echo $STAGINGVERSION | sed "s/${localmarker}[0-9]*.*//" | sed "s/${revertmarker}[0-9]*.*//"`
echo 1 "$localmarkerescaped"
echo 2 "$revertmarkerescaped"
STAGINGVERSIONMARKER=`echo $STAGINGVERSION | grep -Eo "(${localmarkerescaped}|${revertmarkerescaped})[0-9]*"`
STAGINGVERSIONUPTOANDINCLUDINGMARKER="${STAGINGPREMARKERVERSION}${STAGINGVERSIONMARKER}"
NEWDEBSUFFIX=${DEBVERSION:${#STAGINGPREMARKERVERSION}}
NEWVERSION=${STAGINGVERSIONUPTOANDINCLUDINGMARKER}${NEWDEBSUFFIX}
fi
if dpkg --compare-versions $NEWVERSION lt $STAGINGVERSION;then
echo ERROR: WTF: something really strange is going on with version numbers
echo staging version: $STAGINGVERSION
echo new version: $NEWVERSION
exit 1
fi
NEWVERSIONNOEPOCH=`echo ${NEWVERSION} | sed -e s/^[^:]://`
if [ ! -e $outputdir/${PACKAGE}_${NEWVERSIONNOEPOCH}.log ] ; then
($SCRIPTDIR/makeforwardport $PACKAGE $OLDVERSION $DEBVERSION $NEWVERSION $STAGINGSUITE $WORKINGBRANCH || true) 2>&1 | tee $outputdir/${PACKAGE}_${NEWVERSIONNOEPOCH}.log
fi
fi
done