* debian/bin/apply

- Use sed to split versions. Shell can not split on the last occurence.
  - Use list of revisions to check for series.
* debian/rules.real
  - Fix upstream tarball name.
  - Fix location and substitution for patch scripts.

svn path=/dists/trunk/linux-2.6/; revision=4564
This commit is contained in:
Bastian Blank 2005-10-20 15:51:23 +00:00
parent 8db45ea85c
commit dd27f2eec1
2 changed files with 41 additions and 103 deletions

134
debian/bin/apply vendored
View File

@ -61,7 +61,6 @@ deapply_patch() {
unpatch_series() {
series=$1
[ -f "$series" ] || die "I wasn't passed a series: $series"
tac $series | while read action patch; do
case "$action" in
@ -83,7 +82,7 @@ unpatch_series() {
patch_series() {
series=$1
[ -f "$series" ] || die "I wasn't passed a series: $series"
[ -f "$series" ] || return
while read action patch; do
case "$action" in
@ -103,52 +102,6 @@ patch_series() {
echo "--> $(basename $series) fully applied."
}
bubble_sort ()
{
DIR=$1
shift
SORTED=$@
SWAPED=1
while [ $SWAPED = 1 ]; do
X=0
A=""
SWAPED=0
NEW=""
for i in $SORTED; do
if [ -z "$A" ]; then
A="$i"
continue
fi
B="$i"
if dpkg --compare-versions "$A" "$DIR" "$B"; then
SWAPED=1
NEW="$NEW $B"
else
NEW="$NEW $A"
A="$B"
fi
X=$(($X + 1))
done
SORTED="$NEW $A"
done
echo $SORTED
}
bubble_sort_fwd ()
{
bubble_sort "lt" $@
}
bubble_sort_rev ()
{
bubble_sort "gt" $@
}
if ! [ -d Documentation ] || ! [ -d kernel ]; then
die 'Not in kernel top level directory. Exiting'
exit 1
@ -156,15 +109,20 @@ fi
# for THIS particular version of the source package
version=${override_version:-@version@}
upstream=${version%-*}
revision=${version#*-}
revision=$(echo $version | sed -ne 's,^\(.*\)-\([^-]*\)$,\2,p')
upstream=$(echo $version | sed -ne 's,^\(.*\)-\([^-]*\)$,\1,p')
revisions_count=0
for i in ${override_revisions:-@revisions@}; do
revisions[$revisions_count]=$i
revisions_count=$(($revisions_count + 1))
done
home=${home:-/usr/src/kernel-patches/all/$upstream/debian}
if [ -f version.Debian ]; then
current=$(cat version.Debian)
current_rev=${current#*-}
current_up=${current%-*}
current_rev=$(echo $current | sed -ne 's,^\(.*\)-\([^-]*\)$,\2,p')
current_up=$(echo $current | sed -ne 's,^\(.*\)-\([^-]*\)$,\1,p')
if [ "$current" = "$upstream" ]; then
current_rev=0
@ -177,8 +135,8 @@ fi
target=${1:-$version}
target_rev=${target#*-}
target_up=${target%-*}
target_rev=$(echo $target | sed -ne 's,^\(.*\)-\([^-]*\)$,\2,p')
target_up=$(echo $target | sed -ne 's,^\(.*\)-\([^-]*\)$,\1,p')
# Sanity checks
if dpkg --compare-versions "$target_up" ne "$upstream"; then
@ -197,53 +155,33 @@ fi
# reverse each used series (tac) and unapply applied patches and vice versa.
# 3. $target_rev is undefined, and $target is $upstream.
# Revert to upstream.
if [ "$target_rev" = "$target" ]; then
# already reverted
if [ "$current" = "$target" ]; then
echo "Nothing to do, exiting."
exit 0
fi
for base in $(cd $home/series/ && bubble_sort_fwd $(ls -d *)); do
srev=${base#*-}
if [ -n "$srev" ]; then
if dpkg --compare-versions $srev "<=" $current_rev; then
unpatch_series $home/series/$base
fi
else
die "Series doesn't have a revision!"
fi
done
elif dpkg --compare-versions "$current_rev" eq "$upstream" ||
dpkg --compare-versions "$target_rev" gt "$current_rev"; then
for base in $(cd $home/series/ && bubble_sort_rev $(ls -d *)); do
srev=${base#*-}
if [ -n "$srev" ]; then
if dpkg --compare-versions "$srev" gt "$current_rev" &&
dpkg --compare-versions "$srev" le "$target_rev"; then
patch_series $home/series/$base
fi
else
die "Series doesn't have a revision!"
fi
done
elif dpkg --compare-versions "$target_rev" eq "$current_rev"; then
if dpkg --compare-versions "$target_rev" eq "$current_rev"; then
echo "Nothing to do, exiting."
exit 0
elif dpkg --compare-versions "$target_rev" lt "$current_rev"; then
for base in $(cd $home/series/ && bubble_sort_fwd $(ls -d *)); do
srev=${base#*-}
if [ -n "$srev" ]; then
# -gt because you don't want to unapply the target series
if dpkg --compare-versions "$srev" le "$current_rev" &&
dpkg --compare-versions "$srev" gt "$target_rev"; then
unpatch_series $home/series/$base
fi
else
die "Series doesn't have a revision!"
fi
else
cur_index=$revisions_count
while [ $cur_index -gt 0 ]; do
[ ${revisions[$(($cur_index - 1))]} == $current_rev ] && break
cur_index=$(($cur_index - 1))
done
target_index=$revisions_count
while [ $target_index -gt 0 ]; do
[ ${revisions[$(($target_index - 1))]} == $target_rev ] && break
target_index=$(($target_index - 1))
done
if [ $target_index -gt $cur_index ]; then
while [ $target_index -gt $cur_index ]; do
series="$home/series/${upstream}-${revisions[$cur_index]}"
[ -f "$series" ] && patch_series $series
cur_index=$(($cur_index + 1))
done
elif [ $target_index -lt $cur_index ]; then
while [ $target_index -lt $cur_index ]; do
cur_index=$(($cur_index - 1))
series="$home/series/${upstream}-${revisions[$cur_index]}"
[ -f "$series" ] && unpatch_series $series
done
fi
fi
echo $target > version.Debian

10
debian/rules.real vendored
View File

@ -121,7 +121,7 @@ $(BUILD_DIR)/config.$(ARCH)-$(SUBARCH)-$(FLAVOUR): $(basedir)/config.$(FLAVOUR)
cat $(basedir)/config.$(FLAVOUR) >> $@
$(BUILD_DIR)/linux-source-$(UPSTREAM_VERSION).tar.bz2: SOURCE_DIR=$(BUILD_DIR)/source
$(BUILD_DIR)/linux-source-$(UPSTREAM_VERSION).tar.bz2: DIR = $(BUILD_DIR)/linux-source-$(VERSION)
$(BUILD_DIR)/linux-source-$(UPSTREAM_VERSION).tar.bz2: DIR = $(BUILD_DIR)/linux-source-$(UPSTREAM_VERSION)
$(BUILD_DIR)/linux-source-$(UPSTREAM_VERSION).tar.bz2: $(STAMPS_DIR)/source
rm -rf $@ $(DIR)
cp -al $(SOURCE_DIR) $(DIR)
@ -135,7 +135,7 @@ $(STAMPS_DIR)/source: debian/bin/apply
rm -rf $(DIR)
mkdir -p $(DIR)
cp -al $(srcfiles) $(DIR)
cd $(DIR); override_version=$(SOURCE_VERSION) home=$(CURDIR)/debian/patches-debian sh $(CURDIR)/debian/bin/apply
cd $(DIR); override_version="$(SOURCE_VERSION)" override_revisions="$(REVISIONS)" home=$(CURDIR)/debian/patches-debian sh $(CURDIR)/debian/bin/apply
#make-kpkg does this when building kernel-source.
mv $(DIR)/scripts/package/Makefile $(DIR)/scripts/package/Makefile.dist
mv $(DIR)/scripts/package/builddeb $(DIR)/scripts/package/builddeb.dist
@ -256,7 +256,7 @@ install-headers-all:
$(MAKE) -f debian/rules.real install-base DH_OPTIONS=$(DH_OPTIONS)
install-patch: PACKAGE = linux-patch-debian-$(VERSION)
install-patch: pbase := /usr/src/kernel-patches/all/$(VERSION)
install-patch: pbase := /usr/src/kernel-patches/all/$(SOURCE_UPSTREAM)
install-patch: pfull := debian/$(PACKAGE)$(pbase)
install-patch: ptchs := $(notdir $(wildcard debian/patches-arch/*))
install-patch: DH_OPTIONS = -p$(PACKAGE)
@ -267,8 +267,8 @@ install-patch:
dh_installdirs $(DH_OPTIONS) $(pbase)/apply $(pbase)/debian $(pbase)/unpatch
dh_install $(DH_OPTIONS) debian/patches-debian/* $(pbase)/debian
# Install the debian patches
sed 's/@version@/$(release)/g' debian/bin/apply > $(pfull)/apply/debian
sed 's/@upstream@/$(version)/g' debian/bin/unpatch > $(pfull)/unpatch/debian
sed -e 's/@version@/$(SOURCE_VERSION)/g' -e 's/@revisions@/$(REVISIONS)/' debian/bin/apply > $(pfull)/apply/debian
sed -e 's/@upstream@/$(SOURCE_UPSTREAM)/g' debian/bin/unpatch > $(pfull)/unpatch/debian
chmod 755 $(pfull)/apply/debian $(pfull)/unpatch/debian
chmod 644 $(pfull)/debian/*.patch
bzip2 -9 $(pfull)/debian/*.patch