[kernel] r9056 - people/waldi/scripts/snapshot
Bastian Blank
waldi at alioth.debian.org
Wed Jul 4 09:53:11 UTC 2007
Author: waldi
Date: Wed Jul 4 09:53:11 2007
New Revision: 9056
Log:
scripts/snapshot/package.py: Uses objects.
Modified:
people/waldi/scripts/snapshot/config
people/waldi/scripts/snapshot/package.py
Modified: people/waldi/scripts/snapshot/config
==============================================================================
--- people/waldi/scripts/snapshot/config (original)
+++ people/waldi/scripts/snapshot/config Wed Jul 4 09:53:11 2007
@@ -5,7 +5,7 @@
repository: svn://svn.debian.org/kernel/
orig: ~/debian/kernel/orig
sign: DAEE1CDC
-upload: debian-kernel
+upload: upload
[dists/sid/linux-2.6]
dist: kernel-dists-sid
Modified: people/waldi/scripts/snapshot/package.py
==============================================================================
--- people/waldi/scripts/snapshot/package.py (original)
+++ people/waldi/scripts/snapshot/package.py Wed Jul 4 09:53:11 2007
@@ -138,69 +138,70 @@
def exec_svn(self, args):
self._exec("/usr/bin/svn", args)
-def package(path, entry):
- base = entry['base']
- native = entry.get('native', False)
-
- checkout_dir = os.path.join(base, "checkout-" + path.replace('/', '_'))
- gen_dir = os.path.join(base, 'gen')
- out_dir = os.path.join(base, 'out')
- last_file = os.path.join(base, "last-" + path.replace('/', '_'))
-
- checkout_storage = repository_svn(checkout_dir, "%s/%s" % (entry['repository'], path))
- changelog_entry = debian_linux.debian.Changelog(checkout_dir)[0]
- package_name = changelog_entry.source
- package_version = changelog_entry.version.upstream
- package = "%s-%s" % (package_name, package_version)
- package_dir = os.path.join(gen_dir, package)
- package_orig = "%s_%s.orig.tar.gz" % (package_name, package_version)
- package_orig_source = "%s/%s" % (entry['orig'], package_orig)
-
- for line in os.popen("svn info %s" % checkout_dir, 'r').read().split('\n'):
- if line.startswith('Last Changed Rev: '):
- revision = int(line.split()[-1])
-
- last_revision = 0
- last_upstream = None
- print last_file
- if os.path.exists(last_file):
- i = file(last_file).read().strip()
- last_revision, last_upstream = i.split()
- last_revision = int(last_revision)
-
- if revision <= last_revision:
- return
-
- if not os.path.exists(out_dir):
- os.makedirs(out_dir , 0755)
-
- version = changelog_entry.version
- if changelog_entry.distribution in ('stable', 'testing', 'unstable', 'experimental'):
- version_debian_delemiter = ''
- elif changelog_entry.distribution in ('UNRELEASED',):
- version_debian_delemiter = '~'
- else:
- raise "Unknown distribution"
+class Package(object):
+ def __init__(self, path, entry):
+ base = entry['base']
+ native = entry.get('native', False)
+
+ checkout_dir = os.path.join(base, "checkout-" + path.replace('/', '_'))
+ gen_dir = os.path.join(base, 'gen')
+ out_dir = os.path.join(base, 'out')
+ last_file = os.path.join(base, "last-" + path.replace('/', '_'))
+
+ checkout_storage = repository_svn(checkout_dir, "%s/%s" % (entry['repository'], path))
+ changelog_entry = debian_linux.debian.Changelog(checkout_dir)[0]
+ package_name = changelog_entry.source
+ package_version = changelog_entry.version.upstream
+ package = "%s-%s" % (package_name, package_version)
+ package_dir = os.path.join(gen_dir, package)
+ package_orig = "%s_%s.orig.tar.gz" % (package_name, package_version)
+ package_orig_source = "%s/%s" % (entry['orig'], package_orig)
+
+ for line in os.popen("svn info %s" % checkout_dir, 'r').read().split('\n'):
+ if line.startswith('Last Changed Rev: '):
+ revision = int(line.split()[-1])
+
+ last_revision = 0
+ last_upstream = None
+ print last_file
+ if os.path.exists(last_file):
+ i = file(last_file).read().strip()
+ last_revision, last_upstream = i.split()
+ last_revision = int(last_revision)
+
+ if revision <= last_revision:
+ return
+
+ if not os.path.exists(out_dir):
+ os.makedirs(out_dir , 0755)
+
+ version = changelog_entry.version
+ if changelog_entry.distribution in ('stable', 'testing', 'unstable', 'experimental'):
+ version_debian_delemiter = ''
+ elif changelog_entry.distribution in ('UNRELEASED',):
+ version_debian_delemiter = '~'
+ else:
+ raise "Unknown distribution"
- version.debian += "%ssnapshot.%d" % (version_debian_delemiter, revision)
+ version.debian += "%ssnapshot.%d" % (version_debian_delemiter, revision)
- package_storage = checkout_storage.copy(package_dir, storage)
+ package_storage = checkout_storage.copy(package_dir, storage)
- if not native:
- try:
- os.unlink(os.path.join(gen_dir, package_orig))
- except OSError: pass
- try:
- os.unlink(os.path.join(out_dir, package_orig))
- except OSError: pass
- os.symlink(package_orig_source, os.path.join(gen_dir, package_orig))
- os.symlink(package_orig_source, os.path.join(out_dir, package_orig))
-
- changelog = "%s/debian/changelog" % package_dir
- changelog_text = file(changelog).read()
- os.unlink(changelog)
- f = file(changelog, "w")
- f.write("""\
+ if not native:
+ try:
+ os.unlink(os.path.join(gen_dir, package_orig))
+ except OSError: pass
+ try:
+ os.unlink(os.path.join(out_dir, package_orig))
+ except OSError: pass
+ os.symlink(package_orig_source, os.path.join(gen_dir, package_orig))
+ os.symlink(package_orig_source, os.path.join(out_dir, package_orig))
+
+ changelog = "%s/debian/changelog" % package_dir
+ changelog_text = file(changelog).read()
+ os.unlink(changelog)
+ f = file(changelog, "w")
+ f.write("""\
%s (%s) %s; urgency=low
* %s
@@ -213,45 +214,45 @@
time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime()),
)
)
- f.write(changelog_text)
- del f
+ f.write(changelog_text)
+ del f
- spawnv_chdir(os.P_WAIT, "debian/rules", ['debian/rules', 'debian/control'], package_dir)
- if not native:
- if spawnv_chdir(os.P_WAIT, "debian/rules", ['debian/rules', 'orig'], package_dir):
- raise RuntimeError
-
- list = ['dpkg-buildpackage', '-S']
- sign = entry.get('sign', None)
- if sign:
- list.append('-k%s' % sign)
- if not native:
- if version.upstream != last_upstream:
- list.append('-sa')
+ spawnv_chdir(os.P_WAIT, "debian/rules", ['debian/rules', 'debian/control'], package_dir)
+ if not native:
+ if spawnv_chdir(os.P_WAIT, "debian/rules", ['debian/rules', 'orig'], package_dir):
+ raise RuntimeError
+
+ list = ['dpkg-buildpackage', '-S']
+ sign = entry.get('sign', None)
+ if sign:
+ list.append('-k%s' % sign)
+ if not native:
+ if version.upstream != last_upstream:
+ list.append('-sa')
+ else:
+ list.append('-sd')
+ spawnv_chdir(os.P_WAIT, "dpkg-buildpackage", list, package_dir)
+
+ suffixes = ['.dsc', '_source.changes']
+ if native:
+ suffixes.append('.tar.gz')
else:
- list.append('-sd')
- spawnv_chdir(os.P_WAIT, "dpkg-buildpackage", list, package_dir)
+ suffixes.append('.diff.gz')
- suffixes = ['.dsc', '_source.changes']
- if native:
- suffixes.append('.tar.gz')
- else:
- suffixes.append('.diff.gz')
+ for suffix in suffixes:
+ prefix = '%s_%s' % (package_name, version)
+ gen = os.path.join(gen_dir, "%s%s" % (prefix, suffix))
+ out = os.path.join(out_dir, "%s%s" % (prefix, suffix))
+ os.link(gen, out)
+ os.unlink(gen)
- for suffix in suffixes:
- prefix = '%s_%s' % (package_name, version)
- gen = os.path.join(gen_dir, "%s%s" % (prefix, suffix))
- out = os.path.join(out_dir, "%s%s" % (prefix, suffix))
- os.link(gen, out)
- os.unlink(gen)
+ file(last_file, 'w').write("%d %s\n" % (revision, version.upstream))
- file(last_file, 'w').write("%d %s\n" % (revision, version.upstream))
+ package_storage.remove()
- package_storage.remove()
+ spawnv_chdir(os.P_WAIT, 'dput', ['dput', entry['upload'], '%s_%s_source.changes' % (package_name, version)], out_dir)
- spawnv_chdir(os.P_WAIT, 'dput', ['dput', entry['upload'], '%s_%s_source.changes' % (package_name, version)], out_dir)
-
-def main():
+if __name__ == '__main__':
config = Config(sys.argv[1])
if len(sys.argv) > 2:
paths = sys.argv[2:]
@@ -260,10 +261,7 @@
for path in paths:
try:
c = config[path]
- package(path, c)
+ Package(path, c)
except Exception, e:
import traceback
traceback.print_exc()
-
-if __name__ == '__main__':
- main()
More information about the Kernel-svn-changes
mailing list