* Move most parts of debian/bin/gencontrol.py to debian/lib.

* Implement subarch.
* Rewrite patch handling to integrate arch and subarch specific patches. 

r4300:  waldi | 2005-10-03 22:23:02 +0200
debian/rules.real: Remove old definitions.

r4304:  waldi | 2005-10-03 23:02:13 +0200
Move template reading to lib.

* debian/bin/gencontrol.py
  - Remove RFC822 routines.
  - Use templates class.
* debian/lib/python/debian_linux.py: Add templates class.

r4738:  waldi | 2005-11-07 15:51:30 +0100
debian/bin/gencontrol.py: Set TYPE.

r4796:  waldi | 2005-11-13 15:09:40 +0100
* debian/bin/gencontrol.py: Use config_reader.
* debian/lib/python/debian_linux: Add directory.
* debian/lib/python/debian_linux/__init__.py: Move from debian/lib/python/python/debian_linux.py.
* debian/lib/python/debian_linux/config.py: Add config_reader and config_parser.

r4797:  waldi | 2005-11-13 15:45:12 +0100
* debian/bin/gencontrol.py: Move code away. For now only use imported code.
* debian/lib/python/debian_linux/__init__.py: Remove utils.
* debian/lib/python/debian_linux/config.py: Update.
* debian/lib/python/debian_linux/debian.py: Add debian packaging specific code.
* debian/lib/python/debian_linux/gencontrol.py: Add code.
* debian/lib/python/debian_linux/utils.py: Add utils.

r4798:  waldi | 2005-11-13 15:56:37 +0100
debian/lib/python/debian_linux/gencontrol.py:
Don't try to generation extra packages if the template does not exist.

r4799:  waldi | 2005-11-13 16:04:25 +0100
debian/lib/python/debian_linux/gencontrol.py:
Begin to split methods in smaller pieces.

r4800:  waldi | 2005-11-13 16:26:03 +0100
debian/lib/python/debian_linux/gencontrol.py: Split more code.

r4802:  waldi | 2005-11-13 16:40:08 +0100
debian/lib/python/debian_linux/gencontrol.py: Also allow strings in makefile write list.

r4806:  waldi | 2005-11-13 16:55:48 +0100
debian/bin/gencontrol.py: Move linux-2.6 specific code from
debian/lib/python/debian_linux/gencontrol.py.

r4807:  waldi | 2005-11-13 17:07:26 +0100
debian/bin/gencontrol.py, debian/lib/python/debian_linux/gencontrol.py: Update.

r4808:  waldi | 2005-11-13 17:08:53 +0100
debian/bin/gencontrol.py: Move code from debian/lib/python/debian_linux/gencontrol.py.

r4810:  waldi | 2005-11-13 17:10:30 +0100
debian/bin/gencontrol.py
- Move code from debian/lib/python/debian_linux/gencontrol.py.
- Update.

r4811:  waldi | 2005-11-13 17:33:47 +0100
debian/bin/gencontrol.py: Move code from debian/lib/python/debian_linux/gencontrol.py.

r4812:  waldi | 2005-11-13 17:36:38 +0100
debian/bin/gencontrol.py: Update.

r4813:  waldi | 2005-11-13 18:36:28 +0100
debian/lib/python/debian_linux/config.py: Remove old code.

r4814:  waldi | 2005-11-13 18:38:50 +0100
* debian/bin/gencontrol.py, debian/lib/python/debian_linux/gencontrol.py,
  debian/lib/python/debian_linux/utils.py: Teach package object how to
  work with list attributes.
* debian/lib/python/debian_linux/debian.py: Don't use utils.entry.

r4815:  waldi | 2005-11-13 18:41:55 +0100
* debian/lib/python/debian_linux/gencontrol.py
  - Use utils.package.
  - Remove debugging code.
* debian/lib/python/debian_linux/utils.py
  - Use utils.package.
  - Remove utils.entry.

r4816:  waldi | 2005-11-13 18:47:46 +0100
debian/lib/python/debian_linux/utils.py: Don't output empty fields.

r4965:  waldi | 2005-12-04 12:36:20 +0100
Rewrite config reader to support more than one section per (arch, subarch, flavour).

* debian/bin/gencontrol.py, debian/lib/python/debian_linux/gencontrol.py:
  Explicitely Use base entries.
* debian/lib/python/debian_linux/config.py
  - Rewrite.
  - Loose support for entry merging for now.

r5175:  waldi | 2006-01-02 20:46:46 +0100
debian/bin/gencontrol.py: Fix.

r5176:  waldi | 2006-01-02 21:09:17 +0100
* debian/bin/apply: Don't expect upstream version in series file names.
* debian/patches-debian/series/0experimental.1:
  Move from debian/patches-debian/series/2.6.14+2.6.15-rc7-0experimental.1.
* debian/patches-debian/series/0experimental.2:
  Move from debian/patches-debian/series/2.6.14+2.6.15-rc7-0experimental.2.

r5177:  waldi | 2006-01-02 22:31:28 +0100
First prototype of improved patch util.

debian/bin/apply.py: Add.

r5178:  waldi | 2006-01-02 23:40:11 +0100
* debian/bin/apply.py: Finish implementation.
* debian/rules.real: Use apply.py.

r5179:  waldi | 2006-01-03 00:15:05 +0100
* debian/bin/apply.py: Implement arch and subarch specific patches.
* debian/bin/unpatch: Remove old code.
* debian/rules.real: Fix patch package installation.

r5180:  waldi | 2006-01-03 00:16:05 +0100
debian/bin/apply: Remove.

r5181:  waldi | 2006-01-03 00:16:56 +0100
* debian/bin/gencontrol.py: Readd missing build target.
* debian/lib/python/debian_linux/debian.py: Raise if version is not parsable.

r5192:  waldi | 2006-01-03 15:32:43 +0100
debian/bin/apply.py
- Add version_file class.
- Use correct series for deapply.

r5193:  waldi | 2006-01-03 15:41:53 +0100
debian/bin/apply.py
- Remove extra version handling from series class.
- Add check for extra version in patch setup.

r5194:  waldi | 2006-01-03 15:45:49 +0100
debian/bin/apply.py: Move complete reverse logic into series class.

r5195:  waldi | 2006-01-03 16:14:33 +0100
debian/bin/apply.py: Implement patch per arch and subarch. It is currently done
by completely deapply the arch specific patches if it needs to change set of
general patches.

r5196:  waldi | 2006-01-03 16:18:55 +0100
debian/bin/apply.py: Don't record extra version without patch.

r5197:  waldi | 2006-01-03 16:25:03 +0100
debian/bin/apply.py: Record shortest possible extra version in version file.

r5198:  waldi | 2006-01-03 16:28:00 +0100
* debian/patches-debian/series/0experimental.3-extra: Add.
* debian/patches-debian/hppa-incompatible.patch:
  Move from debian/patches-arch/hppa.diff.
* debian/patches-debian/m68k-incompatible.patch
  Move from debian/patches-arch/m68k.diff.
* debian/patches-arch: Remove.

r5200:  waldi | 2006-01-03 16:30:03 +0100
debian/rules.real: Use new apply script for arch and subarch patches.

r5207:  waldi | 2006-01-03 17:12:52 +0100
* debian/rules.real: Remove old arch patches installation.
* debian/templates/control.source.in: Remove dh-kpatches from Buld-Depends-Indep.

r5208:  waldi | 2006-01-03 17:21:21 +0100
debian/lib/python/debian_linux: Set svn:ignore property.

r5210:  waldi | 2006-01-03 17:24:09 +0100
debian/templates/control.main.in: Fix depends of patch package.

r5212:  waldi | 2006-01-03 17:54:18 +0100
* debian/rules: Fix clean.
* debian/rules.real
  - Remove definition of old arch patches.
  - Use a variable for patch command.

r5213:  waldi | 2006-01-03 20:45:41 +0100
* debian/templates: Move subarch part in package names in front of flavour.
* debian/lib/python/debian_linux/gencontrol.py: Fix subarch text setting.

r5214:  waldi | 2006-01-03 20:46:05 +0100
debian/lib/python/debian_linux/config.py: Support subarches.

r5215:  waldi | 2006-01-04 00:51:46 +0100
Update svn:ignore property.

r5216:  waldi | 2006-01-04 00:53:20 +0100
debian/bin/apply.py
- Use correct length in extra check.
- Check for correct length of extra entries.

r5217:  waldi | 2006-01-04 00:54:38 +0100
debian/rules.real
- Append subarch to kernel version.
- Fix base of kconfig.ml call.

r5234:  waldi | 2006-01-04 15:34:59 +0100
* debian/bin/gencontrol.py: Use config entry merging when needed.
* lib/python/debian_linux/config.py: Readd config entry merging.

r5235:  waldi | 2006-01-04 16:00:38 +0100
* debian/bin/install-image: Use DEBIAN_LOCALVERSION and DEBIAN_LOCALVERSION_HEADERS.
* debian/rules.real: Set LOCALVERSION for scripts.

r5240:  waldi | 2006-01-04 17:50:12 +0100
debian/rules.real: Fix version of subarch headers package.

svn path=/dists/trunk/linux-2.6/; revision=5242
This commit is contained in:
Bastian Blank 2006-01-04 19:33:32 +00:00
parent 9ddce5fa57
commit f5ea6ce508
25 changed files with 1335 additions and 884 deletions

6
debian/arch/defines vendored
View File

@ -13,6 +13,7 @@ arches:
powerpc
s390
sparc
image-ramdisk-generators: yaird initramfs-tools
[alpha]
#enabled: False
@ -22,3 +23,8 @@ available: False
[mipsel]
available: False
[image-ramdisk-generators]
yaird: mkinitrd.yaird
initramfs-tools: mkinitramfs

188
debian/bin/apply vendored
View File

@ -1,188 +0,0 @@
#!/bin/bash
set -e
length=50
die() {
echo "E: $@" >&2
exit 1
}
warn() {
echo "W: $@" >&2
}
uncompress_patch() {
patch=$1
case "$patch" in
*.bz2) bzcat $patch ;;
*.gz) zcat $patch ;;
*) cat $patch ;;
esac
}
find_patch() {
patch=$1
if [ -f "$patch" ]; then
echo "$patch"
elif [ -f "$patch.bz2" ]; then
echo "$patch.bz2"
elif [ -f "$patch.gz" ]; then
echo "$patch.gz"
else
die "$patch is in the series, but doesn't exist!"
fi
}
apply_patch() {
patch=$(find_patch $home/$1)
base=$1
if uncompress_patch "$patch" | patch -p1 --fuzz=1 -f -s -t --no-backup-if-mismatch; then
printf "%-${length}s\tOK (+)\n" "$base"
else
printf "%-${length}s\tFAIL (+)\n" "$base"
exit 1
fi
}
deapply_patch() {
patch=$(find_patch $home/$1)
base=$1
if uncompress_patch "$patch" | patch -p1 -f -s -t -R --no-backup-if-mismatch; then
printf "%-${length}s\tOK (-)\n" "$base"
else
printf "%-${length}s\tFAIL (-)\n" "$base"
exit 1
fi
}
unpatch_series() {
series=$1
tac $series | while read action patch; do
case "$action" in
+) deapply_patch $patch ;;
-) apply_patch $patch ;;
X)
bakfile="$(dirname $patch)/.$(basename $patch).bak"
if [ -f "$bakfile" ]; then
mv -f "$bakfile" "$patch"
printf "%-${length}s\tRESTORED (X)\n" "$patch"
else
printf "%-${length}s\tNO BACKUP (X)\n" "$patch"
fi
;;
esac
done
echo "--> $(basename $series) fully unapplied."
}
patch_series() {
series=$1
[ -f "$series" ] || return
while read action patch; do
case "$action" in
+) apply_patch $patch ;;
-) deapply_patch $patch ;;
X)
bakfile="$(dirname $patch)/.$(basename $patch).bak"
if [ -f "$patch" ]; then
mv -f "$patch" "$bakfile"
printf "%-${length}s\tREMOVED (X)\n" "$patch"
else
printf "%-${length}s\tNO FILE (X)\n" "$patch"
fi
;;
esac
done < $series
echo "--> $(basename $series) fully applied."
}
if ! [ -d Documentation ] || ! [ -d kernel ]; then
die 'Not in kernel top level directory. Exiting'
exit 1
fi
# for THIS particular version of the source package
version=${override_version:-@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=$(echo $current | sed -ne 's,^\(.*\)-\([^-]*\)$,\2,p')
current_up=$(echo $current | sed -ne 's,^\(.*\)-\([^-]*\)$,\1,p')
if [ "$current" = "$upstream" ]; then
current_rev=0
fi
else
warn "No version.Debian file, assuming pristine Linux $upstream"
current=$upstream
current_rev=0
fi
target=${1:-$version}
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
die "Upstream $target_up doesn't match $upstream!"
# We don't have that version out yet!
elif [ ! -n "$target_rev" ] ||
( dpkg --compare-versions "$target_rev" ne "$target" &&
dpkg --compare-versions "$target_rev" gt "$revision" ); then
year=$(($(date +%Y) + 1))
die "Can't patch to nonexistent revision $target_rev (wait until $year)"
fi
# At this point, we must handle three cases.
# 1. $target_rev is greater than $current_rev. We must patch forward for this.
# 2. $target_rev is less than $current_rev. We must reverse the list of series,
# reverse each used series (tac) and unapply applied patches and vice versa.
# 3. $target_rev is undefined, and $target is $upstream.
if dpkg --compare-versions "$target_rev" eq "$current_rev"; then
echo "Nothing to do, exiting."
exit 0
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
# vim:noet:ai:ts=4

405
debian/bin/apply.py vendored Executable file
View File

@ -0,0 +1,405 @@
#!/usr/bin/env python2.4
import os.path, sys
from warnings import warn
import debian_linux
_default_home = "@home@"
_default_revisions = "@revisions@"
_default_source = "@source@"
class series(list):
def __init__(self, name, home, reverse = False):
self.name = name
self.reverse = reverse
filename = os.path.join(home, 'series', name)
if not os.path.exists(filename):
raise RuntimeError, "Can't find series file for %s" % name
f = file(filename)
for line in f.readlines():
line = line.strip()
if len(line) == 0 or line[0] == '#':
continue
items = line.split(' ')
operation, patch = items
if operation in ('+', '-'):
patchfile = os.path.join(home, patch)
for suffix, type in (('', 0), ('.bz2', 1), ('.gz', 2)):
if os.path.exists(patchfile + suffix):
patchinfo = patchfile + suffix, type
break
else:
raise RuntimeError, "Can't find patch %s for series %s" % (patchfile, name)
elif operation in ('X',):
backup = patch + ".bak"
if not os.path.exists(patch) and not os.path.exists(backup):
raise RuntimeError, "Can't find neither original nor backup file %s for series %s" % (patch, name)
patchinfo = patch, backup
else:
raise RuntimeError, 'Undefined operation "%s" in series %s' % (operation, name)
self.append((operation, patch, patchinfo))
def __repr__(self):
return '<%s object for %s>' % (self.__class__.__name__, self.name)
def apply(self):
if self.reverse:
for operation, patch, patchinfo in self[::-1]:
if operation == '.':
print """\
(.) IGNORED %s\
""" % patch
elif operation == '+':
self.patch_deapply(patch, patchinfo)
elif operation == '-':
self.patch_apply(patch, patchinfo)
elif operation == 'X':
os.rename(patchinfo[1], patchinfo[0])
print """\
(X) RESTORED %s\
""" % patch
print "--> %s fully unapplied." % self.name
else:
for operation, patch, patchinfo in self:
if operation == '.':
print """\
(.) IGNORED %s\
""" % patch
elif operation == '+':
self.patch_apply(patch, patchinfo)
elif operation == '-':
self.patch_deapply(patch, patchinf)
elif operation == 'X':
os.rename(patchinfo[0], patchinfo[1])
print """\
(X) REMOVED %s\
""" % patch
print "--> %s fully applied." % self.name
def patch_apply(self, patch, patchinfo):
ret = self.patch_call(patchinfo, '--fuzz=1')
if ret == 0:
print """\
(+) OK %s\
""" % patch
else:
print """\
(+) FAIL %s\
""" % patch
raise SystemExit, 1
def patch_call(self, patchinfo, patchargs):
patchfile, type = patchinfo
cmdline = []
if type == 0:
cmdline.append('cat')
elif type == 1:
cmdline.append('bzcat')
elif type == 2:
cmdline.append('zcat')
cmdline.append(patchfile + ' | patch -p1 -f -s -t --no-backup-if-mismatch')
cmdline.append(patchargs)
return os.spawnv(os.P_WAIT, '/bin/sh', ['sh', '-c', ' '.join(cmdline)])
def patch_deapply(self, patch, patchinfo):
ret = self.patch_call(patchinfo, '-R')
if ret == 0:
print """\
(-) OK %s\
""" % patch
else:
print """\
(-) FAIL %s\
""" % patch
raise SystemExit, 1
@staticmethod
def read_all(s, home, reverse = False):
ret = []
for name in s:
filename = os.path.join(home, 'series', name)
if not os.path.exists(filename):
warn("Can't find series file for %s" % name)
else:
i = series(name, home, reverse)
ret.append(i)
return ret
class series_extra(series):
def __init__(self, name, home, extra, reverse = False):
self.extra = extra
self.extra_used = ()
self.name = name
self.reverse = reverse
filename = os.path.join(home, 'series', name + '-extra')
if not os.path.exists(filename):
raise RuntimeError, "Can't find series file for %s" % name
f = file(filename)
for line in f.readlines():
line = line.strip()
if len(line) == 0 or line[0] == '#':
continue
items = line.split(' ')
operation, patch = items[:2]
if operation in ('+', '-'):
patchfile = os.path.join(home, patch)
for suffix, type in (('', 0), ('.bz2', 1), ('.gz', 2)):
if os.path.exists(patchfile + suffix):
patchinfo = patchfile + suffix, type
break
else:
raise RuntimeError, "Can't find patch %s for series %s" % (patchfile, name)
else:
raise RuntimeError, 'Undefined operation "%s" in series %s' % (operation, name)
extra = {}
for s in items[2:]:
s = tuple(s.split('_'))
if len(s) > 3:
raise RuntimeError, "parse error"
if len(s) == 3:
raise RuntimeError, "Patch per flavour is not supported currently"
extra[s] = True
if not self._check_extra(extra):
operation = '.'
self.append((operation, patch, patchinfo))
def _check_extra(self, extra):
for i in (1, 2, 3):
t = tuple(self.extra[:i])
if extra.has_key(t):
if i > len(self.extra_used):
self.extra_used = t
return True
return False
@staticmethod
def read_all(s, home, extra, reverse = False):
ret = []
for name in s:
filename = os.path.join(home, 'series', name + '-extra')
if not os.path.exists(filename):
warn("Can't find series file for %s" % name)
else:
i = series_extra(name, home, extra, reverse)
ret.append(i)
return ret
class version(object):
__slots__ = "upstream", "revision"
def __init__(self, string = None):
if string is not None:
t = debian_linux.parse_version(string)
self.upstream = t['source_upstream']
self.revision = t['debian']
def __str__(self):
return "%s-%s" % (self.upstream, self.revision)
class version_file(object):
_file = 'version.Debian'
extra = ()
in_progress = False
def __init__(self, ver = None, overwrite = False):
if overwrite:
self._read(ver)
elif os.path.exists(self._file):
s = file(self._file).readline().strip()
self._read(s)
elif ver:
warn('No %s file, assuming pristine Linux %s' % (self._file, ver.upstream))
self.version = version()
self.version.upstream = ver.upstream
self.version.revision = '0'
else:
raise RuntimeError, "Not possible to determine version"
def __str__(self):
if self.in_progress:
return "unstable"
if self.extra:
return "%s %s" % (self.version, '_'.join(self.extra))
return str(self.version)
def _read(self, s):
list = s.split(' ')
if len(list) > 2:
raise RuntimeError, "Can't parse %s" % self._file
try:
self.version = version(list[0])
except ValueError:
raise RuntimeError, 'Can\'t read version in %s: "%s"' % (self._file, list[0])
if len(list) == 2:
self.extra = tuple(list[1].split('_'))
def _write(self):
file(self._file, 'w').write('%s\n' % self)
def begin(self):
self.in_progress = True
self._write()
def commit(self, version = None, extra = None):
self.in_progress = False
if version is not None:
self.version = version
if extra is not None:
self.extra = extra
self._write()
def main():
options, args = parse_options()
if len(args) > 1:
print "Too much arguments"
return
home = options.home
revisions = ['0'] + options.revisions.split()
source = version(options.source)
if len(args) == 1:
target = version(args[0])
else:
target = source
if options.current is not None:
vfile = version_file(options.current, True)
else:
vfile = version_file(source)
current = vfile.version
current_extra = vfile.extra
target_extra = []
if options.arch: target_extra.append(options.arch)
if options.subarch: target_extra.append(options.subarch)
if options.flavour: target_extra.append(options.flavour)
target_extra = tuple(target_extra)
if current.revision not in revisions:
raise RuntimeError, "Current revision is not in our list of revisions"
if target.revision not in revisions:
raise RuntimeError, "Target revision is not in our list of revisions"
if current.revision == target.revision and current_extra == target_extra:
print "Nothing to do"
return
current_index = revisions.index(current.revision)
target_index = revisions.index(target.revision)
if current_extra:
consider = revisions[current_index:0:-1]
s = series_extra.read_all(consider, home, current_extra, reverse = True)
vfile.begin()
for i in s:
i.apply()
vfile.commit(current, ())
if current_index < target_index:
consider = revisions[current_index + 1:target_index + 1]
s = series.read_all(consider, home)
vfile.begin()
for i in s:
i.apply()
vfile.commit(target, ())
elif current_index > target_index:
consider = revisions[current_index:target_index:-1]
s = series.read_all(consider, home, reverse = True)
vfile.begin()
for i in s:
i.apply()
vfile.commit(target, ())
if target_extra:
consider = revisions[1:target_index + 1]
s = series_extra.read_all(consider, home, target_extra)
real_extra = ()
for i in s:
t = i.extra_used
if len(t) > len(real_extra):
real_extra = t
vfile.begin()
for i in s:
i.apply()
vfile.commit(target, real_extra)
def parse_options():
from optparse import OptionParser
parser = OptionParser(
usage = "%prog [OPTION]... [TARGET]",
)
parser.add_option(
'-a', '--arch',
dest = 'arch',
help = "arch",
)
parser.add_option(
'-f', '--flavour',
dest = 'flavour',
help = "flavour",
)
parser.add_option(
'-s', '--subarch',
dest = 'subarch',
help = "subarch",
)
parser.add_option(
'-C', '--overwrite-current',
dest = 'current',
help = "overwrite current",
)
parser.add_option(
'-H', '--overwrite-home',
default = _default_home, dest = 'home',
help = "overwrite home [default: %default]",
)
parser.add_option(
'-R', '--overwrite-revisions',
default = _default_revisions, dest = 'revisions',
help = "overwrite revisions [default: %default]",
)
parser.add_option(
'-S', '--overwrite-source',
default = _default_source, dest = 'source',
help = "overwrite source [default: %default]",
)
options, args = parser.parse_args()
if options.arch is None and options.subarch is not None:
raise RuntimeError('You specified a subarch without an arch, this is not really working')
if options.subarch is None and options.flavour is not None:
raise RuntimeError('You specified a flavour without a subarch, this is not really working')
return options, args
if __name__ == '__main__':
def showwarning(message, category, filename, lineno):
sys.stderr.write("Warning: %s\n" % message)
import warnings
warnings.showwarning = showwarning
try:
main()
except RuntimeError, e:
sys.stderr.write("Error: %s\n" % e)
raise SystemExit, 1

View File

@ -1,471 +1,157 @@
#!/usr/bin/env python
#!/usr/bin/env python2.4
import os, os.path, re, sys, textwrap, ConfigParser
sys.path.append("debian/lib/python")
from debian_linux import *
import debian_linux.gencontrol
class packages_list(sorted_dict):
def append(self, package):
self[package['Package']] = package
class gencontrol(debian_linux.gencontrol.gencontrol):
def do_main_packages(self, packages):
vars = self.changelog_vars
def extend(self, packages):
for package in packages:
self[package['Package']] = package
main = self.templates["control.main"]
packages.extend(self.process_packages(main, vars))
def read_changelog():
r = re.compile(r"""
^
(
(?P<header>
(?P<header_source>
\w[-+0-9a-z.]+
)
\
\(
(?P<header_version>
[^\(\)\ \t]+
)
\)
\s+
(?P<header_distribution>
[-0-9a-zA-Z]+
)
\;
)
)
""", re.VERBOSE)
f = file("debian/changelog")
entries = []
act_upstream = None
while True:
line = f.readline()
if not line:
break
line = line.strip('\n')
match = r.match(line)
if not match:
continue
if match.group('header'):
e = entry()
e['Distribution'] = match.group('header_distribution')
e['Source'] = match.group('header_source')
version = parse_version(match.group('header_version'))
e['Version'] = version
if act_upstream is None:
act_upstream = version['upstream']
elif version['upstream'] != act_upstream:
break
entries.append(e)
return entries
tree = self.templates["control.tree"]
packages.append(self.process_real_tree(tree[0], vars))
def read_rfc822(f):
entries = []
def do_arch_packages(self, packages, makefile, arch, vars, makeflags, extra):
headers_arch = self.templates["control.headers.arch"]
package_headers_arch = self.process_package(headers_arch[0], vars)
extra['headers_arch_depends'] = []
while True:
e = entry()
while True:
line = f.readline()
if not line:
break
line = line.strip('\n')
if not line:
break
if line[0] in ' \t':
if not last:
raise ValueError('Continuation line seen before first header')
e[last] += '\n' + line.lstrip()
continue
i = line.find(':')
if i < 0:
raise ValueError("Not a header, not a continuation: ``%s''" % line)
last = line[:i]
e[last] = line[i+1:].lstrip()
if not e:
break
entries.append(e)
return entries
def read_template(name):
return read_rfc822(file("debian/templates/control.%s.in" % name))
def parse_version(version):
version_re = ur"""
^
(?P<source>
(?P<parent>
\d+\.\d+\.\d+\+
)?
(?P<upstream>
(?P<version>
(?P<major>\d+\.\d+)
\.
\d+
)
(?:
-
(?P<modifier>
.+?
)
)?
)
-
(?P<debian>[^-]+)
)
$
"""
match = re.match(version_re, version, re.X)
ret = match.groupdict()
if ret['parent'] is not None:
ret['source_upstream'] = ret['parent'] + ret['upstream']
else:
ret['source_upstream'] = ret['upstream']
return ret
def process_changelog(in_vars, config, changelog):
ret = [None, None, None, None]
ret[0] = version = changelog[0]['Version']
vars = in_vars.copy()
if version['modifier'] is not None:
ret[1] = vars['abiname'] = version['modifier']
ret[2] = ""
else:
ret[1] = vars['abiname'] = config['base']['abiname']
ret[2] = "-%s" % vars['abiname']
vars['version'] = version['version']
vars['major'] = version['major']
ret[3] = vars
return ret
def process_depends(key, e, in_e, vars):
in_dep = in_e[key].split(',')
dep = []
for d in in_dep:
d = d.strip()
d = substitute(d, vars)
if d:
dep.append(d)
if dep:
t = ', '.join(dep)
e[key] = t
def process_description(e, in_e, vars):
desc = in_e['Description']
desc_short, desc_long = desc.split ("\n", 1)
desc_pars = [substitute(i, vars) for i in desc_long.split ("\n.\n")]
desc_pars_wrapped = []
w = wrap(width = 74, fix_sentence_endings = True)
for i in desc_pars:
desc_pars_wrapped.append(w.fill(i))
e['Description'] = "%s\n%s" % (substitute(desc_short, vars), '\n.\n'.join(desc_pars_wrapped))
def process_package(in_entry, vars):
e = entry()
for i in in_entry.iterkeys():
if i in (('Depends', 'Provides', 'Suggests', 'Recommends', 'Conflicts')):
process_depends(i, e, in_entry, vars)
elif i == 'Description':
process_description(e, in_entry, vars)
elif i[:2] == 'X-':
pass
else:
e[i] = substitute(in_entry[i], vars)
return e
def process_packages(in_entries, vars):
entries = []
for i in in_entries:
entries.append(process_package(i, vars))
return entries
def process_real_image(in_entry, vars):
in_entry = in_entry.copy()
if vars.has_key('desc'):
in_entry['Description'] += "\n.\n" + vars['desc']
entry = process_package(in_entry, vars)
for i in (('Depends', 'Provides', 'Suggests', 'Recommends', 'Conflicts')):
value = []
tmp = entry.get(i, None)
if tmp:
tmp = tmp.split(',')
for t in tmp:
value.append(t.strip())
if i == 'Depends':
t = vars.get('depends', None)
if t is not None:
value.append(t)
elif i == 'Provides':
t = vars.get('provides', None)
if t is not None:
value.append(t)
elif i == 'Suggests':
t = vars.get('suggests', None)
if t is not None:
value.append(t)
elif i == 'Recommends':
t = vars.get('recommends', None)
if t is not None:
value.append(t)
elif i == 'Conflicts':
t = vars.get('conflicts', None)
if t is not None:
value.append(t)
entry[i] = ', '.join(value)
return entry
def process_real_tree(in_entry, changelog, vars):
entry = process_package(in_entry, vars)
tmp = changelog[0]['Version']['upstream']
versions = []
for i in changelog:
if i['Version']['upstream'] != tmp:
break
versions.insert(0, i['Version'])
for i in (('Depends', 'Provides')):
value = []
tmp = entry.get(i, None)
if tmp:
value.extend([j.strip() for j in tmp.split(',')])
if i == 'Depends':
value.append("linux-patch-debian-%(version)s (= %(source)s)" % changelog[0]['Version'])
value.append(' | '.join(["linux-source-%(version)s (= %(source)s)" % v for v in versions]))
elif i == 'Provides':
value.extend(["linux-tree-%(source)s" % v for v in versions])
entry[i] = ', '.join(value)
return entry
def substitute(s, vars):
def subst(match):
return vars[match.group(1)]
return re.sub(r'@([a-z_]+)@', subst, s)
def write_control(list):
write_rfc822(file("debian/control", 'w'), list)
def write_makefile(list):
f = file("debian/rules.gen", 'w')
for i in list:
f.write("%s\n" % i[0])
if i[1] is not None:
list = i[1]
if isinstance(list, basestring):
list = list.split('\n')
for j in list:
f.write("\t%s\n" % j)
def write_rfc822(f, list):
for entry in list:
for key, value in entry.iteritems():
f.write("%s:" % key)
if isinstance(value, tuple):
value = value[0].join(value[1])
for k in value.split('\n'):
f.write(" %s\n" % k)
f.write('\n')
def process_real_arch(packages, makefile, config, arch, vars, makeflags):
config_entry = config[arch,]
vars.update(config_entry)
if not config_entry.get('available', True):
for i in ('binary-arch', 'build', 'setup'):
makefile.append(("%s-%s:" % (i, arch), ["@echo Architecture %s is not available!" % arch, "@exit 1"]))
return
headers_arch = read_template("headers.arch")
package_headers_arch = process_package(headers_arch[0], vars)
package_headers_arch_depends = []
name = package_headers_arch['Package']
if packages.has_key(name):
package_headers_arch = packages.get(name)
package_headers_arch['Architecture'][1].append(arch)
else:
package_headers_arch['Architecture'] = (' ', [arch])
packages.append(package_headers_arch)
for i in (('binary-arch', 'setup',)):
makefile.append(("%s-%s:: %s-%s-real" % (i, arch, i, arch), None))
makeflags['ARCH'] = arch
makeflags_string = ' '.join(["%s='%s'" % i for i in makeflags.iteritems()])
cmds_setup = []
cmds_setup.append(("$(MAKE) -f debian/rules.real setup-arch %s" % makeflags_string,))
makefile.append(("setup-%s-real:" % arch, cmds_setup))
for subarch in config_entry['subarches']:
process_real_subarch(packages, makefile, config, arch, subarch, vars.copy(), makeflags.copy(), package_headers_arch_depends)
# Append this here so it only occurs on the install-headers-all line
makeflags_string += " FLAVOURS='%s' " % ' '.join(['%s' % i for i in config_entry['flavours']])
cmds_binary_arch = []
cmds_binary_arch.append(("$(MAKE) -f debian/rules.real install-headers-all GENCONTROL_ARGS='\"-Vkernel:Depends=%s\"' %s" % (', '.join(package_headers_arch_depends), makeflags_string),))
makefile.append(("binary-arch-%s-real:" % arch, cmds_binary_arch))
def process_real_flavour(packages, makefile, config, arch, subarch, flavour, vars, makeflags, package_headers_arch_depends):
config_entry = config[arch, subarch, flavour]
vars.update(config_entry)
vars['flavour'] = flavour
if not vars.has_key('class'):
vars['class'] = '%s-class' % flavour
if not vars.has_key('longclass'):
vars['longclass'] = vars['class']
image = read_template("image")
headers = read_template("headers")
image_latest = read_template("image.latest")
headers_latest = read_template("headers.latest")
packages_own = []
packages_dummy = []
packages_own.append(process_real_image(image[0], vars))
packages_own.append(process_package(headers[0], vars))
packages_dummy.extend(process_packages(image_latest, vars))
packages_dummy.append(process_package(headers_latest[0], vars))
for package in packages_own + packages_dummy:
name = package['Package']
name = package_headers_arch['Package']
if packages.has_key(name):
package = packages.get(name)
package['Architecture'][1].append(arch)
package_headers_arch = packages.get(name)
package_headers_arch['Architecture'].append(arch)
else:
package['Architecture'] = (' ', [arch])
packages.append(package)
package_headers_arch['Architecture'] = [arch]
packages.append(package_headers_arch)
package_headers_arch_depends.append(packages_own[1]['Package'])
makeflags_string = ' '.join(["%s='%s'" % i for i in makeflags.iteritems()])
for i in ('binary-arch', 'build', 'setup'):
makefile.append(("%s-%s-%s:: %s-%s-%s-%s" % (i, arch, subarch, i, arch, subarch, flavour), None))
makefile.append(("%s-%s-%s-%s:: %s-%s-%s-%s-real" % (i, arch, subarch, flavour, i, arch, subarch, flavour), None))
cmds_setup = []
cmds_setup.append(("$(MAKE) -f debian/rules.real setup-arch %s" % makeflags_string,))
makefile.append(("setup-%s-real:" % arch, cmds_setup))
makefile.append(("build-%s-real:" % arch))
makeflags['FLAVOUR'] = flavour
for i in (('compiler', 'COMPILER'), ('kernel-header-dirs', 'KERNEL_HEADER_DIRS'), ('kpkg-subarch', 'KPKG_SUBARCH'), ('kpkg-arch', 'KPKG_ARCH')):
if config_entry.has_key(i[0]):
makeflags[i[1]] = config_entry[i[0]]
makeflags_string = ' '.join(["%s='%s'" % i for i in makeflags.iteritems()])
def do_arch_packages_post(self, packages, makefile, arch, vars, makeflags, extra):
makeflags_string = ' '.join(["%s='%s'" % i for i in makeflags.iteritems()])
cmds_binary_arch = []
cmds_binary_arch.append(("$(MAKE) -f debian/rules.real binary-arch-flavour %s" % makeflags_string,))
cmds_binary_arch.append(("$(MAKE) -f debian/rules.real install-dummy DH_OPTIONS='%s'" % ' '.join(["-p%s" % i['Package'] for i in packages_dummy]),))
cmds_build = []
cmds_build.append(("$(MAKE) -f debian/rules.real build %s" % makeflags_string,))
cmds_setup = []
cmds_setup.append(("$(MAKE) -f debian/rules.real setup-flavour %s" % makeflags_string,))
makefile.append(("binary-arch-%s-%s-%s-real:" % (arch, subarch, flavour), cmds_binary_arch))
makefile.append(("build-%s-%s-%s-real:" % (arch, subarch, flavour), cmds_build))
makefile.append(("setup-%s-%s-%s-real:" % (arch, subarch, flavour), cmds_setup))
# Append this here so it only occurs on the install-headers-all line
# makeflags_string += " FLAVOURS='%s' " % ' '.join(['%s' % i for i in config_entry['flavours']])
cmds_binary_arch = []
cmds_binary_arch.append(("$(MAKE) -f debian/rules.real install-headers-all GENCONTROL_ARGS='\"-Vkernel:Depends=%s\"' %s" % (', '.join(extra['headers_arch_depends']), makeflags_string),))
makefile.append(("binary-arch-%s-real:" % arch, cmds_binary_arch))
def process_real_main(packages, makefile, config, version, abiname, kpkg_abiname, changelog, vars):
source = read_template("source")
packages['source'] = process_package(source[0], vars)
def do_subarch_makeflags(self, makeflags, arch, subarch):
config_entry = self.config.merge('base', arch, subarch)
for i in ('kernel-header-dirs', 'KERNEL_HEADER_DIRS'),:
if config_entry.has_key(i[0]):
makeflags[i[1]] = config_entry[i[0]]
main = read_template("main")
packages.extend(process_packages(main, vars))
def do_subarch_packages(self, packages, makefile, arch, subarch, vars, makeflags, extra):
headers_subarch = self.templates["control.headers.subarch"]
package_headers = self.process_package(headers_subarch[0], vars)
tree = read_template("tree")
packages.append(process_real_tree(tree[0], changelog, vars))
name = package_headers['Package']
if packages.has_key(name):
package_headers = packages.get(name)
package_headers['Architecture'].append(arch)
else:
package_headers['Architecture'] = [arch]
packages.append(package_headers)
makeflags = {
'VERSION': version['version'],
'SOURCE_UPSTREAM': version['source_upstream'],
'SOURCE_VERSION': version['source'],
'UPSTREAM_VERSION': version['upstream'],
'ABINAME': abiname,
'KPKG_ABINAME': kpkg_abiname,
'REVISIONS': ' '.join([i['Version']['debian'] for i in changelog[::-1]]),
}
makeflags_string = ' '.join(["%s='%s'" % i for i in makeflags.iteritems()])
makeflags_string = ' '.join(["%s='%s'" % i for i in makeflags.iteritems()])
cmds_binary_indep = []
cmds_binary_indep.append(("$(MAKE) -f debian/rules.real binary-indep %s" % makeflags_string,))
makefile.append(("binary-indep:", cmds_binary_indep))
cmds_binary_arch = []
cmds_binary_arch.append(("$(MAKE) -f debian/rules.real binary-arch-subarch %s" % makeflags_string,))
cmds_setup = []
cmds_setup.append(("$(MAKE) -f debian/rules.real setup-subarch %s" % makeflags_string,))
makefile.append(("binary-arch-%s-%s-real:" % (arch, subarch), cmds_binary_arch))
makefile.append("build-%s-%s-real:" % (arch, subarch))
makefile.append(("setup-%s-%s-real:" % (arch, subarch), cmds_setup))
for arch in iter(config['base']['arches']):
process_real_arch(packages, makefile, config, arch, vars.copy(), makeflags.copy())
def do_flavour_makeflags(self, makeflags, arch, subarch, flavour):
config_entry = self.config.merge('base', arch, subarch, flavour)
makeflags['TYPE'] = 'kernel-package'
for i in (
('compiler', 'COMPILER'),
('kernel-header-dirs', 'KERNEL_HEADER_DIRS'),
('kpkg-arch', 'KPKG_ARCH'),
('kpkg-subarch', 'KPKG_SUBARCH'),
('type', 'TYPE'),
):
if config_entry.has_key(i[0]):
makeflags[i[1]] = config_entry[i[0]]
extra = read_template("extra")
packages.extend(process_packages(extra, vars))
extra_pn = {}
for i in extra:
arches = i['Architecture'].split(' ')
for arch in arches:
pn = extra_pn.get(arch, [])
pn.append(i)
extra_pn[arch] = pn
archs = extra_pn.keys()
archs.sort()
for arch in archs:
arch_vars = vars.copy()
arch_vars.update(config[arch])
def do_flavour_packages(self, packages, makefile, arch, subarch, flavour, vars, makeflags, extra):
image = self.templates["control.image"]
headers = self.templates["control.headers"]
image_latest = self.templates["control.image.latest"]
headers_latest = self.templates["control.headers.latest"]
cmds = []
for i in extra_pn[arch]:
tmp = []
if i.has_key('X-Version-Overwrite-Epoch'):
tmp.append("-v1:%s" % version['source'])
cmds.append("$(MAKE) -f debian/rules.real install-dummy DH_OPTIONS='-p%s' GENCONTROL_ARGS='%s'" % (i['Package'], ' '.join(tmp)))
makefile.append(("binary-arch-%s:: binary-arch-%s-extra" % (arch, arch), None))
makefile.append(("binary-arch-%s-extra:" % arch, cmds))
packages_own = []
packages_dummy = []
packages_own.append(self.process_real_image(image[0], vars))
packages_own.append(self.process_package(headers[0], vars))
packages_dummy.extend(self.process_packages(image_latest, vars))
packages_dummy.append(self.process_package(headers_latest[0], vars))
def process_real_subarch(packages, makefile, config, arch, subarch, vars, makeflags, package_headers_arch_depends):
if subarch == 'none':
vars['subarch'] = ''
else:
vars['subarch'] = '%s-' % subarch
config_entry = config[arch, subarch]
vars.update(config_entry)
for package in packages_own + packages_dummy:
name = package['Package']
if packages.has_key(name):
package = packages.get(name)
package['Architecture'].append(arch)
else:
package['Architecture'] = [arch]
packages.append(package)
headers_subarch = read_template("headers.subarch")
extra['headers_arch_depends'].append(packages_own[1]['Package'])
package_headers = process_package(headers_subarch[0], vars)
makeflags_string = ' '.join(["%s='%s'" % i for i in makeflags.iteritems()])
name = package_headers['Package']
if packages.has_key(name):
package_headers = packages.get(name)
package_headers['Architecture'][1].append(arch)
else:
package_headers['Architecture'] = (' ', [arch])
packages.append(package_headers)
cmds_binary_arch = []
cmds_binary_arch.append(("$(MAKE) -f debian/rules.real binary-arch-flavour %s" % makeflags_string,))
cmds_binary_arch.append(("$(MAKE) -f debian/rules.real install-dummy DH_OPTIONS='%s'" % ' '.join(["-p%s" % i['Package'] for i in packages_dummy]),))
cmds_build = []
cmds_build.append(("$(MAKE) -f debian/rules.real build %s" % makeflags_string,))
cmds_setup = []
cmds_setup.append(("$(MAKE) -f debian/rules.real setup-flavour %s" % makeflags_string,))
makefile.append(("binary-arch-%s-%s-%s-real:" % (arch, subarch, flavour), cmds_binary_arch))
makefile.append(("build-%s-%s-%s-real:" % (arch, subarch, flavour), cmds_build))
makefile.append(("setup-%s-%s-%s-real:" % (arch, subarch, flavour), cmds_setup))
for i in ('binary-arch', 'build', 'setup'):
makefile.append(("%s-%s:: %s-%s-%s" % (i, arch, i, arch, subarch), None))
makefile.append(("%s-%s-%s::" % (i, arch, subarch), None))
for i in ('binary-arch', 'setup'):
makefile.append(("%s-%s-%s:: %s-%s-%s-real" % (i, arch, subarch, i, arch, subarch), None))
makeflags['SUBARCH'] = subarch
for i in ('kernel-header-dirs', 'KERNEL_HEADER_DIRS'),:
if config_entry.has_key(i[0]):
makeflags[i[1]] = config_entry[i[0]]
makeflags_string = ' '.join(["%s='%s'" % i for i in makeflags.iteritems()])
cmds_binary_arch = []
cmds_binary_arch.append(("$(MAKE) -f debian/rules.real binary-arch-subarch %s" % makeflags_string,))
cmds_setup = []
cmds_setup.append(("$(MAKE) -f debian/rules.real setup-subarch %s" % makeflags_string,))
makefile.append(("binary-arch-%s-%s-real:" % (arch, subarch), cmds_binary_arch))
makefile.append(("setup-%s-%s-real:" % (arch, subarch), cmds_setup))
for flavour in config_entry['flavours']:
process_real_flavour(packages, makefile, config, arch, subarch, flavour, vars.copy(), makeflags.copy(), package_headers_arch_depends)
def main():
changelog = read_changelog()
c = config()
version, abiname, kpkg_abiname, vars = process_changelog({}, c, changelog)
packages = packages_list()
makefile = []
process_real_main(packages, makefile, c, version, abiname, kpkg_abiname, changelog, vars)
write_control(packages.itervalues())
write_makefile(makefile)
def process_real_image(self, in_entry, vars):
in_entry = in_entry.copy()
if vars.has_key('desc'):
in_entry['Description'] += "\n.\n" + vars['desc']
entry = self.process_package(in_entry, vars)
for field in 'Depends', 'Provides', 'Suggests', 'Recommends', 'Conflicts':
value = entry.get(field, [])
t = vars.get(field.lower(), [])
value.extend(t)
entry[field] = value
return entry
def process_real_tree(self, in_entry, vars):
entry = self.process_package(in_entry, vars)
tmp = self.changelog[0]['Version']['upstream']
versions = []
for i in self.changelog:
if i['Version']['upstream'] != tmp:
break
versions.insert(0, i['Version'])
for i in (('Depends', 'Provides')):
value = []
tmp = entry.get(i, None)
if tmp:
value.extend([j.strip() for j in tmp.split(',')])
if i == 'Depends':
value.append("linux-patch-debian-%(version)s (= %(source)s)" % self.changelog[0]['Version'])
value.append(' | '.join(["linux-source-%(version)s (= %(source)s)" % v for v in versions]))
elif i == 'Provides':
value.extend(["linux-tree-%(source)s" % v for v in versions])
entry[i] = ', '.join(value)
return entry
if __name__ == '__main__':
main()
gencontrol()()

View File

@ -32,8 +32,8 @@ debhelper_post() {
# to linux-headers-$(subarch)-$(version)-$(abiname),
# not just linux-headers-$(version)-$(abiname).
#
prefix="$DEBIAN_VERSION-$DEBIAN_ABINAME"
pkg="linux-headers-$prefix-$DEBIAN_FLAVOUR"
prefix="$DEBIAN_VERSION$DEBIAN_LOCALVERSION_HEADERS"
pkg="linux-headers-$DEBIAN_VERSION$DEBIAN_LOCALVERSION"
top="$PWD/debian/$pkg"
dir="$top/usr/src/$pkg"
#
@ -58,7 +58,7 @@ debhelper_pre "$pkg"
mkdir -p "$dir/arch/$arch/kernel"
mkdir -p "$dir/include/linux"
cp -a .config "$dir"
echo "-$DEBIAN_ABINAME-$DEBIAN_FLAVOUR" > "$dir/.extraversion"
echo "$DEBIAN_LOCALVERSION" > "$dir/localversion"
cp -a Module.symvers "$dir"

7
debian/bin/unpatch vendored
View File

@ -1,8 +1,5 @@
#!/bin/sh
# $Id: unpatch,v 1.3 2003/06/30 12:49:09 herbert Exp $
set -e
upstream=${override_upstream:-@upstream@}
/usr/src/kernel-patches/all/$upstream/apply/debian $upstream-0
upstream="@upstream@"
exec "/usr/src/kernel-patches/all/$upstream/apply/debian" "$upstream-0"

View File

@ -1,186 +0,0 @@
import os, os.path, re, sys, textwrap, ConfigParser
class schema_item_boolean(object):
def __call__(self, i):
i = i.strip().lower()
if i in ("true", "1"):
return True
if i in ("false", "0"):
return False
raise Error
class schema_item_list(object):
def __call__(self, i):
return re.split("\s+", i.strip())
class config(dict):
schema = {
'arches': schema_item_list,
'available': schema_item_boolean,
'flavours': schema_item_list,
'subarches': schema_item_list,
}
config_name = "defines"
def __init__(self, overlay_dir = None):
self._overlay_dir = overlay_dir
self._read_base()
def __getitem__(self, key):
if isinstance(key, basestring):
return super(config, self).__getitem__(key)
if isinstance(key, tuple):
ret = {}
ret.update(super(config, self).__getitem__('base'))
if len(key) >= 1:
# XXX: workaround
del ret['abiname']
del ret['arches']
ret.update(super(config, self).__getitem__(key[0]))
if len(key) >= 2:
del ret['subarches']
ret.update(super(config, self).__getitem__('-'.join(key[0:2])))
if len(key) >= 3:
del ret['flavours']
ret.update(super(config, self).__getitem__('-'.join(key[0:3])))
return ret
raise NotImplemented
def _get_files(self, name):
ret = []
if self._overlay_dir is not None:
ret.append(os.path.join(self._overlay_dir, name))
ret.append(name)
return ret
def _read_arch(self, arch, base):
files = self._get_files("debian/arch/%s/%s" % (arch, self.config_name))
c = config_parser(self.schema)
c.read(files)
t = c.items_convert('base')
base.update(t)
self[arch] = t
subarches = t.get('subarches', [])
for subarch in subarches:
try:
t2 = c.items_convert(subarch)
avail = t2.get('available', True)
except ConfigParser.NoSectionError:
t2 = {}
avail = True
if avail:
self._read_subarch(arch, subarch, t2)
else:
self['-'.join((arch, subarch))] = t2
flavours = t.get('flavours', None)
if flavours:
for flavour in flavours:
self._read_flavour(arch, 'none', flavour, c)
self['-'.join((arch, 'none'))] = {}
subarches.insert(0, 'none')
t['subarches'] = subarches
def _read_base(self):
files = self._get_files("debian/arch/%s" % self.config_name)
c = config_parser(self.schema)
c.read(files)
t1 = c.items_convert('base')
self['base'] = t1
for arch in t1['arches']:
try:
t2 = c.items_convert(arch)
avail = t2.get('available', True)
except ConfigParser.NoSectionError:
t2 = {}
avail = True
if avail:
self._read_arch(arch, t2)
else:
self[arch] = t2
def _read_flavour(self, arch, subarch, flavour, c):
try:
t = c.items_convert(flavour)
except ConfigParser.NoSectionError:
try:
t = c.items_convert("%s-none-%s" % (arch, flavour))
except ConfigParser.NoSectionError:
#raise RuntimeError("Don't find config for %s-none-%s!" % (arch, flavour))
t = {}
self["%s-%s-%s" % (arch, subarch, flavour)] = t
def _read_subarch(self, arch, subarch, base):
files = self._get_files("debian/arch/%s/%s/%s" % (arch, subarch, self.config_name))
c = config_parser(self.schema)
c.read(files)
t = c.items_convert('base')
base.update(t)
self['-'.join((arch, subarch))] = t
flavours = t.get('flavours', None)
for flavour in flavours:
self._read_flavour(arch, subarch, flavour, c)
class config_parser(object, ConfigParser.ConfigParser):
def __init__(self, schema):
ConfigParser.ConfigParser.__init__(self)
self.schema = schema
def items_convert(self, section):
items = self.items(section)
ret = {}
for key, value in items:
try:
convert = self.schema[key]()
value = convert(value)
except KeyError: pass
ret[key] = value
return ret
class _sorted_dict(dict):
__slots__ = ('_list')
def __init__(self):
super(_sorted_dict, self).__init__()
self._list = []
def __delitem__(self, key):
super(_sorted_dict, self).__delitem__(key)
self._list.remove(key)
def iterkeys(self):
for i in iter(self._list):
yield i
def iteritems(self):
for i in iter(self._list):
yield (i, self[i])
def itervalues(self):
for i in iter(self._list):
yield self[i]
class sorted_dict(_sorted_dict):
__slots__ = ()
def __setitem__(self, key, value):
super(sorted_dict, self).__setitem__(key, value)
if key not in self._list:
self._list.append(key)
class entry(_sorted_dict):
__slots__ = ()
def __setitem__(self, key, value):
super(entry, self).__setitem__(key, value)
if key not in self._list:
if 'Description' in self._list:
self._list.insert(len(self._list)-1, key)
else:
self._list.append(key)
class wrap(textwrap.TextWrapper):
wordsep_re = re.compile(
r'(\s+|' # any whitespace
r'(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))') # em-dash

View File

@ -0,0 +1,6 @@
import os, os.path, re, sys, textwrap, ConfigParser
from config import config_reader
from debian import *
from utils import *

223
debian/lib/python/debian_linux/config.py vendored Normal file
View File

@ -0,0 +1,223 @@
import os, os.path, re, sys, textwrap, ConfigParser
__all__ = 'config_reader',
_marker = object()
class config_reader(dict):
"""
Read configs in debian/arch and in the overlay directory.
"""
class schema_item_boolean(object):
def __call__(self, i):
i = i.strip().lower()
if i in ("true", "1"):
return True
if i in ("false", "0"):
return False
raise Error
class schema_item_list(object):
def __init__(self, type = "\s+"):
self.type = type
def __call__(self, i):
return [j.strip() for j in re.split(self.type, i.strip())]
schema = {
'arches': schema_item_list(),
'available': schema_item_boolean(),
'flavours': schema_item_list(),
'subarches': schema_item_list(),
}
config_name = "defines"
def __init__(self, overlay_dir = None):
self._overlay_dir = overlay_dir
self._read_base()
def __getitem__(self, key):
return self.get(key)
def _get_files(self, name):
ret = []
if self._overlay_dir is not None:
ret.append(os.path.join(self._overlay_dir, name))
ret.append(os.path.join('debian/arch', name))
return ret
def _read_arch(self, arch):
files = self._get_files("%s/%s" % (arch, self.config_name))
config = config_parser(self.schema, files)
subarches = config['base',].get('subarches', [])
flavours = config['base',].get('flavours', [])
for section in iter(config):
real = list(section)
if real[-1] in subarches:
real[0:0] = ['base', arch]
elif real[-1] in flavours:
real[0:0] = ['base', arch, 'none']
else:
real[0:] = [real.pop(), arch]
real = tuple(real)
s = self.get(real, {})
s.update(config[section])
self[tuple(real)] = s
for subarch in subarches:
if self.has_key(('base', arch, subarch)):
avail = self['base', arch, subarch].get('available', True)
else:
avail = True
if avail:
self._read_subarch(arch, subarch)
if flavours:
base = self['base', arch]
subarches.insert(0, 'none')
base['subarches'] = subarches
del base['flavours']
self['base', arch] = base
self['base', arch, 'none'] = {'flavours': flavours}
for flavour in flavours:
self._read_flavour(arch, 'none', flavour)
def _read_base(self):
files = self._get_files(self.config_name)
config = config_parser(self.schema, files)
arches = config['base',]['arches']
for section in iter(config):
real = list(section)
if real[-1] in arches:
real.insert(0, 'base')
else:
real.insert(0, real.pop())
self[tuple(real)] = config[section]
for arch in arches:
try:
avail = self['base', arch].get('available', True)
except KeyError:
avail = True
if avail:
self._read_arch(arch)
def _read_flavour(self, arch, subarch, flavour):
if not self.has_key(('base', arch, subarch, flavour)):
import warnings
warnings.warn('No config entry for flavour %s, subarch %s, arch %s' % (flavour, subarch, arch), DeprecationWarning)
self['base', arch, subarch, flavour] = {}
def _read_subarch(self, arch, subarch):
files = self._get_files("%s/%s/%s" % (arch, subarch, self.config_name))
config = config_parser(self.schema, files)
flavours = config['base',].get('flavours', [])
for section in iter(config):
real = list(section)
if real[-1] in flavours:
real[0:0] = ['base', arch, subarch]
else:
real[0:] = [real.pop(), arch, subarch]
real = tuple(real)
s = self.get(real, {})
s.update(config[section])
self[tuple(real)] = s
for flavour in flavours:
self._read_flavour(arch, subarch, flavour)
def _update(self, ret, inputkey):
for key, value in super(config_reader, self).get(tuple(inputkey), {}).iteritems():
ret[key] = value
def get(self, key, default = _marker):
if isinstance(key, basestring):
key = key,
ret = super(config_reader, self).get(tuple(key), default)
if ret == _marker:
raise KeyError, key
return ret
def merge(self, section, *args):
ret = {}
for i in xrange(0, len(args) + 1):
ret.update(self.get(tuple([section] + list(args[:i])), {}))
if section == 'base':
for i in ('abiname', 'arches', 'flavours', 'subarches'):
try:
del ret[i]
except KeyError: pass
return ret
def sections(self):
return super(config_reader, self).keys()
class config_parser(object):
__slots__ = 'configs', 'schema'
def __init__(self, schema, files):
self.configs = []
self.schema = schema
for file in files:
config = ConfigParser.ConfigParser()
config.read(file)
self.configs.append(config)
def __getitem__(self, key):
return self.items(key)
def __iter__(self):
return iter(self.sections())
def items(self, section, var = {}):
ret = {}
section = '_'.join(section)
exception = None
for config in self.configs:
try:
items = config.items(section)
except ConfigParser.NoSectionError, e:
exception = e
else:
for key, value in items:
try:
value = self.schema[key](value)
except KeyError: pass
ret[key] = value
exception = None
if exception is not None:
raise exception
return ret
def sections(self):
sections = []
for config in self.configs:
for section in config.sections():
section = tuple(section.split('_'))
if section not in sections:
sections.append(section)
return sections
if __name__ == '__main__':
import sys
config = config_reader()
sections = config.sections()
sections.sort()
for section in sections:
print "[%s]" % (section,)
items = config[section]
items_keys = items.keys()
items_keys.sort()
for item in items:
print "%s: %s" % (item, items[item])
print

View File

@ -0,0 +1,83 @@
import re, utils
def read_changelog():
r = re.compile(r"""
^
(
(?P<header>
(?P<header_source>
\w[-+0-9a-z.]+
)
\
\(
(?P<header_version>
[^\(\)\ \t]+
)
\)
\s+
(?P<header_distribution>
[-0-9a-zA-Z]+
)
\;
)
)
""", re.VERBOSE)
f = file("debian/changelog")
entries = []
act_upstream = None
while True:
line = f.readline()
if not line:
break
line = line.strip('\n')
match = r.match(line)
if not match:
continue
if match.group('header'):
e = {}
e['Distribution'] = match.group('header_distribution')
e['Source'] = match.group('header_source')
version = parse_version(match.group('header_version'))
e['Version'] = version
if act_upstream is None:
act_upstream = version['upstream']
elif version['upstream'] != act_upstream:
break
entries.append(e)
return entries
def parse_version(version):
version_re = ur"""
^
(?P<source>
(?P<parent>
\d+\.\d+\.\d+\+
)?
(?P<upstream>
(?P<version>
(?P<major>\d+\.\d+)
\.
\d+
)
(?:
-
(?P<modifier>
.+?
)
)?
)
-
(?P<debian>[^-]+)
)
$
"""
match = re.match(version_re, version, re.X)
if match is None:
raise ValueError
ret = match.groupdict()
if ret['parent'] is not None:
ret['source_upstream'] = ret['parent'] + ret['upstream']
else:
ret['source_upstream'] = ret['upstream']
return ret

View File

@ -0,0 +1,258 @@
from config import *
from debian import *
from utils import *
class packages_list(sorted_dict):
def append(self, package):
self[package['Package']] = package
def extend(self, packages):
for package in packages:
self[package['Package']] = package
class gencontrol(object):
def __init__(self):
self.changelog = read_changelog()
self.config = config_reader()
self.templates = templates()
self.version, self.abiname, self.kpkg_abiname, self.changelog_vars = self.process_changelog({})
def __call__(self):
packages = packages_list()
makefile = []
self.do_source(packages)
self.do_main(packages, makefile)
self.do_extra(packages, makefile)
self.write_control(packages.itervalues())
self.write_makefile(makefile)
def do_source(self, packages):
source = self.templates["control.source"]
packages['source'] = self.process_package(source[0], self.changelog_vars)
def do_main(self, packages, makefile):
makeflags = {
'VERSION': self.version['version'],
'SOURCE_UPSTREAM': self.version['source_upstream'],
'SOURCE_VERSION': self.version['source'],
'UPSTREAM_VERSION': self.version['upstream'],
'ABINAME': self.abiname,
'KPKG_ABINAME': self.kpkg_abiname,
'REVISIONS': ' '.join([i['Version']['debian'] for i in self.changelog[::-1]]),
}
self.do_main_packages(packages)
self.do_main_makefile(makefile, makeflags)
for arch in iter(self.config['base',]['arches']):
self.do_arch(packages, makefile, arch, self.changelog_vars.copy(), makeflags.copy())
def do_main_makefile(self, makefile, makeflags):
makeflags_string = ' '.join(["%s='%s'" % i for i in makeflags.iteritems()])
cmds_binary_indep = []
cmds_binary_indep.append(("$(MAKE) -f debian/rules.real binary-indep %s" % makeflags_string,))
makefile.append(("binary-indep:", cmds_binary_indep))
def do_main_packages(self, packages):
pass
def do_extra(self, packages, makefile):
try:
templates_extra = self.templates["control.extra"]
except IOError:
return
packages.extend(self.process_packages(templates_extra, {}))
extra_arches = {}
for package in templates_extra:
arches = package['Architecture']
for arch in arches:
i = extra_arches.get(arch, [])
i.append(package)
extra_arches[arch] = i
archs = extra_arches.keys()
archs.sort()
for arch in archs:
cmds = []
for i in extra_arches[arch]:
tmp = []
if i.has_key('X-Version-Overwrite-Epoch'):
tmp.append("-v1:%s" % self.version['source'])
cmds.append("$(MAKE) -f debian/rules.real install-dummy DH_OPTIONS='-p%s' GENCONTROL_ARGS='%s'" % (i['Package'], ' '.join(tmp)))
makefile.append("binary-arch-%s:: binary-arch-%s-extra" % (arch, arch))
makefile.append(("binary-arch-%s-extra:" % arch, cmds))
def do_arch(self, packages, makefile, arch, vars, makeflags):
config_entry = self.config['base', arch]
vars.update(config_entry)
if not config_entry.get('available', True):
for i in ('binary-arch', 'build', 'setup'):
makefile.append(("%s-%s:" % (i, arch), ["@echo Architecture %s is not available!" % arch, "@exit 1"]))
return
extra = {}
makeflags['ARCH'] = arch
self.do_arch_makeflags(makeflags, arch)
self.do_arch_makefile(makefile, arch, makeflags)
self.do_arch_packages(packages, makefile, arch, vars, makeflags, extra)
for subarch in config_entry['subarches']:
self.do_subarch(packages, makefile, arch, subarch, vars.copy(), makeflags.copy(), extra)
self.do_arch_packages_post(packages, makefile, arch, vars, makeflags, extra)
def do_arch_makeflags(self, makeflags, arch):
pass
def do_arch_makefile(self, makefile, arch, makeflags):
for i in (('binary-arch', 'build', 'setup',)):
makefile.append("%s-%s:: %s-%s-real" % (i, arch, i, arch))
def do_arch_packages(self, packages, makefile, arch, vars, makeflags, extra):
pass
def do_arch_packages_post(self, packages, makefile, arch, vars, makeflags, extra):
pass
def do_subarch(self, packages, makefile, arch, subarch, vars, makeflags, extra):
if subarch == 'none':
vars['subarch'] = ''
else:
vars['subarch'] = '-%s' % subarch
config_entry = self.config['base', arch, subarch]
vars.update(config_entry)
makeflags['SUBARCH'] = subarch
self.do_subarch_makeflags(makeflags, arch, subarch)
self.do_subarch_makefile(makefile, arch, subarch, makeflags)
self.do_subarch_packages(packages, makefile, arch, subarch, vars, makeflags, extra)
for flavour in config_entry['flavours']:
self.do_flavour(packages, makefile, arch, subarch, flavour, vars.copy(), makeflags.copy(), extra)
def do_subarch_makeflags(self, makeflags, arch, subarch):
pass
def do_subarch_makefile(self, makefile, arch, subarch, makeflags):
for i in ('binary-arch', 'build', 'setup'):
makefile.append("%s-%s:: %s-%s-%s" % (i, arch, i, arch, subarch))
makefile.append("%s-%s-%s:: %s-%s-%s-real" % (i, arch, subarch, i, arch, subarch))
def do_subarch_packages(self, packages, makefile, arch, subarch, vars, makeflags, extra):
pass
def do_flavour(self, packages, makefile, arch, subarch, flavour, vars, makeflags, extra):
config_entry = self.config['base', arch, subarch, flavour]
vars.update(config_entry)
vars['flavour'] = flavour
if not vars.has_key('class'):
vars['class'] = '%s-class' % flavour
if not vars.has_key('longclass'):
vars['longclass'] = vars['class']
makeflags['FLAVOUR'] = flavour
self.do_flavour_makeflags(makeflags, arch, subarch, flavour)
self.do_flavour_makefile(makefile, arch, subarch, flavour, makeflags)
self.do_flavour_packages(packages, makefile, arch, subarch, flavour, vars, makeflags, extra)
def do_flavour_makeflags(self, makeflags, arch, subarch, flavour):
pass
def do_flavour_makefile(self, makefile, arch, subarch, flavour, makeflags):
for i in ('binary-arch', 'build', 'setup'):
makefile.append("%s-%s-%s:: %s-%s-%s-%s" % (i, arch, subarch, i, arch, subarch, flavour))
makefile.append("%s-%s-%s-%s:: %s-%s-%s-%s-real" % (i, arch, subarch, flavour, i, arch, subarch, flavour))
def do_flavour_packages(self, packages, makefile, arch, subarch, flavour, vars, makeflags, extra):
pass
def process_changelog(self, in_vars):
ret = [None, None, None, None]
ret[0] = version = self.changelog[0]['Version']
vars = in_vars.copy()
if version['modifier'] is not None:
ret[1] = vars['abiname'] = version['modifier']
ret[2] = ""
else:
ret[1] = vars['abiname'] = self.config['base',]['abiname']
ret[2] = "-%s" % vars['abiname']
vars['version'] = version['version']
vars['major'] = version['major']
ret[3] = vars
return ret
def process_relation(self, key, e, in_e, vars):
in_dep = in_e[key]
dep = type(in_dep)()
for d in in_dep:
d = self.substitute(d, vars)
if d:
dep.append(d)
e[key] = dep
def process_description(self, e, in_e, vars):
desc = in_e['Description']
desc_short, desc_long = desc.split ("\n", 1)
desc_pars = [self.substitute(i, vars) for i in desc_long.split ("\n.\n")]
desc_pars_wrapped = []
w = wrap(width = 74, fix_sentence_endings = True)
for i in desc_pars:
desc_pars_wrapped.append(w.fill(i))
e['Description'] = "%s\n%s" % (self.substitute(desc_short, vars), '\n.\n'.join(desc_pars_wrapped))
def process_package(self, in_entry, vars):
e = package()
for key in in_entry.iterkeys():
if key in (('Depends', 'Provides', 'Suggests', 'Recommends', 'Conflicts')):
self.process_relation(key, e, in_entry, vars)
elif key == 'Description':
self.process_description(e, in_entry, vars)
elif key[:2] == 'X-':
pass
else:
e[key] = self.substitute(in_entry[key], vars)
return e
def process_packages(self, in_entries, vars):
entries = []
for i in in_entries:
entries.append(self.process_package(i, vars))
return entries
def substitute(self, s, vars):
if isinstance(s, (list, tuple)):
for i in xrange(len(s)):
s[i] = self.substitute(s[i], vars)
return s
def subst(match):
return vars[match.group(1)]
return re.sub(r'@([a-z_]+)@', subst, s)
def write_control(self, list):
self.write_rfc822(file("debian/control", 'w'), list)
def write_makefile(self, out_list):
out = file("debian/rules.gen", 'w')
for item in out_list:
if isinstance(item, (list, tuple)):
out.write("%s\n" % item[0])
cmd_list = item[1]
if isinstance(cmd_list, basestring):
cmd_list = cmd_list.split('\n')
for j in cmd_list:
out.write("\t%s\n" % j)
else:
out.write("%s\n" % item)
def write_rfc822(self, f, list):
for entry in list:
for key, value in entry.iteritems():
f.write("%s: %s\n" % (key, value))
f.write('\n')

175
debian/lib/python/debian_linux/utils.py vendored Normal file
View File

@ -0,0 +1,175 @@
import re, textwrap
class _sorted_dict(dict):
__slots__ = ('_list')
def __init__(self, entries = None):
super(_sorted_dict, self).__init__()
self._list = []
if entries is not None:
for key, value in entries:
self[key] = value
def __delitem__(self, key):
super(_sorted_dict, self).__delitem__(key)
self._list.remove(key)
def iterkeys(self):
for i in iter(self._list):
yield i
def iteritems(self):
for i in iter(self._list):
yield (i, self[i])
def itervalues(self):
for i in iter(self._list):
yield self[i]
class sorted_dict(_sorted_dict):
__slots__ = ()
def __setitem__(self, key, value):
super(sorted_dict, self).__setitem__(key, value)
if key not in self._list:
self._list.append(key)
class field_list(list):
TYPE_WHITESPACE = object()
TYPE_COMMATA = object()
def __init__(self, value = None, type = TYPE_WHITESPACE):
self.type = type
if isinstance(value, field_list):
self.type = value.type
self.extend(value)
elif isinstance(value, (list, tuple)):
self.extend(value)
else:
self._extend(value)
def __str__(self):
if self.type is self.TYPE_WHITESPACE:
type = ' '
elif self.type is self.TYPE_COMMATA:
type = ', '
return type.join(self)
def _extend(self, value):
if self.type is self.TYPE_WHITESPACE:
type = '\s'
elif self.type is self.TYPE_COMMATA:
type = ','
if value is not None:
self.extend([j.strip() for j in re.split(type, value.strip())])
def extend(self, value):
if isinstance(value, str):
self._extend(value)
else:
super(field_list, self).extend(value)
class field_list_commata(field_list):
def __init__(self, value = None):
super(field_list_commata, self).__init__(value, field_list.TYPE_COMMATA)
class field_string(str):
def __str__(self):
return '\n '.join(self.split('\n'))
class package(dict):
_fields = sorted_dict((
('Package', str),
('Source', str),
('Architecture', field_list),
('Section', str),
('Priority', str),
('Maintainer', str),
('Uploaders', str),
('Standards-Version', str),
('Build-Depends', str),
('Build-Depends-Indep', str),
('Provides', field_list_commata),
('Depends', field_list_commata),
('Recommends', field_list_commata),
('Suggests', field_list_commata),
('Replaces', field_list_commata),
('Conflicts', field_list_commata),
('Description', field_string),
))
def __setitem__(self, key, value):
try:
value = self._fields[key](value)
except KeyError: pass
super(package, self).__setitem__(key, value)
def iterkeys(self):
for i in self._fields.iterkeys():
if self.has_key(i) and self[i]:
yield i
def iteritems(self):
for i in self._fields.iterkeys():
if self.has_key(i) and self[i]:
yield (i, self[i])
def itervalues(self):
for i in self._fields.iterkeys():
if self.has_key(i) and self[i]:
yield self[i]
class templates(dict):
def __init__(self, dir = None):
if dir is None:
self.dir = "debian/templates"
else:
self.dir = dir
def __getitem__(self, key):
try:
return dict.__getitem__(self, key)
except KeyError: pass
ret = self._read(key)
dict.__setitem__(self, key, ret)
return ret
def __setitem__(self, key, value):
raise NotImplemented()
def _read(self, filename):
entries = []
f = file("%s/%s.in" % (self.dir, filename))
while True:
e = package()
while True:
line = f.readline()
if not line:
break
line = line.strip('\n')
if not line:
break
if line[0] in ' \t':
if not last:
raise ValueError('Continuation line seen before first header')
e[last] += '\n' + line.lstrip()
continue
i = line.find(':')
if i < 0:
raise ValueError("Not a header, not a continuation: ``%s''" % line)
last = line[:i]
e[last] = line[i+1:].lstrip()
if not e:
break
entries.append(e)
return entries
class wrap(textwrap.TextWrapper):
wordsep_re = re.compile(
r'(\s+|' # any whitespace
r'(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))') # em-dash

2
debian/patches-debian/series/2-extra vendored Normal file
View File

@ -0,0 +1,2 @@
+ hppa-incompatible.patch hppa
+ m68k-incompatible.patch m68k

2
debian/rules vendored
View File

@ -43,7 +43,7 @@ maintainerclean:
clean: debian/control
dh_testdir
rm -rf $(BUILD_DIR) $(STAMPS_DIR) debian/lib/python/*.pyc debian/*.kpatches.arch
rm -rf $(BUILD_DIR) $(STAMPS_DIR) debian/lib/python/debian_linux/*.pyc
dh_clean
binary-indep: build

66
debian/rules.real vendored
View File

@ -4,26 +4,25 @@
# variable means that we are building for an arch without the subarch.
# Additionally, variables version, abiname and ltver are
# expected to be available (need to be exported from the parent process).
# It is possible to override the flavours by setting the flavours
# variable. It will also be passed a list of source files
#
SHELL := sh -e
DEB_HOST_ARCH := $(shell dpkg-architecture -a'$(ARCH)' -qDEB_HOST_ARCH)
DEB_HOST_GNU_TYPE := $(shell dpkg-architecture -a'$(ARCH)' -qDEB_HOST_GNU_TYPE)
DEB_BUILD_ARCH := $(shell dpkg-architecture -a'$(ARCH)' -qDEB_BUILD_ARCH)
export PYTHONPATH = $(CURDIR)/debian/lib/python
#
# Build the list of common config files to be included
#
ifeq ($(SUBARCH),none)
basedir := debian/arch/$(ARCH)
LOCALVERSION := -$(FLAVOUR)
LOCALVERSION_HEADERS :=
else
basedir := debian/arch/$(ARCH)/$(SUBARCH)
endif
configs := $(notdir $(wildcard $(basedir)/config.*))
configs := $(filter-out config, $(configs))
ifndef flavours
flavours := $(patsubst config.%,%,$(configs))
LOCALVERSION := -$(SUBARCH)-$(FLAVOUR)
LOCALVERSION_HEADERS := -$(SUBARCH)
endif
-include $(basedir)/Makefile.inc
@ -37,11 +36,11 @@ include debian/rules.defs
# in Makefile.inc. @flavour@ in the expressions is going to be
# replaced by the flavour for which the command is run.
#
kpkg_header += make-kpkg --append-to-version '$(KPKG_ABINAME)'
kpkg_header += make-kpkg --append-to-version '$(KPKG_ABINAME)$(LOCALVERSION_HEADERS)'
kpkg_header += --arch '$(ARCH)'
kpkg_header += --stem linux
kpkg_header += --config defconfig
kpkg_image := make-kpkg --append-to-version '$(KPKG_ABINAME)-$(FLAVOUR)'
kpkg_image := make-kpkg --append-to-version '$(KPKG_ABINAME)$(LOCALVERSION)'
kpkg_image += --arch '$(ARCH)'
kpkg_image += --stem linux
kpkg_image += --initrd
@ -54,7 +53,9 @@ ifneq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
kpkg_image += --cross-compile='$(DEB_HOST_GNU_TYPE)'
endif
setup_env := env -u ABINAME -u ARCH -u SUBARCH -u FLAVOUR -u VERSION
setup_env += DEBIAN_ABINAME='$(ABINAME)' DEBIAN_FLAVOUR='$(FLAVOUR)' DEBIAN_VERSION='$(VERSION)'
setup_env += DEBIAN_LOCALVERSION='-$(ABINAME)$(LOCALVERSION)'
setup_env += DEBIAN_LOCALVERSION_HEADERS='-$(ABINAME)$(LOCALVERSION_HEADERS)'
setup_env += DEBIAN_VERSION='$(VERSION)'
setup_makeflags =
ifdef COMPILER
setup_makeflags += CC="$$$$(CROSS_COMPILE)$(COMPILER)"
@ -93,7 +94,7 @@ ifneq ($(SUBARCH),none)
endif
$(BUILD_DIR)/config.$(ARCH)-$(SUBARCH)-$(FLAVOUR): $(basedir)/config.$(FLAVOUR) $(config_common)
@echo "Generating configuration file $@:"
ocaml debian/bin/kconfig.ml -ba -b "$(basedir)" -a "$(ARCH)" -s "$(SUBARCH)" -f "$(FLAVOUR)" > '$@'
ocaml debian/bin/kconfig.ml -b "debian/arch" -a "$(ARCH)" -s "$(SUBARCH)" -f "$(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-$(UPSTREAM_VERSION)
@ -104,13 +105,17 @@ $(BUILD_DIR)/linux-source-$(UPSTREAM_VERSION).tar.bz2: $(STAMPS_DIR)/source
cd '$(BUILD_DIR)'; tar -cjf 'linux-source-$(UPSTREAM_VERSION).tar.bz2' 'linux-source-$(UPSTREAM_VERSION)'
rm -rf '$(DIR)'
define patch_cmd
cd '$(DIR)'; python2.4 '$(CURDIR)/debian/bin/apply.py' --overwrite-home='$(CURDIR)/debian/patches-debian' --overwrite-source='$(SOURCE_VERSION)' --overwrite-revisions='$(REVISIONS)'
endef
srcfiles := $(filter-out debian, $(wildcard *))
$(STAMPS_DIR)/source: DIR=$(BUILD_DIR)/source
$(STAMPS_DIR)/source: debian/bin/apply
$(STAMPS_DIR)/source: debian/bin/apply.py
rm -rf '$(DIR)'
mkdir -p '$(DIR)'
cp -al $(srcfiles) '$(DIR)'
cd '$(DIR)'; override_version='$(SOURCE_VERSION)' override_revisions='$(REVISIONS)' home='$(CURDIR)/debian/patches-debian' sh '$(CURDIR)/debian/bin/apply'
$(patch_cmd)
#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'
@ -118,11 +123,6 @@ $(STAMPS_DIR)/source: debian/bin/apply
echo "all:" >> '$(DIR)/scripts/package/Makefile'
touch '$@'
patches := $(wildcard debian/patches-arch/$(SUBARCH).*)
patches += $(wildcard debian/patches-arch/$(SUBARCH)_*)
patches += $(wildcard debian/patches-arch/$(ARCH).*)
patches += $(wildcard debian/patches-arch/$(ARCH)_*)
patches := $(strip $(patches))
$(STAMPS_DIR)/source-$(ARCH)-$(SUBARCH): SOURCE_DIR=$(BUILD_DIR)/source
$(STAMPS_DIR)/source-$(ARCH)-$(SUBARCH): DIR=$(BUILD_DIR)/source-$(ARCH)-$(SUBARCH)
$(STAMPS_DIR)/source-$(ARCH)-$(SUBARCH): $(STAMPS_DIR)/source
@ -133,12 +133,7 @@ $(STAMPS_DIR)/source-$(ARCH)-$(SUBARCH): $(STAMPS_DIR)/source
cp debian/copyright '$(DIR)/debian'
cp debian/control '$(DIR)/debian/control'
touch '$(DIR)/debian/official'
if [ -n '$(patches)' ]; then \
cd '$(DIR)'; \
for patch in $(patches); do \
cat "$(CURDIR)/$$patch" | patch -p1; \
done; \
fi
$(patch_cmd) -a $(ARCH) -s $(SUBARCH)
touch '$@'
#
# This target performs a build for a particular flavour. Note
@ -258,26 +253,15 @@ 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 -e 's/@version@/$(SOURCE_VERSION)/g' -e 's/@revisions@/$(REVISIONS)/' debian/bin/apply > '$(pfull)/apply/debian'
sed \
-e 's,@home@,$(pbase)/debian,' \
-e 's,@revisions@,$(REVISIONS),' \
-e 's,@source@,$(SOURCE_VERSION),' \
debian/bin/apply.py > '$(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
# Now the arch/subarch-specific patches
for i in $(ptchs); do \
arch="$${i%%.*}"; \
( \
echo "Patch-name: $${arch}"; \
echo "Patch-id: $${arch}_$(subst .,_,$(VERSION))"; \
echo "Path-strip-level: 1"; \
echo; \
echo "Patch-file: debian/patches-arch/$${i}"; \
echo "Architecture: $${arch}"; \
echo "Kernel-version: $(VERSION)"; \
echo; \
) > 'debian/$(PACKAGE).kpatches.arch'; \
dh_installkpatches $(DH_OPTIONS); \
done
dh_installdocs $(DH_OPTIONS)
dh_installchangelogs $(DH_OPTIONS)
$(MAKE) -f debian/rules.real install-base DH_OPTIONS='$(DH_OPTIONS)'

View File

@ -1,15 +1,15 @@
Package: linux-headers-@subarch@@version@-@abiname@-@flavour@
Package: linux-headers-@version@-@abiname@@subarch@-@flavour@
Section: devel
Priority: optional
Depends: linux-headers-@subarch@@version@-@abiname@ (= ${Source-Version})
Depends: linux-headers-@version@-@abiname@@subarch@ (= ${Source-Version})
Provides: linux-headers, linux-headers-@major@
Description: Header files for Linux kernel @version@ on @class@ machines
This package provides the architecture-specific kernel header files
for Linux kernel @version@ on @longclass@ machines, generally
used for building out-of-tree kernel modules. These files are going to be
installed into /usr/src/linux-headers-@subarch@@version@-@abiname@-@flavour@, and can
installed into /usr/src/linux-headers-@version@-@abiname@@subarch@-@flavour@, and can
be used for building modules that load into the kernel provided by the
linux-image-@subarch@@version@-@abiname@-@flavour@ package.
linux-image-@version@-@abiname@@subarch@-@flavour@ package.
.
This packages is produced using an updated kernel packaging system
and replaces older kernel-headers packages

View File

@ -1,7 +1,7 @@
Package: linux-headers-@subarch@@major@-@flavour@
Package: linux-headers-@major@@subarch@-@flavour@
Section: devel
Priority: optional
Depends: linux-headers-@subarch@@version@-@abiname@-@flavour@
Depends: linux-headers-@version@-@abiname@@subarch@-@flavour@
Provides: linux-headers, linux-headers-@major@
Description: Architecture-specific header files for Linux kernel @major@ on @class@ machines
This package depends on the architecture-specific header files for the latest

View File

@ -1,4 +1,4 @@
Package: linux-headers-@subarch@@version@-@abiname@
Package: linux-headers-@version@-@abiname@@subarch@
Section: devel
Priority: optional
Provides: linux-headers, linux-headers-@major@
@ -6,10 +6,10 @@ Description: Common header files for Linux kernel @version@
This package provides the (sub)architecture-specific common kernel header files
for Linux kernel version @version@, generally used for building out-of-tree
kernel modules. To obtain a complete set of headers you also need to install
the linux-headers-@subarch@@version@-@abiname@-(flavour) package, matching the
the linux-headers-@version@-@abiname@@subarch@-(flavour) package, matching the
flavour of the kernel you intend the build for. To obtain such a set for the
currently running kernel it is sufficient to run a command
.
apt-get install linux-headers-@subarch@$(uname -r)
apt-get install linux-headers-$(uname -r)
.
and it will be unpacked in /usr/src/linux-headers-@subarch@@version@-@abiname@-(flavour).
and it will be unpacked in /usr/src/linux-headers-@version@-@abiname@@subarch@-(flavour).

View File

@ -1,4 +1,4 @@
Package: linux-image-@subarch@@version@-@abiname@-@flavour@
Package: linux-image-@version@-@abiname@@subarch@-@flavour@
Section: base
Priority: optional
Provides: linux-image, linux-image-@major@

View File

@ -1,15 +1,15 @@
Package: linux-image-@subarch@@flavour@
Package: linux-image@subarch@-@flavour@
Section: base
Priority: optional
Depends: linux-image-@subarch@@major@-@flavour@
Depends: linux-image-@major@@subarch@-@flavour@
Description: Linux kernel image on @class@ machines
This package depends on the latest binary image for Linux kernel on
@longclass@ machines.
Package: linux-image-@subarch@@major@-@flavour@
Package: linux-image-@major@@subarch@-@flavour@
Section: base
Priority: optional
Depends: linux-image-@subarch@@version@-@abiname@-@flavour@
Depends: linux-image-@version@-@abiname@@subarch@-@flavour@
Description: Linux kernel @major@ image on @class@ machines
This package depends on the latest binary image for Linux kernel @major@
on @longclass@ machines.

View File

@ -57,7 +57,7 @@ Package: linux-patch-debian-@version@
Architecture: all
Section: devel
Priority: optional
Depends: bzip2, ${kpatch:Depends}
Depends: bzip2, python2.4-minimal
Suggests: linux-source-@version@
Description: Debian patches to version @version@ of the Linux kernel
This package includes the patches used to produce the prepackaged

View File

@ -4,5 +4,5 @@ Priority: optional
Maintainer: Debian Kernel Team <debian-kernel@lists.debian.org>
Uploaders: Andres Salomon <dilinger@debian.org>, Bastian Blank <waldi@debian.org>, Simon Horman <horms@debian.org>, Sven Luther <luther@debian.org>, Jonas Smedegaard <dr@jones.dk>, Norbert Tretkowski <nobse@debian.org>, Frederik Schüler <fs@debian.org>
Standards-Version: 3.6.1.0
Build-Depends: gcc (>= 4:4.0) [!m68k], gcc-3.3 [m68k], binutils-hppa64 [hppa], gcc-4.0-hppa64 [hppa], debhelper (>= 4.1.0), module-init-tools, dpkg-dev (>= 1.10.23), debianutils (>= 1.6), bzip2, sparc-utils [sparc], kernel-package (>= 10.029), ocaml-interp
Build-Depends-Indep: docbook-utils, gs, transfig, xmlto, dh-kpatches (>= 0.99.3)
Build-Depends: gcc (>= 4:4.0) [!m68k], gcc-3.3 [m68k], binutils-hppa64 [hppa], gcc-4.0-hppa64 [hppa], debhelper (>= 4.1.0), module-init-tools, dpkg-dev (>= 1.10.23), debianutils (>= 1.6), bzip2, sparc-utils [sparc], kernel-package (>= 10.029), ocaml-interp, python2.4-minimal
Build-Depends-Indep: docbook-utils, gs, transfig, xmlto