2011-08-25 07:52:25 +02:00
|
|
|
#!/usr/bin/python2
|
|
|
|
import sys
|
|
|
|
import subprocess
|
|
|
|
import os
|
|
|
|
import tempfile
|
|
|
|
|
|
|
|
args = sys.argv[1:]
|
2011-11-12 10:32:11 +01:00
|
|
|
do_spm_repo = "--no-spm-repo" not in args
|
|
|
|
if not do_spm_repo:
|
|
|
|
args.remove("--no-spm-repo")
|
2011-11-29 20:58:23 +01:00
|
|
|
keyslot = "--keyslot" in args
|
|
|
|
if keyslot:
|
|
|
|
args.remove("--keyslot")
|
2011-08-25 07:52:25 +02:00
|
|
|
|
|
|
|
if len(args) < 3:
|
2011-11-29 20:58:23 +01:00
|
|
|
print("bump_kernel_tag_mods <query tag> <compile tag> <source (query) repo> <destination entropy repo> [--no-spm-repo] [--keyslot]")
|
2011-08-25 07:52:25 +02:00
|
|
|
raise SystemExit(1)
|
|
|
|
|
|
|
|
kernel_tag = args.pop(0)
|
|
|
|
compile_tag = args.pop(0)
|
|
|
|
source_repo = args.pop(0)
|
|
|
|
dest_repo = args.pop(0)
|
|
|
|
|
|
|
|
sys.argv.append("--no-pid-handling")
|
|
|
|
|
|
|
|
os.environ['KERNEL_DIR'] = "/usr/src/linux-" + compile_tag
|
|
|
|
os.environ['ETP_REPO'] = source_repo
|
|
|
|
import entropy.dep
|
|
|
|
from entropy.server.interfaces import Server
|
|
|
|
srv = Server()
|
|
|
|
pkgs_map = {}
|
|
|
|
try:
|
|
|
|
repo = srv.open_repository(srv.repository())
|
|
|
|
pkg_ids = repo.searchTaggedPackages(kernel_tag)
|
|
|
|
if not pkg_ids:
|
|
|
|
print("!!! no packages for kernel_tag")
|
|
|
|
|
2011-11-12 10:32:11 +01:00
|
|
|
injected_atoms = []
|
|
|
|
for pkg_id in injected_atoms:
|
|
|
|
atom_str = entropy.dep.remove_tag(repo.retrieveAtom(pkg_id))
|
|
|
|
if do_spm_repo:
|
|
|
|
spm_repo = repo.retrieveSpmRepository(pkg_id)
|
|
|
|
if spm_repo is not None:
|
|
|
|
atom_str += "::" + spm_repo
|
|
|
|
injected_atoms.append(atom_str)
|
2011-11-29 20:58:23 +01:00
|
|
|
if keyslot:
|
2011-11-29 22:58:32 +01:00
|
|
|
injected_atoms = [entropy.dep.remove_tag_from_slot(repo.retrieveKeySlotAggregated(pkg_id)) for pkg_id in pkg_ids]
|
2011-11-29 20:58:23 +01:00
|
|
|
else:
|
2011-11-29 22:58:32 +01:00
|
|
|
injected_atoms = ["~" + entropy.dep.remove_tag(repo.retrieveAtom(pkg_id)) for pkg_id in pkg_ids]
|
2011-08-25 07:52:25 +02:00
|
|
|
finally:
|
|
|
|
srv.shutdown()
|
|
|
|
|
|
|
|
if injected_atoms:
|
|
|
|
print("packages: %s" % (' '.join(injected_atoms),))
|
|
|
|
else:
|
|
|
|
print("nothing to do !!")
|
|
|
|
raise SystemExit(0)
|
|
|
|
|
|
|
|
tmp_dir = tempfile.mkdtemp()
|
|
|
|
os.environ['PKGDIR'] = tmp_dir
|
2011-11-29 22:58:32 +01:00
|
|
|
rc = subprocess.call(["emerge", "-Bav", "--keep-going"] + [x for x in injected_atoms])
|
2011-08-25 07:52:25 +02:00
|
|
|
if rc != 0:
|
|
|
|
raise SystemExit(rc)
|
|
|
|
tbz2s = []
|
|
|
|
for category in os.listdir(tmp_dir):
|
|
|
|
path = os.path.join(tmp_dir, category)
|
|
|
|
if not os.path.isdir(path):
|
|
|
|
continue
|
|
|
|
for sub_file in os.listdir(path):
|
|
|
|
if not sub_file.endswith(".tbz2"):
|
|
|
|
continue
|
|
|
|
tbz2s.append(os.path.join(path, sub_file))
|
|
|
|
|
|
|
|
if tbz2s:
|
|
|
|
os.environ['ETP_REPO'] = dest_repo
|
2011-10-20 17:06:17 +02:00
|
|
|
rc = subprocess.call(["eit", "inject"] + tbz2s)
|
2011-08-25 07:52:25 +02:00
|
|
|
if rc != 0:
|
|
|
|
raise SystemExit(rc)
|
|
|
|
|
|
|
|
raise SystemExit(0)
|