X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=automation%2Fkernel-seed.py;h=aefa50b66a5a0297540a31fd0a87dd71733955a3;hb=7033367ae2fd2ea02f3920cef09f794b4986ff2b;hp=632b01509264c1d95673ac26373f79625cb40a33;hpb=95066f76ff883cabf703b8bc5a52066dcac387a4;p=lttng-ci.git diff --git a/automation/kernel-seed.py b/automation/kernel-seed.py index 632b015..aefa50b 100644 --- a/automation/kernel-seed.py +++ b/automation/kernel-seed.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- # # Copyright (C) 2015 - Michael Jeanson +# Jonathan Rajotte # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,13 +17,15 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -""" This script is used to """ +""" This script is used to generate a yaml list of kernel version tag """ import os import re +import yaml +import argparse + from distutils.version import Version from git import Repo -import yaml class KernelVersion(Version): @@ -115,27 +118,32 @@ class KernelVersion(Version): else: assert False, "never get here" - - - -KERNCUTOFF = KernelVersion("2.6.36") - -LINUX_GIT = "git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git" -LINUX_PATH = "/home/mjeanson/tmp/toto/" - - - - def main(): """ Main """ versions = [] + kernel_cutoff = KernelVersion("2.6.36") + kernel_git = "git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git" + kernel_path = os.getcwd() + "/kernel" + + parser = argparse.ArgumentParser() + parser.add_argument("--kernel-path", help="The location of the kernel. Default to the currentdir/linux") + parser.add_argument("--kernel-git-remote", help="The git url of the kernel. Default to git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git") + parser.add_argument("--kernel-cutoff", help="The lower bersion cutoff in X.X.X format. Default to 2.6.36") + args = parser.parse_args() + + if args.kernel_path: + kernel_path = args.kernel_path + if args.kernel_git_remote: + kernel_git = args.kernel_git_remote + if args.kernel_cutoff: + kernel_cutoff = KernelVersion(args.kernel_cutoff) # Open or create the local repository - if os.path.isdir(LINUX_PATH): - linux_repo = Repo(LINUX_PATH) + if os.path.isdir(kernel_path): + linux_repo = Repo(kernel_path) else: - linux_repo = Repo.clone_from(LINUX_GIT, LINUX_PATH) + linux_repo = Repo.clone_from(kernel_git, kernel_path) # Pull the latest linux_repo.remote().pull() @@ -146,7 +154,7 @@ def main(): version = KernelVersion(tag.name.lstrip('v')) # Add only those who are superior to the cutoff version - if version >= KERNCUTOFF: + if version >= kernel_cutoff: versions.append(version) except ValueError: #print(tag.name)