parent
0810c8c48e
commit
9e5d6a2de9
@ -0,0 +1,40 @@
|
||||
# Copyright 1999-2012 Gentoo Foundation
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
# $Header: $
|
||||
|
||||
EAPI="5"
|
||||
PYTHON_COMPAT=(python2_7)
|
||||
|
||||
inherit distutils-r1 eutils
|
||||
|
||||
SRC_URI="ftp://ftp.calculate.ru/pub/calculate/calculate2/${PN}/${P}.tar.bz2
|
||||
http://mirror.yandex.ru/calculate/calculate2/${PN}/${P}.tar.bz2"
|
||||
|
||||
DESCRIPTION="Builder tasks utilities for Calculate Linux"
|
||||
HOMEPAGE="http://www.calculate-linux.org/main/en/calculate2"
|
||||
LICENSE="Apache-2.0"
|
||||
SLOT="0"
|
||||
KEYWORDS="amd64 x86"
|
||||
|
||||
DEPEND="~sys-apps/calculate-lib-2.2.32
|
||||
!<sys-apps/calculate-1.4.0_p20100921
|
||||
>=app-cdr/cdrtools-3.01_alpha13
|
||||
>=sys-boot/grub-2.00-r3
|
||||
>=sys-boot/syslinux-4.06
|
||||
sys-fs/squashfs-tools"
|
||||
|
||||
RDEPEND="${DEPEND}"
|
||||
|
||||
src_unpack() {
|
||||
unpack "${A}"
|
||||
cd "${S}"
|
||||
|
||||
# fix variable, remove cl-kernel, fix rescratch
|
||||
epatch "${FILESDIR}/calculate-builder-2.2.32-r3.patch"
|
||||
|
||||
# fix clean image
|
||||
epatch "${FILESDIR}/calculate-builder-2.2.32-clean.patch"
|
||||
|
||||
# fix clean kernel
|
||||
epatch "${FILESDIR}/calculate-builder-2.2.32-clean_kernel.patch"
|
||||
}
|
@ -0,0 +1,118 @@
|
||||
diff --git pym/cl_fill_builder.py pym/cl_fill_builder.py
|
||||
index 0e51827..e62d04f 100644
|
||||
--- pym/cl_fill_builder.py
|
||||
+++ pym/cl_fill_builder.py
|
||||
@@ -190,73 +190,40 @@ class fillVars(object, varsShare):
|
||||
return "/run/builder"
|
||||
return "/"
|
||||
|
||||
+ def get_cl_builder_kernel_ver(self):
|
||||
+ prefix = self.Get('cl_builder_path')
|
||||
+ current_src = self.get_current_kernel_src(prefix)
|
||||
+ src = path.join(prefix,current_src)
|
||||
+ return self.get_src_kernel_version(src)
|
||||
+
|
||||
+ def get_kernel_object(self, objname):
|
||||
+ mapFunc = {'kernel':(self.list_kernel, self.filter_kernel),
|
||||
+ 'initrd':(self.list_initramfs, self.filter_initramfs),
|
||||
+ 'config':(self.list_config, self.filter_config),
|
||||
+ 'map':(self.list_system_map, self.filter_system_map)}
|
||||
+ listf, filterf = mapFunc[objname]
|
||||
+ prefix = self.Get('cl_builder_path')
|
||||
+ version = self.Get('cl_builder_kernel_ver')
|
||||
+ objfile = self.max_default(
|
||||
+ filterf(listf(prefix),version=version),
|
||||
+ key=path.getmtime,
|
||||
+ default="")
|
||||
+ if objfile:
|
||||
+ objfile = path.basename(objfile)
|
||||
+ return objfile
|
||||
+
|
||||
def get_cl_builder_kernel(self):
|
||||
"""Kernel image"""
|
||||
- bootdir = path.join(self.Get('cl_builder_path'),'boot')
|
||||
- modulesdir = path.join(self.Get('cl_builder_path'),'lib/modules')
|
||||
- if not os.access(modulesdir,os.R_OK):
|
||||
- return ""
|
||||
- validKernel = os.listdir(modulesdir)
|
||||
- kernelFiles = self.getFilesByType(bootdir,"Linux kernel")
|
||||
- kernelsWithVer = \
|
||||
- map(lambda x:(x[0],(getTupleVersion("".join(x[1].groups()[0:3:2])),
|
||||
- path.getmtime(x[0]))),
|
||||
- filter(lambda x:x[1] and x[1].group() in validKernel,
|
||||
- map(lambda x:(x[0],self.reFindVer.search(x[1])),
|
||||
- kernelFiles)))
|
||||
- if kernelsWithVer:
|
||||
- return path.split(max(kernelsWithVer,key=itemgetter(1))[0])[-1]
|
||||
- return ""
|
||||
+ return self.get_kernel_object("kernel")
|
||||
|
||||
def get_cl_builder_initrd_install(self):
|
||||
- kernelname = self.Get('cl_builder_kernel')
|
||||
- reShortname = re.compile(
|
||||
- r"^vmlinuz-(\d+\.)*\d+-(x86_64|i686)-(.*)$",re.S)
|
||||
- res = reShortname.search(kernelname)
|
||||
- if res:
|
||||
- shortname = res.groups()[2]
|
||||
- archmachine = res.groups()[1]
|
||||
- else:
|
||||
- shortname = self.Get('os_builder_linux_shortname')
|
||||
- archmachine = self.Get('os_builder_arch_machine')
|
||||
- return self.getInitrd(archmachine,
|
||||
- shortname,
|
||||
- self.Get('cl_builder_path'),
|
||||
- kernelname) or ""
|
||||
+ return self.get_kernel_object("initrd")
|
||||
|
||||
def get_cl_builder_kernel_config(self):
|
||||
- kernelname = self.Get('cl_builder_kernel')
|
||||
- reShortname = re.compile(
|
||||
- r"^vmlinuz-((?:\d+\.)*\d+)-(x86_64|i686)-(.*)$",re.S)
|
||||
- res = reShortname.search(kernelname)
|
||||
- bootPath = path.join(self.Get('cl_builder_path'),'boot')
|
||||
- if res:
|
||||
- kernelconfig = "config-%s-%s-%s"%(res.groups()[:3])
|
||||
- if path.exists(path.join(bootPath,kernelconfig)):
|
||||
- return kernelconfig
|
||||
- elif path.exists(bootPath):
|
||||
- configs = filter(lambda x:x.startswith('config'),
|
||||
- os.listdir(bootPath))
|
||||
- if configs:
|
||||
- return configs[0]
|
||||
- return ""
|
||||
+ return self.get_kernel_object("config")
|
||||
|
||||
def get_cl_builder_kernel_systemmap(self):
|
||||
- kernelname = self.Get('cl_builder_kernel')
|
||||
- reShortname = re.compile(
|
||||
- r"^vmlinuz-((?:\d+\.)*\d+)-(x86_64|i686)-(.*)$",re.S)
|
||||
- res = reShortname.search(kernelname)
|
||||
- bootPath = path.join(self.Get('cl_builder_path'),'boot')
|
||||
- if res:
|
||||
- systemmap = "System.map-%s-%s-%s"%(res.groups()[:3])
|
||||
- if path.exists(path.join(bootPath,systemmap)):
|
||||
- return systemmap
|
||||
- elif path.exists(bootPath):
|
||||
- systemmaps = filter(lambda x:x.startswith('System.map'),
|
||||
- os.listdir(bootPath))
|
||||
- if systemmaps:
|
||||
- return systemmaps[0]
|
||||
- return ""
|
||||
+ return self.get_kernel_object("map")
|
||||
|
||||
def get_os_builder_linux_name(self):
|
||||
"""Build system name"""
|
||||
diff --git pym/cl_vars_builder.py pym/cl_vars_builder.py
|
||||
index 71e6c82..5ac4b59 100644
|
||||
--- pym/cl_vars_builder.py
|
||||
+++ pym/cl_vars_builder.py
|
||||
@@ -82,6 +82,9 @@ class Data:
|
||||
# directory for iso building
|
||||
cl_builder_iso_path = {'mode':'w'}
|
||||
|
||||
+ # builder kernel version
|
||||
+ cl_builder_kernel_ver = {}
|
||||
+
|
||||
# kernel image
|
||||
cl_builder_kernel = {}
|
||||
|
@ -0,0 +1,43 @@
|
||||
# Copyright 1999-2012 Gentoo Foundation
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
# $Header: $
|
||||
|
||||
EAPI="5"
|
||||
PYTHON_COMPAT=(python2_7)
|
||||
|
||||
inherit distutils-r1 eutils
|
||||
|
||||
SRC_URI="ftp://ftp.calculate.ru/pub/calculate/calculate2/${PN}/${P}.tar.bz2
|
||||
http://mirror.yandex.ru/calculate/calculate2/${PN}/${P}.tar.bz2"
|
||||
|
||||
DESCRIPTION="The library for Calculate 2"
|
||||
HOMEPAGE="http://www.calculate-linux.org/main/en/calculate2"
|
||||
LICENSE="Apache-2.0"
|
||||
SLOT="2.2"
|
||||
KEYWORDS="amd64 x86"
|
||||
IUSE="minimal"
|
||||
DEPEND="!<sys-apps/calculate-lib-2.1.8-r1
|
||||
!=sys-apps/calculate-lib-2.1.9
|
||||
!=sys-apps/calculate-lib-2.1.10
|
||||
!minimal? ( dev-python/py-smbpasswd )
|
||||
>=dev-python/pyxml-0.8
|
||||
sys-apps/iproute2
|
||||
sys-apps/pciutils
|
||||
sys-fs/lvm2
|
||||
sys-fs/mdadm
|
||||
sys-apps/file[python]"
|
||||
RDEPEND="${DEPEND}"
|
||||
|
||||
src_unpack() {
|
||||
unpack "${A}"
|
||||
cd "${S}"
|
||||
|
||||
# create revision for calculate lib
|
||||
epatch "${FILESDIR}/calculate-lib-2.2.32-r2.patch"
|
||||
|
||||
# fix for compabitble with file-5.19
|
||||
epatch "${FILESDIR}/calculate-lib-2.2.32-fix_file.patch"
|
||||
|
||||
# fix for clean kernel from builder
|
||||
epatch "${FILESDIR}/calculate-lib-2.2.32-fix_clean_kernel.patch"
|
||||
}
|
@ -0,0 +1,172 @@
|
||||
diff --git pym/cl_utils.py pym/cl_utils.py
|
||||
index 5c6a199..da5ef2e 100644
|
||||
--- pym/cl_utils.py
|
||||
+++ pym/cl_utils.py
|
||||
@@ -1479,3 +1479,36 @@ def countFiles(dirpath,onefilesystem=True):
|
||||
for dirname in mountDirs:
|
||||
dirnames.remove(dirname)
|
||||
return num
|
||||
+
|
||||
+class InitrdFile(object):
|
||||
+ re_kver_path = re.compile("/modules/([^/]+)/kernel")
|
||||
+ def __init__(self, _file):
|
||||
+ self._file = _file
|
||||
+
|
||||
+ def get_kernel_version(self):
|
||||
+ for fn in self.get_names():
|
||||
+ if "/modules/" in fn and "/kernel" in fn:
|
||||
+ m = self.re_kver_path.search(fn)
|
||||
+ if m:
|
||||
+ return m.group(1)
|
||||
+ else:
|
||||
+ break
|
||||
+ return ""
|
||||
+
|
||||
+ def get_names(self):
|
||||
+ if not path.exists(self._file):
|
||||
+ # raise IOError
|
||||
+ open(self._file)
|
||||
+ gz = Popen(['/bin/gzip', "-dc", self._file], stdout=PIPE, stderr=PIPE,
|
||||
+ close_fds=True)
|
||||
+ cpio = Popen(["/bin/cpio","-tf"], stdout=PIPE, stdin=gz.stdout,
|
||||
+ stderr=PIPE, close_fds=True)
|
||||
+ try:
|
||||
+ for fn in cpio.stdout.xreadlines():
|
||||
+ yield fn.rstrip()
|
||||
+ finally:
|
||||
+ cpio.terminate()
|
||||
+ gz.terminate()
|
||||
+
|
||||
+ def __iter__(self):
|
||||
+ return iter(self.get_names())
|
||||
diff --git pym/cl_vars_share.py pym/cl_vars_share.py
|
||||
index 52a114e..ec4981a 100644
|
||||
--- pym/cl_vars_share.py
|
||||
+++ pym/cl_vars_share.py
|
||||
@@ -16,9 +16,11 @@
|
||||
|
||||
import os
|
||||
import sys
|
||||
-from cl_utils import getpathenv, runOsCommand, typeFile,process
|
||||
+from cl_utils import (getpathenv, runOsCommand, typeFile,process,
|
||||
+ listDirectory, InitrdFile)
|
||||
import re
|
||||
from os import path, R_OK
|
||||
+
|
||||
try:
|
||||
from cl_ldap import ldapUser
|
||||
except ImportError:
|
||||
@@ -276,10 +278,13 @@ class varsShare:
|
||||
|
||||
def getFilesByType(self,pathname,descr):
|
||||
"""Get files from "pathname" has "descr" in descriptions"""
|
||||
- filelist = map(lambda x:path.join(pathname,x),os.listdir(pathname))
|
||||
+ return list(self.get_files_by_type(pathname, descr))
|
||||
+
|
||||
+ def get_files_by_type(self, pathname, descr):
|
||||
ftype = typeFile(magic=0x4).getMType
|
||||
- filesWithType = map(lambda x:(x,ftype(x)), filelist)
|
||||
- return filter(lambda x:descr in x[1],filesWithType)
|
||||
+ for x in listDirectory(pathname, fullPath=True):
|
||||
+ if descr in ftype(x):
|
||||
+ yield x
|
||||
|
||||
def getInitrd(self,arch,shortname,chroot,kernel,suffix="",notsuffix=""):
|
||||
"""Get initrd for kernel"""
|
||||
@@ -629,3 +634,96 @@ class varsShare:
|
||||
return res[:8]
|
||||
else:
|
||||
return "no_uid"
|
||||
+
|
||||
+ def get_current_kernel_src(self, prefix='/'):
|
||||
+ """
|
||||
+ Get current kernel source directory
|
||||
+ """
|
||||
+ src_path = "usr/src"
|
||||
+ current_linux_src = path.join(src_path,"linux")
|
||||
+ symlink_kernel = path.join(prefix,current_linux_src)
|
||||
+ if not path.exists(symlink_kernel) or not path.islink(symlink_kernel):
|
||||
+ raise ValueError("Failed to determine current kernel version")
|
||||
+ return path.join(src_path,os.readlink(symlink_kernel))
|
||||
+
|
||||
+ def get_config_version(self, configfile):
|
||||
+ re_config = re.compile("Automatically generated file;.*\n"
|
||||
+ ".*?Linux/\S+\s+(\S+)\s", re.M)
|
||||
+ if path.exists(configfile):
|
||||
+ with open(configfile) as f:
|
||||
+ match = re_config.search(f.read(200))
|
||||
+ if match:
|
||||
+ return match.group(1)
|
||||
+
|
||||
+ def get_src_kernel_version(self, kernel_src):
|
||||
+ """
|
||||
+ Get version of kernel from .config
|
||||
+ """
|
||||
+ config_path = path.join(kernel_src, ".config")
|
||||
+ makefile_path = path.join(kernel_src, "Makefile")
|
||||
+
|
||||
+ # get version from config
|
||||
+ version = self.get_config_version(config_path)
|
||||
+ if version:
|
||||
+ return version
|
||||
+
|
||||
+ # get version from Makefile
|
||||
+ re_makefile = re.compile("^VERSION = (\S+)\n"
|
||||
+ "PATCHLEVEL = (\S+)\n"
|
||||
+ "SUBLEVEL = (\S+)\n"
|
||||
+ "EXTRAVERSION = (\S*)\n", re.M)
|
||||
+ if path.exists(makefile_path):
|
||||
+ with open(makefile_path) as f:
|
||||
+ match = re_makefile.search(f.read(200))
|
||||
+ if match:
|
||||
+ return "{0}.{1}.{2}{3}".format(*match.groups())
|
||||
+ return ""
|
||||
+
|
||||
+ def list_initramfs(self, prefix='/', bootdir='boot'):
|
||||
+ boot_dir = path.join(prefix, bootdir)
|
||||
+ return self.get_files_by_type(boot_dir,"ASCII cpio archive")
|
||||
+
|
||||
+ def filter_initramfs(self, iterable, version=None):
|
||||
+ for fn in iterable:
|
||||
+ if InitrdFile(fn).get_kernel_version() == version:
|
||||
+ yield fn
|
||||
+
|
||||
+ def list_kernel(self, prefix='/', bootdir='boot'):
|
||||
+ boot_dir = path.join(prefix, bootdir)
|
||||
+ return self.get_files_by_type(boot_dir, "boot executable bzImage")
|
||||
+
|
||||
+ def filter_kernel(self, iterable, version=None):
|
||||
+ ftype = typeFile(magic=0x4).getMType
|
||||
+ re_kver = re.compile("bzImage, version (\S+)\s")
|
||||
+ for fn in iterable:
|
||||
+ m = re_kver.search(ftype(fn))
|
||||
+ if m.group(1) == version:
|
||||
+ yield fn
|
||||
+
|
||||
+ def list_config(self, prefix='/', bootdir='boot'):
|
||||
+ boot_dir = path.join(prefix, bootdir)
|
||||
+ return self.get_files_by_type(boot_dir, "Linux make config build file")
|
||||
+
|
||||
+ def filter_config(self, iterable, version=None):
|
||||
+ for fn in iterable:
|
||||
+ if self.get_config_version(fn) == version:
|
||||
+ yield fn
|
||||
+
|
||||
+ def list_system_map(self, prefix='/', bootdir='boot'):
|
||||
+ boot_dir = path.join(prefix, bootdir)
|
||||
+ for fn in listDirectory(boot_dir):
|
||||
+ if fn.startswith("System.map"):
|
||||
+ yield path.join(boot_dir, fn)
|
||||
+
|
||||
+ def filter_system_map(self, iterable, version=None):
|
||||
+ re_kver = re.compile("System.map-(\S+)$")
|
||||
+ for fn in iterable:
|
||||
+ m = re_kver.search(fn)
|
||||
+ if m and m.group(1) == version:
|
||||
+ yield fn
|
||||
+
|
||||
+ def max_default(self, iterable, key=lambda x:x, default=None):
|
||||
+ try:
|
||||
+ return max(iterable, key=key)
|
||||
+ except ValueError:
|
||||
+ return default
|
@ -0,0 +1,30 @@
|
||||
# Copyright 1999-2012 Gentoo Foundation
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
# $Header: $
|
||||
|
||||
EAPI=3
|
||||
|
||||
DESCRIPTION="Calculate Utilities meta package"
|
||||
HOMEPAGE="http://www.calculate-linux.org/main/en/calculate2"
|
||||
SRC_URI=""
|
||||
|
||||
LICENSE="Apache-2.0"
|
||||
SLOT="0"
|
||||
KEYWORDS="amd64 x86"
|
||||
IUSE="
|
||||
cl_assemble
|
||||
cl_builder
|
||||
cl_server
|
||||
"
|
||||
|
||||
RDEPEND="${RDEPEND}
|
||||
!sys-apps/calculate-templates
|
||||
!<sys-apps/calculate-install-3.0.0_alpha1
|
||||
=sys-apps/calculate-lib-2.2.32-r5
|
||||
=sys-apps/calculate-i18n-2.2.32
|
||||
|
||||
cl_assemble? ( =sys-apps/calculate-assemble-2.2.32-r4 )
|
||||
cl_builder? ( =sys-apps/calculate-builder-2.2.32-r7 )
|
||||
|
||||
cl_server? ( =sys-apps/calculate-server-2.1.16-r15 )
|
||||
"
|
Loading…
Reference in new issue