BUILD_DIR = os.path.join(WORKING_DIR, BUILD_DIR) SOURCE_DIR = os.path.join(WORKING_DIR, "redhat-kernel-source/linux-2.6.32") rh_changelog = os.path.join(WORKING_DIR, "redhat-kernel-changelog") if not os.path.exists(rh_changelog): print >>sys.stderr, "redhat-kernel-source\redhat-kernel-changelog is missing.\n" sys.exit(1) try: shutil.rmtree(BUILD_DIR) except: pass os.mkdir(BUILD_DIR) tarball_name = "linux-" + config.get_srcversion() + ".tar.bz2" tmp_name = "linux-" + config.get_srcversion() print >>sys.stdout, "%s\n" % (tarball_name,) os.rename(SOURCE_DIR, tmp_name) subprocess.call(["tar", "cjf", tarball_name, tmp_name]) os.rename(tarball_name, os.path.join(BUILD_DIR, tarball_name)) os.rename(tmp_name, SOURCE_DIR) if not os.path.exists("series.conf"): print >>sys.stderr, "Configuration file series.conf not found.\n" sys.exit(1) for x in misc_files_to_copy: shutil.copy(x, BUILD_DIR)
if __name__ == "__main__": patches, release_string, config_files, changelog, released, buildid = parse_opts() script_dir = get_script_loc() os.chdir(script_dir) os.chdir("..") WORKING_DIR = os.getcwd() rpm_dir = os.path.join(WORKING_DIR, "rpm") build_dir = os.path.join(WORKING_DIR, config.BUILD_DIR) config_dir = os.path.join(WORKING_DIR, "config") spec_temple = "".join(open(os.path.join(rpm_dir, "kernel.spec.in")).readlines()) # Generate version number from tags and base kernel version number. # tb_base_var is something like 2.6.32 tb_base_ver = config.get_srcversion().split("-")[0] rh_release_id = config.get_srcversion().split("-")[1][:-4] tb_sublevel = tb_base_ver.split(".")[2] try: tb_short_commit = commands.getoutput("git log --pretty=format:%%h -1") tb_long_commit = commands.getoutput("git log --pretty=format:%H -1") except: tr_short_commit = tb_long_commit = "UnknownCommitId" # the lst string is distribution id, for, # branch master, it's ".master" # branch 5u4, it's ".el5" # branch 6u, it's ".el6" pkg_release = rh_release_id + "." + "tb" + buildid + ".master"
patches, release_string, config_files, changelog, released, buildid = parse_opts( ) script_dir = get_script_loc() os.chdir(script_dir) os.chdir("..") WORKING_DIR = os.getcwd() rpm_dir = os.path.join(WORKING_DIR, "rpm") build_dir = os.path.join(WORKING_DIR, config.BUILD_DIR) config_dir = os.path.join(WORKING_DIR, "config") spec_temple = "".join( open(os.path.join(rpm_dir, "kernel.spec.in")).readlines()) # Generate version number from tags and base kernel version number. # tb_base_var is something like 2.6.32 tb_base_ver = config.get_srcversion().split("-")[0] rh_release_id = config.get_srcversion().split("-")[1][:-4] tb_sublevel = tb_base_ver.split(".")[2] try: tb_short_commit = commands.getoutput("git log --pretty=format:%%h -1") tb_long_commit = commands.getoutput("git log --pretty=format:%H -1") except: tr_short_commit = tb_long_commit = "UnknownCommitId" # the lst string is distribution id, for, # branch master, it's ".master" # branch 5u4, it's ".el5" # branch 6u, it's ".el6" pkg_release = rh_release_id + "." + "tb" + buildid + ".master"
BUILD_DIR = os.path.join(WORKING_DIR, BUILD_DIR) SOURCE_DIR = os.path.join(WORKING_DIR, "redhat-kernel-source/linux-2.6.32") rh_changelog = os.path.join(WORKING_DIR, "redhat-kernel-changelog") if not os.path.exists(rh_changelog): print >> sys.stderr, "redhat-kernel-source\redhat-kernel-changelog is missing.\n" sys.exit(1) try: shutil.rmtree(BUILD_DIR) except: pass os.mkdir(BUILD_DIR) tarball_name = "linux-" + config.get_srcversion() + ".tar.bz2" tmp_name = "linux-" + config.get_srcversion() print >> sys.stdout, "%s\n" % (tarball_name, ) os.rename(SOURCE_DIR, tmp_name) subprocess.call(["tar", "cjf", tarball_name, tmp_name]) os.rename(tarball_name, os.path.join(BUILD_DIR, tarball_name)) os.rename(tmp_name, SOURCE_DIR) if not os.path.exists("series.conf"): print >> sys.stderr, "Configuration file series.conf not found.\n" sys.exit(1) for x in misc_files_to_copy: shutil.copy(x, BUILD_DIR)
print >> sys.stderr, "SCRATCH_AREA can not be null, roll back to \ default value (tmp)\n" SCRATCH_AREA = "tmp" if not os.path.isdir(SCRATCH_AREA): if os.path.exists(SCRATCH_AREA): print >> sys.stderr, "The SCRATCH_AREA folder: %s already exists.\n" "Please specify an alternative name.\n" % (SCRATCH_AREA, ) sys.exit(1) os.mkdir(SCRATCH_AREA) SCRATCH_AREA = os.path.join(os.getcwd(), SCRATCH_AREA) # ORIG_DIR is the folder where the unziped kernel source code lives, which # means vanilla kernel. ORIG_DIR = os.path.join(SCRATCH_AREA, "linux-%s.orig" % (config.get_srcversion(), )) PATCH_DIR = os.path.join(SCRATCH_AREA, "linux-%s" % (config.get_srcversion(), )) SCRIPTS_DIR = os.path.join(os.getcwd(), "scripts") if not os.path.exists(SCRIPTS_DIR): print >> sys.stderr, "Cannot find scripts folder.\n" sys.exit(1) if not os.path.exists("series.conf"): print >> sys.stderr, "Configuration file series.conf not found.\n" sys.exit(1) # Delete existed PATCH_DIR if it exists if os.path.exists(PATCH_DIR): rm_in_background(PATCH_DIR)
if SCRATCH_AREA == "": print >>sys.stderr, "SCRATCH_AREA can not be null, roll back to \ default value (tmp)\n" SCRATCH_AREA = "tmp" if not os.path.isdir(SCRATCH_AREA): if os.path.exists(SCRATCH_AREA): print >>sys.stderr, "The SCRATCH_AREA folder: %s already exists.\n" "Please specify an alternative name.\n" % (SCRATCH_AREA,) sys.exit(1) os.mkdir(SCRATCH_AREA) SCRATCH_AREA = os.path.join(os.getcwd(), SCRATCH_AREA) # ORIG_DIR is the folder where the unziped kernel source code lives, which # means vanilla kernel. ORIG_DIR = os.path.join(SCRATCH_AREA, "linux-%s.orig" % (config.get_srcversion(),)) PATCH_DIR = os.path.join(SCRATCH_AREA, "linux-%s" % (config.get_srcversion(),)) SCRIPTS_DIR = os.path.join(os.getcwd(), "scripts") if not os.path.exists(SCRIPTS_DIR): print >>sys.stderr, "Cannot find scripts folder.\n" sys.exit(1) if not os.path.exists("series.conf"): print >>sys.stderr, "Configuration file series.conf not found.\n" sys.exit(1) # Delete existed PATCH_DIR if it exists if os.path.exists(PATCH_DIR): rm_in_background(PATCH_DIR)