[bin] add helper scripts

This commit is contained in:
Fabio Erculiani 2011-07-14 22:05:05 +02:00
parent 381e51a098
commit 21e3b6da8b
10 changed files with 356 additions and 0 deletions

28
bin/bump_ati_drivers Executable file
View File

@ -0,0 +1,28 @@
#!/bin/sh
kernels="2.6.36-sabayon 2.6.37-sabayon 2.6.38-sabayon 2.6.39-sabayon"
running_kernel="2.6.39-sabayon"
packages="x11-drivers/ati-drivers::sabayon"
# build for latest kernel
KERNEL_DIR="/usr/src/linux-${running_kernel}" emerge $packages media-video/amdcccle::sabayon
echo -5 | etc-update
reagent update
for kernel in $kernels; do
if [ "${kernel}" = "${running_kernel}" ]; then
continue
fi
rm -rf /usr/portage/packages/*
KERNEL_DIR="/usr/src/linux-${kernel}" emerge -B ${packages} || ( echo "ouch unable to build" && exit 1 )
built_pkgs=$(find /usr/portage/packages -name "*.tbz2" | xargs echo)
[[ -z "${built_pkgs}" ]] && echo "ouch no kernel pkgs" && exit 2
reagent inject ${built_pkgs} || ( echo "ouch unable to inject" && exit 3 )
echo
reagent query tags ${kernel} -qv | sort
echo
done
echo "Now you should remove old packages:"
echo reagent repo remove `reagent query search ${packages} -qv | grep MY_OLD_VER | xargs echo`
echo

19
bin/bump_injected_ati_drivers Executable file
View File

@ -0,0 +1,19 @@
#!/bin/sh
kernels="2.6.36-sabayon 2.6.37-sabayon 2.6.38-sabayon"
packages="=x11-drivers/ati-drivers-11.2-r1"
non_injected_packages="~x11-drivers/ati-userspace-11.2"
ETP_REPO="${ETP_REPO:-sabayon-limbo}"
rm -rf /usr/portage/packages/x11-drivers/*
emerge -B ${non_injected_packages} || exit 1
reagent inject /usr/portage/packages/x11-drivers/* || exit 1
for kernel in $kernels; do
mypackages="${packages}"
# build for latest kernel
rm -rf /usr/portage/packages/x11-drivers/*
KERNEL_DIR="/usr/src/linux-${kernel}" emerge -B ${mypackages} || exit 1
reagent inject /usr/portage/packages/x11-drivers/*
echo
done

41
bin/bump_injected_kernel_mods Executable file
View File

@ -0,0 +1,41 @@
#!/bin/sh
kernel="${1}"
if [ -z "${kernel}" ]; then
echo "$0 <kernel>"
echo "example: $0 2.6.35-sabayon"
exit 1
fi
packages="app-emulation/open-vm-tools-kmod
app-emulation/virtualbox-guest-additions
app-emulation/virtualbox-modules
app-emulation/vmware-modules
app-laptop/omnibook
app-laptop/tp_smapi
media-video/em8300-modules
net-wireless/acx
net-wireless/broadcom-sta
net-wireless/madwifi-ng
=net-wireless/ndiswrapper-1.55-r1
sys-block/iscsitarget
sys-fs/vhba
~x11-drivers/ati-drivers-10.8
net-wireless/rtl8192se
~x11-drivers/nvidia-drivers-173.14.27
~x11-drivers/nvidia-drivers-195.36.31
~x11-drivers/nvidia-drivers-96.43.18
~x11-drivers/nvidia-drivers-256.53
x11-drivers/xf86-video-virtualbox"
ETP_REPO="${ETP_REPO:-sabayonlinux.org}"
# build for latest kernel
rm -rf /usr/portage/packages/*
KERNEL_DIR="/usr/src/linux-${kernel}" emerge -Bav ${packages}
if [ "${?}" != "0" ]; then
exit 1
fi
reagent inject $(find /usr/portage/packages -name "*.tbz2" | xargs echo)
echo "Now you should remove old packages, if you want of course"

View File

@ -0,0 +1,19 @@
#!/bin/sh
kernels="2.6.36-sabayon 2.6.37-sabayon 2.6.38-sabayon 2.6.39-sabayon"
packages="~x11-drivers/nvidia-drivers-173.14.30" # ~x11-drivers/nvidia-drivers-96.43.19"
non_injected_packages="~x11-drivers/nvidia-userspace-173.14.30" # ~x11-drivers/nvidia-userspace-96.43.19"
ETP_REPO="${ETP_REPO:-sabayon-limbo}"
rm -rf /usr/portage/packages/x11-drivers/*
emerge -B ${non_injected_packages} || exit 1
reagent inject /usr/portage/packages/x11-drivers/* || exit 1
for kernel in $kernels; do
mypackages="${packages}"
# build for latest kernel
rm -rf /usr/portage/packages/x11-drivers/*
KERNEL_DIR="/usr/src/linux-${kernel}" emerge -B ${mypackages} || exit 1
reagent inject /usr/portage/packages/x11-drivers/*
echo
done

91
bin/bump_kernel_tag_mods Executable file
View File

@ -0,0 +1,91 @@
#!/usr/bin/python2
import sys
import subprocess
import os
import tempfile
args = sys.argv[1:]
only_injected = "--only-injected" in args
if only_injected:
args.remove("--only-injected")
if len(args) < 3:
print("bump_kernel_tag_mods <query tag> <compile tag> <source (query) repo> <destination entropy repo>")
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")
injected_pkgs = []
normal_pkgs = []
for pkg_id in pkg_ids:
injected = repo.isInjected(pkg_id)
if injected:
injected_pkgs.append(pkg_id)
else:
normal_pkgs.append(pkg_id)
normal_atoms = [entropy.dep.remove_tag(repo.retrieveAtom(pkg_id)) for pkg_id in normal_pkgs]
injected_atoms = [entropy.dep.remove_tag(repo.retrieveAtom(pkg_id)) for pkg_id in injected_pkgs]
finally:
srv.shutdown()
if not only_injected:
if normal_atoms:
print("normal packages: %s" % (' '.join(normal_atoms),))
if injected_atoms:
print("injected packages: %s" % (' '.join(injected_atoms),))
if not (normal_atoms or injected_atoms):
print("nothing to do !!")
raise SystemExit(0)
if normal_atoms and not only_injected:
rc = subprocess.call(["emerge", "-av", "--keep-going"] + ["~" + x for x in normal_atoms])
if rc != 0:
raise SystemExit(rc)
subprocess.call(["etc-update"], shell = True)
os.environ['ETP_REPO'] = dest_repo
rc = subprocess.call(["reagent", "update"])
if rc != 0:
raise SystemExit(rc)
if injected_atoms:
tmp_dir = tempfile.mkdtemp()
os.environ['PKGDIR'] = tmp_dir
rc = subprocess.call(["emerge", "-Bav", "--nodeps"] + ["~" + x for x in injected_atoms])
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
rc = subprocess.call(["reagent", "inject"] + tbz2s)
if rc != 0:
raise SystemExit(rc)
raise SystemExit(0)

33
bin/bump_kernel_video_drivers Executable file
View File

@ -0,0 +1,33 @@
#!/bin/sh
# PLEASE READ:
# This script recompiles all the kernel-dependent video drivers for
# every currently supported kernel. You can use this script when
# you bump kernels or xorg-server.
kernels="2.6.36-sabayon 2.6.37-sabayon 2.6.38-sabayon 2.6.39-sabayon"
running_kernel="2.6.39-sabayon"
packages="~x11-drivers/nvidia-drivers-173.14.28 ~x11-drivers/nvidia-drivers-96.43.19"
non_injected_packages="~x11-drivers/nvidia-drivers-260.19.29 x11-drivers/ati-drivers x11-drivers/xf86-video-virtualbox"
general_purpose_packages="media-video/amdcccle"
ETP_REPO="${ETP_REPO:-sabayon-limbo}"
for kernel in $kernels; do
mypackages="${packages}"
if [ "${kernel}" != "${running_kernel}" ]; then
mypackages="${mypackages} ${non_injected_packages}"
fi
# build for latest kernel
rm -rf /usr/portage/packages/x11-drivers/*
KERNEL_DIR="/usr/src/linux-${kernel}" emerge -B ${mypackages} || exit 1
reagent inject /usr/portage/packages/x11-drivers/*
echo
done
# Workout drivers for the running kernel, those non injected
eselect kernel set "linux-${running_kernel}" || exit 1
emerge ${non_injected_packages} ${general_purpose_packages} || exit 1
echo -5 | etc-update
reagent update --atoms ${non_injected_packages} ${general_purpose_packages} || exit 1
echo "Now you should remove old packages, if you want of course"

28
bin/bump_nvidia_drivers Executable file
View File

@ -0,0 +1,28 @@
#!/bin/sh
kernels="2.6.36-sabayon 2.6.37-sabayon 2.6.38-sabayon 2.6.39-sabayon"
running_kernel="2.6.39-sabayon"
packages="x11-drivers/nvidia-drivers::sabayon"
# build for latest kernel
KERNEL_DIR="/usr/src/linux-${running_kernel}" emerge $packages media-video/nvidia-settings::sabayon
echo -5 | etc-update
reagent update
for kernel in $kernels; do
if [ "${kernel}" = "${running_kernel}" ]; then
continue
fi
rm -rf /usr/portage/packages/*
KERNEL_DIR="/usr/src/linux-${kernel}" emerge -B ${packages} || ( echo "ouch unable to build" && exit 1 )
built_pkgs=$(find /usr/portage/packages -name "*.tbz2" | xargs echo)
[[ -z "${built_pkgs}" ]] && echo "ouch no kernel pkgs" && exit 2
reagent inject ${built_pkgs} || ( echo "ouch unable to inject" && exit 3 )
echo
reagent query tags ${kernel} -qv | sort
echo
done
echo "Now you should remove old packages:"
echo reagent repo remove `reagent query search ${packages} -qv | grep MY_OLD_VER | xargs echo`
echo

29
bin/bump_vbox Executable file
View File

@ -0,0 +1,29 @@
#!/bin/sh
kernels="2.6.36-sabayon 2.6.37-sabayon 2.6.38-sabayon"
running_kernel="2.6.39-sabayon"
packages="app-emulation/virtualbox-guest-additions app-emulation/virtualbox-modules x11-drivers/xf86-video-virtualbox"
# build for latest kernel
KERNEL_DIR="/usr/src/linux-${running_kernel}" emerge xf86-input-virtualbox $packages virtualbox-bin
echo -5 | etc-update
reagent update
for kernel in $kernels; do
if [ "${kernel}" = "${running_kernel}" ]; then
continue
fi
rm -rf /usr/portage/packages/*
KERNEL_DIR="/usr/src/linux-${kernel}" emerge -B ${packages} || ( echo "ouch unable to build" && exit 1 )
built_pkgs=$(find /usr/portage/packages -name "*.tbz2" | xargs echo)
[[ -z "${built_pkgs}" ]] && echo "ouch no kernel pkgs" && exit 2
reagent inject ${built_pkgs} || ( echo "ouch unable to inject" && exit 3 )
echo
reagent query tags ${kernel} -qv | sort
echo
done
echo "Now you should remove old packages:"
echo reagent repo remove `reagent query search virtualbox -qv | grep MY_OLD_VER | xargs echo`
echo
echo "PLEASE also see /etc/entropy/packages/packages.server.dep_rewrite"

2
bin/bump_weekly_repo Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
ssh entropy@pkg.sabayon.org /sabayon/bin/update-sabayon-weekly-repository

66
bin/check_la Executable file
View File

@ -0,0 +1,66 @@
#!/usr/bin/python2
import sys
la_patterns = sys.argv[1:]
if not la_patterns:
print sys.argv[0], "<.la files patterns>"
raise SystemExit(1)
import os
import re
import tempfile
import shutil
from entropy.server.interfaces import Server
import entropy.tools
la_compiled_patterns = dict((x, re.compile(x)) for x in la_patterns)
print la_compiled_patterns
repo_id = os.getenv("ETP_REPO", "sabayonlinux.org")
srv = Server()
dbconn = srv.open_repository(repo_id)
pkg_ids = dbconn.listAllIdpackages(order_by="atom")
for pkg_id in pkg_ids:
# get pkg path
pkg_path = srv._get_package_path(repo_id, dbconn, pkg_id)
if not os.path.isfile(pkg_path):
print "WTF, not a package file =>", pkg_path
continue
# now extract
tmp_dir = tempfile.mkdtemp()
rc = entropy.tools.uncompress_tarball(pkg_path, extract_path = tmp_dir,
catch_empty = True)
if rc != 0:
print "WTF, cannot extract file", pkg_path, "at dir", tmp_dir
continue
la_paths = []
for cur_dir, subdirs, files in os.walk(tmp_dir):
for file in files:
path = os.path.join(cur_dir, file)
if path.endswith(".la") and os.path.isfile(path) and os.access(path, os.R_OK):
la_paths.append(path)
if not la_paths:
continue
# print "pkg:", dbconn.retrieveAtom(pkg_id), "la:", la_paths
found = False
for la_path in la_paths:
# apply regexps
la_f = open(la_path, "r")
la_content = la_f.read()
la_f.close()
for la_pattern, cm_pattern in la_compiled_patterns.items():
if cm_pattern.search(la_content):
found = True
break
if found:
print dbconn.retrieveKeySlotAggregated(pkg_id)
break
shutil.rmtree(tmp_dir, True)
srv.shutdown()
raise SystemExit(0)