Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Reworked code, to handle major kernel releases transparently

1) Every supported tree is named as linux[-{fork}]

2) I left only some core trees in the ketchup code, and split the rest
of them in the ketchuprc file.

3) Added the quilt_patchset and local_quilt_patchset list, to support
quilt patchsets in a general way (and not only -mmotm)

4) Reworked the code that finds the latest_kernel releases (for stable,
longterm and rc kernels), in order to handle major kernel releases
trasparently, and to fix some failures, since urls at kernel.org
changed.

5) Dropped support for -ck and -pf patchsets atm, due to some versioning
issues. Hopefully I'll find a workaround, and add them to the ketchuprc
soon.

6) Changed the get_ver() function, and replaced the parsing code with
"make kernelversion" (adding however a dependency on GNU make).

7) Fixed the show-url option, so that it show the correct url for
longterm kernels.

(I know I should have split that in several commits :/)

Signed-off-by: Stratos Psomadakis <psomas@cslab.ece.ntua.gr>
  • Loading branch information...
commit c91634dd8d29d72715917ce1de2ec0b77e3a5a29 1 parent e1c29f7
Stratos Psomadakis authored

Showing 2 changed files with 277 additions and 256 deletions. Show diff stats Hide diff stats

  1. +240 256 ketchup
  2. +37 0 ketchuprc
496 ketchup
... ... @@ -1,6 +1,6 @@
1 1 #!/usr/bin/python
2 2 #
3   -# ketchup 1.1
  3 +# ketchup 1.1-beta
4 4 # http://github.com/psomas/ketchup
5 5 # git://github.com/psomas/ketchup.git
6 6 #
@@ -39,7 +39,7 @@
39 39 # gpg = '/weird/path/to/gpg'
40 40 #
41 41
42   -import re, sys, urllib, os, getopt, glob, shutil, subprocess
  42 +import re, sys, urllib, os, getopt, glob, shutil, subprocess, commands
43 43
44 44 def error(*args):
45 45 sys.stderr.write("ketchup: ")
@@ -112,6 +112,11 @@ gpg = "/usr/bin/gpg"
112 112 precommand = postcommand = None
113 113 default_tree = None
114 114 local_trees = {}
  115 +local_quilt_patchsets = ()
  116 +quilt_patchsets = []
  117 +
  118 +minors= {}
  119 +lmajor = None
115 120
116 121 # Functions to parse version strings
117 122
@@ -153,7 +158,7 @@ def rev(ver):
153 158 if t == 2:
154 159 t = 2.6
155 160 r = last_minor(t)
156   -
  161 +
157 162 return r
158 163
159 164 def pre(ver):
@@ -254,31 +259,24 @@ def fork(ver):
254 259 try: return f.group(4)
255 260 except: return None
256 261
257   -#FIXME: at some point the Makefile for 3.x kernels will change
258 262 def get_ver(makefile):
259 263 """ Read the version information from the specified makefile """
260   - part = {}
261   - parts = "VERSION PATCHLEVEL SUBLEVEL EXTRAVERSION CKVERSION".split(' ')
262   - m = open(makefile)
263   - for l in m.readlines():
264   - for p in parts:
265   - try: part[p] = re.match(r'%s\s*=\s*(\S+)' % p, l).group(1)
266   - except: pass
267   -
268   - # atm we use VERSION.PATCHLEVEL for Linus' releases and EXTRAVERSION for
269   - # the -stable releases
270   - if part['VERSION'] >= '3':
271   - version = "%s.%s" % tuple([part[p] for p in parts[:2]])
272   - else:
273   - version = "%s.%s.%s" % tuple([part[p] for p in parts[:3]])
274   - version += part.get("EXTRAVERSION","")
275   - version += part.get("CKVERSION","")
276   -
277   - # required for -next patchset
278   - try: n = open("localversion-next")
279   - except: return version
  264 + ver = commands.getoutput("make kernelversion")
  265 +
  266 + version = full_tree(ver)
  267 + v = post(ver)
  268 + if v != '0':
  269 + version += '.' + v
  270 + f = fork(ver)
  271 + if f:
  272 + version += f
280 273
281   - version += n.read()[:-1]
  274 + # required for -next patchset
  275 + try:
  276 + n = open("localversion-next")
  277 + version += n.read()[:-1]
  278 + except:
  279 + pass
282 280
283 281 return version
284 282
@@ -304,6 +302,9 @@ def compare_ver(a, b):
304 302
305 303 c = cmp(float(tree(a)), float(tree(b)))
306 304 if c: return c
  305 + ra, rb = tree(revbase(a)), tree(revbase(b))
  306 + c = cmp(ra, rb)
  307 + if c: return c
307 308 ra, rb = rev(a), rev(b)
308 309 c = cmp(ra, rb)
309 310 if c: return c
@@ -321,27 +322,6 @@ def last(url, pat="(.*/)"):
321 322 if m: n = m.group(1)
322 323 return n
323 324
324   -def latest_mmotm(url, pat):
325   - latest = find_ver('mainline-rc')
326   -
327   - return latest + "-mm1"
328   -
329   -def latest_ck(url, pat):
330   - url = "http://www.kernel.org/pub/linux/kernel/people/ck/patches/2.6/"
331   - url += last(url)
332   - part = fork(last(url))
333   - stable = latest_dir(os.path.dirname(version_info['2.6'][1][0]), version_info['2.6'][2])
334   -
335   - return stable + part
336   -
337   -def latest_pf(url, pat):
338   - url = "http://pf.natalenko.name/sources/"
339   - url += last(url)
340   - part = last(url,"(.*patch.*)")
341   - part = re.search('\d+.\d+.\d+-pf\d+', part).group(0)
342   -
343   - return part
344   -
345 325 def latest_dir_lt(url, pat):
346 326 """Find the latest link to the stable release series that is used local"""
347 327 cwd=os.getcwd()
@@ -352,12 +332,22 @@ def latest_dir_lt(url, pat):
352 332 lv = get_ver('Makefile')
353 333 except:
354 334 lv = None
  335 + if not lv and os.listdir("."):
  336 + error("Can't find kernel version for non-empty directory")
  337 + sys.exit(-1)
355 338 if not lv:
356 339 qprint("No local version found. Use newest kernel release instead.")
357 340 return latest_dir(url, pat)
358   - local_revbase = revbase(lv)
  341 + local_revbase = full_tree(lv)
359 342 p = []
360   - url = url % { "kernel_url": kernel_url }
  343 +
  344 + s = {
  345 + 'tree': float(tree(local_revbase)),
  346 + 'kernel_url': kernel_url,
  347 + 'revbase' : revbase(lv)
  348 + }
  349 +
  350 + url = url % s
361 351 for l in urllib.urlopen(url).readlines():
362 352 m = re.search('"%s"' % pat, l)
363 353 if m and revbase(m.group(1))==local_revbase:
@@ -371,7 +361,6 @@ def latest_dir_lt(url, pat):
371 361 def find_www(url, pat, grp):
372 362 """Parse the page the url is pointing to and fetch the matched items"""
373 363 p = []
374   - url = url % { "kernel_url": kernel_url }
375 364
376 365 for l in urllib.urlopen(url).readlines():
377 366 m = re.search('"%s"' % pat, l)
@@ -381,68 +370,91 @@ def find_www(url, pat, grp):
381 370
382 371 def latest_dir(url, pat):
383 372 """Find the latest link matching pat at url after sorting"""
384   - p = find_www(url, pat, 1)
  373 + s = {
  374 + 'tree': latest_major(),
  375 + 'kernel_url': kernel_url,
  376 + 'full_tree': latest_major()
  377 + }
  378 +
  379 + p = find_www(url % s, pat, 1)
385 380 if not p: return None
386 381
387 382 p.sort(compare_ver)
388 383 return p[-1]
389 384
390   -
391 385 def find_majors():
392 386 return find_www(kernel_url, '.*v(\d+\.\d+).*', 1)
393   -
  387 +
394 388 def latest_major():
395   - p = find_majors()
  389 + global lmajor
  390 + if lmajor == None:
  391 + p = find_majors()
396 392
397   - p.sort(compare_ver)
398   - return p[-1]
  393 + p.sort(compare_ver)
  394 + lmajor = p[-1]
  395 +
  396 + return lmajor
399 397
400   -transitions = {}
401 398 def last_minor(t):
402 399 maj = t
403 400 if t >= 3:
404 401 maj += .0
405 402
406   - url = kernel_url + ("/v%s" % maj)
407   - if url in transitions:
408   - return transitions[url]
409   - else:
  403 + if maj not in minors:
  404 + url = kernel_url + ("/v%s" % maj)
  405 +
410 406 p = map(int, find_www(url, ".*linux-%s\.(\d+)\.tar\.bz2" % t, 1))
411 407 p.sort()
412 408
413   - if not p:
414   - transitions[url] = None
415   - return None
416   -
417   - transitions[url] = p[-1]
  409 + if p:
  410 + minors[maj] = int(p[-1])
  411 + else:
  412 + minors[maj] = None
418 413
419   - return p[-1]
  414 + return minors[maj]
420 415
421 416 def find_info(ver):
  417 + b = "linux%s"
  418 +
422 419 t = tree(ver)
423   - if t >= 3:
424   - b = "%d" % t
  420 + if t == 2.4:
  421 + s = b % '-2.4'
425 422 else:
426   - b = "%.1f" % t
427   - f = forkname(ver)
428   - p = pre(ver)
429   -
430   - if (not f) or f == 'git' or f == 'next' or f == 'mm':
431   - b = 'mainline'
  423 + f = forkname(ver)
  424 + p = pre(ver)
  425 +
  426 + if f:
  427 + fd = '-' + f
  428 + s = b % fd
  429 + elif p:
  430 + s = b % '-rc'
  431 + else:
  432 + s = b % ''
432 433
433   - s = b
  434 + if s not in version_info:
  435 + error("Unknown tree/patchset!")
  436 + sys.exit(-1)
434 437
435   - if f:
436   - s = "%s-%s" % (b, f)
437   - elif p:
438   - s = "%s-rc" % b
  438 + v = version_info[s]
439 439
440   - if f == "rt":
441   - s = "rt"
  440 + if f in quilt_patchsets:
  441 + if ver != v[0](os.path.dirname(v[1])):
  442 + error("%s can only be applied to specific kernel versions" % s)
  443 + sys.exit(-1)
  444 +
  445 + return version_info[s]
442 446
  447 +def full_tree(ver):
  448 + if tree(ver) >= 3:
  449 + t = re.match(r'(\d+\.\d+)', ver)
  450 + else:
  451 + t = re.match(r'(\d+\.\d+\.\d+)', ver)
443 452
444   - return version_info[s]
  453 + if t == None:
  454 + error("Invalid tree version!")
  455 + return t.group(0)
445 456
  457 +
446 458 def version_urls(ver):
447 459 """ Return the URL for the patch associated with the specified version """
448 460 i = find_info(ver)[1]
@@ -457,7 +469,7 @@ def version_urls(ver):
457 469 'fork': fork(ver),
458 470 'revbase': revbase(ver),
459 471 'kernel_url': kernel_url,
460   - 'full_tree': (tree(ver) + .0) + last_minor(tree(ver))
  472 + 'full_tree': full_tree(ver),
461 473 }
462 474
463 475 l = []
@@ -570,11 +582,6 @@ def get_patch(ver):
570 582 if os.path.exists(f):
571 583 return f
572 584
573   - if re.search(r'-mm1', ver) != None:
574   - if pre(find_ver('mainline-rc')) != pre(ver):
575   - error("-mm1 patchset can only be applied to the latest -rc release!")
576   - sys.exit(-1)
577   -
578 585 if f[-4:] == ".bz2":
579 586 f2 = f[:-4] + ".gz"
580 587 if os.path.exists(f2):
@@ -593,7 +600,7 @@ def get_patch(ver):
593 600
594 601 return f
595 602
596   -def apply_mmotm(ver, reverse = 0):
  603 +def apply_quilt(ver, reverse = 0):
597 604 if reverse:
598 605 err = os.system("quilt pop -a &> .patchdiag")
599 606 if err:
@@ -631,11 +638,12 @@ def apply_patch(ver, reverse = 0):
631 638 r = " -R"
632 639
633 640 qprint("Applying %s%s" % (os.path.basename(p), r))
  641 + print os.path.basename(p)
634 642 if options["dry-run"] or options["only-dl"]:
635 643 return ver
636 644
637   - if forkname(ver) == "mm":
638   - return apply_mmotm(ver, reverse)
  645 + if forkname(ver) in quilt_patchsets:
  646 + return apply_quilt(ver, reverse)
639 647
640 648 def cmd(patch, reverse, dry):
641 649 base = "patch -l -p1%s" % reverse
@@ -684,19 +692,33 @@ def untar(tarfile):
684 692
685 693 def install_nearest(ver):
686 694 t = tree(ver)
687   - tarballs = glob.glob(archive + "/linux-%s.*.tar.bz2" % t)
  695 + if t == 2.4:
  696 + tarballs = glob.glob(archive + "/linux-%s.*.tar.bz2" % t)
  697 + else:
  698 + tarballs = glob.glob(archive + "/linux-2.6.*.tar.bz2")
  699 + tarballs += glob.glob(archive + "/linux-[3-9].*.tar.bz2")
  700 +
688 701 list = []
689   -
690 702 for f in tarballs:
691 703 m = re.match(r'.*/linux-(.*).tar.bz2$', f)
692 704 v = m.group(1)
693   - d = abs(rev(v) - rev(ver))
  705 + dt = tree(v) - tree(ver)
  706 + # if we're 2 'major' trees apart, just get the full tarball
  707 + if(abs(dt) > 1):
  708 + break
  709 + # carefully calc how many 'steps' we're away from the target version
  710 + else:
  711 + if dt == 0:
  712 + d = abs(rev(v) - rev(ver))
  713 + elif dt == 1:
  714 + d = abs(last_minor(tree(ver)) - rev(ver) + rev(v) + 1)
  715 + else:
  716 + d = abs(last_minor(tree(v)) - rev(v) + rev(ver) + 1)
  717 +
694 718 list.append((d, f, v))
  719 +
695 720 list.sort()
696 721
697   - # ugly hack, upstream dir is /v3.0 (not v3)
698   - # FIXME: we assume that this will be the case for linux-4.0 and later releases
699   - # if not, we'll have to fix it again :)
700 722 if t >= 3:
701 723 t += .0
702 724
@@ -725,32 +747,15 @@ def install_nearest(ver):
725 747 return ver
726 748
727 749 def find_ver(ver):
728   - m = re.match(r'mainline.*', ver)
729   - if m:
730   - t = latest_major()
731   - else:
732   - m = re.match(r'(\d+)(-rc|-git)?$', ver)
733   - if m:
734   - t = tree(m.group(1) + '.0')
735   - ver = 'mainline'
736   - if m.group(2):
737   - ver += m.group(2)
738   -
739 750 if ver in version_info.keys():
740 751 v = version_info[ver]
741 752
742 753 d = v[1]
743 754 if type(d) is type([]):
744 755 d = d[0]
745   -
746   - for n in range(5):
747   - if m:
748   - t = float(t)
749   - return v[0](os.path.dirname(d) % {'kernel_url': kernel_url, 'tree': t, 'full_tree' :
750   - latest_major()}, v[2])
751   - else:
752   - return v[0](os.path.dirname(d), v[2])
753 756
  757 + for n in range(5):
  758 + return v[0](os.path.dirname(d), v[2])
754 759 error('retrying version lookup for %s' % ver)
755 760 else:
756 761 return ver
@@ -781,7 +786,7 @@ def transform(a, b):
781 786 ta, tb = tree(a), tree(b)
782 787 if tree(revbase(b)) != tb:
783 788 tb = tree(revbase(b))
784   -
  789 +
785 790 if ta == tb and ra > rb:
786 791 for r in range(ra, rb, -1):
787 792 apply_patch("%s.%s" % (ta, r), -1)
@@ -837,70 +842,46 @@ def rename_dir(v):
837 842 os.rename(cwd, newdir)
838 843 qprint('Current directory renamed to %s' % newdir)
839 844
840   -
841 845 # latest lookup function, canonical urls, pattern for lookup function,
842 846 # signature flag, description
843 847 version_info = {
844   - '2.4': (latest_dir,
845   - "%(kernel_url)s" + "/v2.4" + "/patch-%(base)s.bz2",
846   - r'patch-(.*?).bz2',
847   - 1, "2.4 kernel series"),
848   - '2.6': (latest_dir,
849   - ["%(kernel_url)s" + "/v2.6" + "/patch-%(prebase)s.bz2",
850   - "%(kernel_url)s" + "/v2.6/longterm/v%(revbase)s/patch-%(prebase)s.bz2"],
851   - r'patch-(.*?).bz2',
852   - 1, "2.6 kernel series"),
853   - '2.6-lt': (latest_dir_lt,
854   - ["%(kernel_url)s" + "/v2.6" + "/patch-%(prebase)s.bz2",
855   - "%(kernel_url)s" + "/v2.6/longterm/v%(revbase)s/patch-%(prebase)s.bz2"],
856   - r'patch-(.*?).bz2',
857   - 1, "2.6 kernel series - update (only) to newer longterm stable releases (fourth number of 2.6 kernels)"),
858   - '2.6-rt': (latest_dir,
859   - ["%(kernel_url)s" + "/projects/rt/patch-%(full)s.bz2",
860   - "%(kernel_url)s" + "/projects/rt/older/patch-%(full)s.bz2"],
861   - r'patch-(2.6.*?).bz2',
862   - 0, "Ingo Molnar's realtime-preempt kernel"),
863   - '2.6-pf': (latest_pf,
864   - "http://pf.natalenko.name/sources" + "/%(revbase)s"
865   - + "/patch-%(full)s.bz2",
866   - r'patch-(.*?).bz2',
867   - 0, "-pf kernel patchset"),
868   - '2.6-ck': (latest_ck,
869   - "%(kernel_url)s" + "/people/ck/patches/2.6" +
870   - "/%(revbase)s/%(revbase)s%(fork)s/patch-%(revbase)s%(fork)s.bz2",
871   - "", 0,
872   - "Con Kolivas' -ck patchset"),
873   - # current -next releases, for 3.x kernels
874   - # FIXME: URL probably going to change (/v2.6/next -> /v3.0/next)
875   - 'mainline-next': (latest_dir,
  848 + 'linux-2.4': (latest_dir,
  849 + "%(kernel_url)s" + "/v2.4" + "/patch-%(base)s.bz2",
  850 + r'patch-(.*?).bz2',
  851 + 1, "2.4 kernel series"),
  852 + 'linux-next': (latest_dir,
876 853 "%(kernel_url)s" + "/v2.6/next" + "/patch-v%(prebase)s%(fork)s.bz2",
877 854 r'patch-v(.*?).bz2',
878   - 1, " linux-next tree"),
879   - 'mainline-mm': (latest_mmotm,
880   - "http://userweb.kernel.org/~akpm/mmotm/broken-out.tar.gz",
881   - r'broken-out.tar.gz',
882   - 0, "-mmotm quilt patchset"),
883   - 'rt': (latest_dir,
884   - ["%(kernel_url)s" + "/projects/rt/patch-%(full)s.bz2",
885   - "%(kernel_url)s" + "/projects/rt/older/patch-%(full)s.bz2"],
886   - r'patch-(.*?).bz2',
887   - 0, "PREEMPT_RT real-time kernel"),
888   - 'mainline-rc': (latest_dir,
889   - "%(kernel_url)s" + "/v%(tree)s" + "/testing/v%(full_tree)s/patch-%(prebase)s.bz2",
890   - r'patch-(.*?).bz2',
891   - 1, "current stable kernel series prereleases"),
892   - 'mainline-git': (latest_dir,
893   - "%(kernel_url)s" + "/v%(tree)s" + "/snapshots/patch-%(full)s.bz2",
894   - r'patch-(.*?).bz2',
895   - 0, "current stable kernel series snapshots"),
896   - 'mainline': (latest_dir,
897   - ["%(kernel_url)s" + "/v%(tree)s" + "/patch-%(prebase)s.bz2",
898   - "%(kernel_url)s" + "/v%(tree)s/longterm/v%(revbase)s/patch-%(prebase)s.bz2"],
899   - r'patch-(.*?).bz2',
900   - 1, "current stable kernel series"),
  855 + 1, "linux-next tree"),
  856 + 'linux-rc': (latest_dir,
  857 + ["%(kernel_url)s" + "/v%(tree)s" + "/testing/patch-%(prebase)s.bz2",
  858 + "%(kernel_url)s" + "/v%(tree)s" + "/testing/v%(full_tree)s/patch-%(prebase)s.bz2"],
  859 + r'patch-(.*?).bz2',
  860 + 1, "current stable kernel series prereleases"),
  861 + 'linux-git': (latest_dir,
  862 + "%(kernel_url)s" + "/v%(tree)s" + "/snapshots/patch-%(full)s.bz2",
  863 + r'patch-(.*?).bz2',
  864 + 1, "current stable kernel series snapshots"),
  865 + 'linux-lt': (latest_dir_lt,
  866 + ["%(kernel_url)s" + "/v%(tree)s/longterm/v%(revbase)s/patch-%(prebase)s.bz2",
  867 + "%(kernel_url)s" + "/v%(tree)s" + "/patch-%(prebase)s.bz2"],
  868 + r'patch-(.*?).bz2',
  869 + 1, "longterm kernel series - update (only) to newer longterm stable releases"),
  870 + 'linux': (latest_dir,
  871 + ["%(kernel_url)s" + "/v%(tree)s" + "/patch-%(prebase)s.bz2",
  872 + "%(kernel_url)s" + "/v%(tree)s/longterm/v%(revbase)s/patch-%(prebase)s.bz2"],
  873 + r'patch-(.*?).bz2',
  874 + 1, "current stable kernel series"),
901 875 }
902 876
903   -# Override defaults with ~/.ketchuprc which is just a Python script
  877 +# Override defaults with /etc/ketchuprc and ~/.ketchuprc which are just Python scripts
  878 +rcpath = '/etc/ketchuprc'
  879 +if os.path.isfile(rcpath):
  880 + try:
  881 + execfile(rcpath)
  882 + except Exception, e:
  883 + sys.exit('Failed parsing %s\nError was: %s' % (rcpath, e))
  884 +
904 885 rcpath = os.path.expanduser('~/.ketchuprc')
905 886 if os.path.isfile(rcpath):
906 887 try:
@@ -912,6 +893,10 @@ if os.path.isfile(rcpath):
912 893 for k,v in local_trees.items():
913 894 version_info[k] = v
914 895
  896 +# Add local quilt patchsets
  897 +for p in local_quilt_patchsets:
  898 + quilt_patchsets += p
  899 +
915 900 # Environment variables override defaults and ketchuprc
916 901 kernel_url = os.environ.get("KETCHUP_URL", kernel_url)
917 902 archive = os.environ.get("KETCHUP_ARCH", archive)
@@ -941,91 +926,90 @@ opts = [
941 926 ('w', 'wget', wget, 'command to use for wget'),
942 927 ]
943 928
944   -args = fancyopts(sys.argv[1:], opts, options,
945   - 'ketchup [options] [ver]')
  929 +# Process args
  930 +def process_args(args):
  931 + archive = options["archive"]
  932 + kernel_url = options["kernel-url"]
  933 + if options["no-gpg"]: options["gpg-path"] = ''
  934 +
  935 + if not os.path.exists(options["directory"]):
  936 + qprint("Creating target directory", options["directory"])
  937 + os.mkdir(options["directory"])
  938 + os.chdir(options["directory"])
  939 +
  940 + if options["list-trees"]:
  941 + l = version_info.keys()
  942 + l.sort()
  943 + for tree in l:
  944 + if version_info[tree][3] == 0:
  945 + lprint(tree, "(unsigned)")
  946 + else:
  947 + lprint(tree, "(signed)")
  948 + lprint(" " + version_info[tree][4])
  949 + sys.exit(0)
  950 +
  951 + if options["show-makefile"] and len(args) < 2:
  952 + if not args:
  953 + lprint(get_ver("Makefile"))
  954 + else:
  955 + lprint(get_ver(args[0]))
  956 + sys.exit(0)
946 957
947   -archive = options["archive"]
948   -kernel_url = options["kernel-url"]
949   -if options["no-gpg"]: options["gpg-path"] = ''
  958 + if len(args) == 0 and default_tree:
  959 + qprint("Using default tree \"%s\"" % (default_tree))
  960 + args.append(default_tree)
950 961
951   -# Process args
  962 + if len(args) != 1:
  963 + error("No version given on command line and no default in configuration")
  964 + sys.exit(-1)
  965 +
  966 + if options["show-latest"]:
  967 + lprint(find_ver(args[0]))
  968 + sys.exit(0)
952 969
953   -if not os.path.exists(options["directory"]):
954   - qprint("Creating target directory", options["directory"])
955   - os.mkdir(options["directory"])
956   -os.chdir(options["directory"])
  970 + if options["show-url"]:
  971 + for v in version_urls(find_ver(args[0])):
  972 + if urllib.urlopen(v).getcode() != 404:
  973 + break
  974 + lprint(v)
  975 + sys.exit(0)
  976 +
  977 + if options["show-previous"]:
  978 + v = find_ver(args[0])
  979 + p = prebase(v)
  980 + if p == v: p = base(v)
  981 + if p == v:
  982 + if rev(v) > 0: p = "%.1f.%s" % (tree(v), rev(v) -1)
  983 + else: p = "unknown"
  984 + lprint(p)
  985 + sys.exit(0)
  986 +
  987 + if not os.path.exists(options["archive"]):
  988 + qprint("Creating cache directory", options["archive"])
  989 + os.mkdir(options["archive"])
  990 +
  991 + if precommand and os.system(precommand):
  992 + sys.exit('Precommand "%s" failed!' % precommand)
957 993
958   -if os.path.isfile(".ketchuprc"):
959 994 try:
960   - execfile(".ketchuprc")
961   - except Exception, e:
962   - sys.exit('Failed parsing .ketchuprc\nError was: %s' % (e))
963   -
964   -if options["list-trees"]:
965   - l = version_info.keys()
966   - l.sort()
967   - for tree in l:
968   - if version_info[tree][3] == 0:
969   - lprint(tree, "(unsigned)")
970   - else:
971   - lprint(tree, "(signed)")
972   - lprint(" " + version_info[tree][4])
973   - sys.exit(0)
  995 + a = get_ver('Makefile')
  996 + except:
  997 + a = None
974 998
975   -if options["show-makefile"] and len(args) < 2:
976   - if not args:
977   - lprint(get_ver("Makefile"))
978   - else:
979   - lprint(get_ver(args[0]))
980   - sys.exit(0)
981   -
982   -if len(args) == 0 and default_tree:
983   - qprint("Using default tree \"%s\"" % (default_tree))
984   - args.append(default_tree)
985   -
986   -if len(args) != 1:
987   - error("No version given on command line and no default in configuration")
988   - sys.exit(-1)
989   -
990   -if options["show-latest"]:
991   - lprint(find_ver(args[0]))
992   - sys.exit(0)
993   -
994   -if options["show-url"]:
995   - lprint(version_urls(find_ver(args[0]))[0])
996   - sys.exit(0)
997   -
998   -if options["show-previous"]:
999   - v = find_ver(args[0])
1000   - p = prebase(v)
1001   - if p == v: p = base(v)
1002   - if p == v:
1003   - if rev(v) > 0: p = "%.1f.%s" % (tree(v), rev(v) -1)
1004   - else: p = "unknown"
1005   - lprint(p)
1006   - sys.exit(0)
1007   -
1008   -if not os.path.exists(options["archive"]):
1009   - qprint("Creating cache directory", options["archive"])
1010   - os.mkdir(options["archive"])
1011   -
1012   -if precommand and os.system(precommand):
1013   - sys.exit('Precommand "%s" failed!' % precommand)
1014   -
1015   -try:
1016   - a = get_ver('Makefile')
1017   -except:
1018   - a = None
1019   -
1020   -if not a and os.listdir("."):
1021   - error("Can't find kernel version for non-empty directory")
1022   - sys.exit(-1)
1023   -
1024   -b = find_ver(args[0])
1025   -qprint("%s -> %s" % (a, b))
1026   -transform(a, b)
1027   -if options["rename-directory"] and not options["dry-run"] and not options["only-dl"] :
1028   - rename_dir(b)
1029   -
1030   -if postcommand and os.system(postcommand):
1031   - sys.exit('Postcommand "%s" failed!' % postcommand)
  999 + if not a and os.listdir("."):
  1000 + error("Can't find kernel version for non-empty directory")
  1001 + sys.exit(-1)
  1002 +
  1003 + b = find_ver(args[0])
  1004 + qprint("%s -> %s" % (a, b))
  1005 + transform(a, b)
  1006 + if options["rename-directory"] and not options["dry-run"] and not options["only-dl"] :
  1007 + rename_dir(b)
  1008 +
  1009 + if postcommand and os.system(postcommand):
  1010 + sys.exit('Postcommand "%s" failed!' % postcommand)
  1011 +
  1012 +if __name__ == "__main__":
  1013 + args = fancyopts(sys.argv[1:], opts, options,
  1014 + 'ketchup [options] [ver]')
  1015 + process_args(args)
37 ketchuprc
... ... @@ -0,0 +1,37 @@
  1 +# Default onfiguration file for ketchup
  2 +#
  3 +# Stratos Psomadakis <psomas@cslab.ece.ntua.gr>
  4 +# Thu Aug 25 21:18:43 EEST 2011
  5 +
  6 +def latest_mm(url, pat=""):
  7 + url += '/broken-out/mm.patch'
  8 +
  9 + part = {}
  10 + parts = "VERSION PATCHLEVEL SUBLEVEL EXTRAVERSION CKVERSION".split(' ')
  11 +
  12 + for l in urllib.urlopen(url).readlines():
  13 + for p in parts:
  14 + try: part[p] = re.match(r'\s*[-]?%s\s*=\s*(\S+)' % p, l).group(1)
  15 + except: pass
  16 +
  17 + if part['VERSION'] >= '3' and part['SUBLEVEL'] == '0':
  18 + version = "%s.%s" % tuple([part[p] for p in parts[:2]])
  19 + else:
  20 + version = "%s.%s.%s" % tuple([part[p] for p in parts[:3]])
  21 + version += part.get("EXTRAVERSION","")
  22 +
  23 + return version + '-mm1'
  24 +
  25 +local_trees = {
  26 + 'linux-mm': (latest_mm,
  27 + "http://userweb.kernel.org/~akpm/mmotm/broken-out.tar.gz",
  28 + r'broken-out.tar.gz',
  29 + 0, "-mmotm quilt patchset"),
  30 + 'linux-rt': (latest_dir,
  31 + ["%(kernel_url)s" + "/projects/rt/patch-%(full)s.bz2",
  32 + "%(kernel_url)s" + "/projects/rt/older/patch-%(full)s.bz2"],
  33 + r'patch-(.*?).bz2',
  34 + 1, "PREEMPT_RT real-time kernel"),
  35 + }
  36 +
  37 +local_quilt_patchsets = ( "mm" )

0 comments on commit c91634d

Please sign in to comment.
Something went wrong with that request. Please try again.