Update calculate-utilities rc2

atratsevskiy
Mike Hiretsky 13 years ago
parent c5d4ae49f6
commit be98a8d154

@ -2,6 +2,13 @@
# Copyright 1999-2011 Gentoo Foundation; Distributed under the GPL v2
# $Header: $
*calculate-install-2.2.19-r3 (26 Jul 2011)
26 Jul 2011; Mike Hiretsky (mhiretskiy) <mh@calculate.ru>
calculate-install-2.2.19-r2.ebuild, +calculate-install-2.2.19-r3.ebuild,
+files/calculate-install-2.2.19_lvmraid_rc2.patch:
Update for raid lvm
*calculate-install-2.2.19-r2 (25 Jul 2011)
25 Jul 2011; Mike Hiretsky (mhiretskiy) <mh@calculate.ru>

@ -3,6 +3,7 @@ AUX calculate-install-2.2.18-to_2.2.19_rc1.patch 2145 RMD160 ff0242bbf53e10e1cd0
AUX calculate-install-2.2.18-to_2.2.19_rc2.patch 3834 RMD160 5aeac0cc6ce8b889a50e70719592a86717a18f77 SHA1 56bf8ae25eefa1b72d639de66a433cf3853158b0 SHA256 b47e94a9bac6779f0a831ce275cad60f306a9939fa78407c905789186be01243
AUX calculate-install-2.2.19_2.2.20_rc1.patch 4197 RMD160 2173f292eb876ac8ad2f37b05eb2d29cd6c38989 SHA1 468a2c7ba8eff0ed3a4ad1510d571936ed6c3940 SHA256 bbb14bea93756f59fa3d000aa65776e44bcaa06c9926b257ed4a96e91a836543
AUX calculate-install-2.2.19_lvmraid_rc1.patch 71417 RMD160 d692c2d17a57ee98b0c9e095f75d8779e414daca SHA1 5cbbc69cd8ef4fe129a541e1d1bf15ab90b1fbe7 SHA256 5fa8e8a394d2590b399133b60dd068b964b92a300ef06f98f8531d3e1de6d6de
AUX calculate-install-2.2.19_lvmraid_rc2.patch 71669 RMD160 30934778ac315debbebb8aeb332473cf37b4144e SHA1 b065089df52cb6302e55cceb0789f8edab1eaaed SHA256 7eced47992fbd72b6ebea39eedc9da82384aaee032225ed04a0d0ce8b3d1d16e
DIST calculate-install-2.2.18.tar.bz2 75850 RMD160 56b1058d1977957cc6ceb8322a049af4dbb8f0cc SHA1 4e990cf5bd6310942b54995293f1f7ea82726aa9 SHA256 2a1b9c3fa93a958f19f05af51f80adf25f5ee0867452fac0304ec721de19cd97
DIST calculate-install-2.2.19.tar.bz2 63943 RMD160 8c76315aea89d20239b11c7e6017766b5e5e93db SHA1 1127468d3b221333e820e142fc1b9afaef507ee3 SHA256 5dedcb4c3d42ca4d87b2a2fa0d72704be3748865907b991dddbeba493e0da80a
EBUILD calculate-install-2.2.18-r1.ebuild 896 RMD160 ee093622c27d416e091dbe7d79f4937dec59b9ef SHA1 725ebcabb3fc63fde3a6e804d3912caacd121fa7 SHA256 9d08644a337cafe7a5744e4ffdf7f8ff549c785bf03acd33349c441aedb72de2
@ -11,7 +12,8 @@ EBUILD calculate-install-2.2.18-r3.ebuild 971 RMD160 62ee16eb832645a3275da557a6f
EBUILD calculate-install-2.2.18.ebuild 718 RMD160 6036a151e5e5f44dc88f05943483889aac3db500 SHA1 733eb52ed024192f39a93961b2af8b4f4d8b9ed7 SHA256 a10787adc974dd82ca0272b461ad9b593cd441f821fb1696b57d2b97e3f4297f
EBUILD calculate-install-2.2.19-r1.ebuild 907 RMD160 ffc1169f89321fc9e94606a844ae559cf9298dda SHA1 18424b3c512a931e1946372d9db8698bb496ed1a SHA256 54a1e68243a55fe1dbe49385b52cb3728e2ddae3ecd295616bb3742224506189
EBUILD calculate-install-2.2.19-r2.ebuild 905 RMD160 e4825969e7fc0e4aca73e41353b4a0ff8a3719b9 SHA1 c65b23c3c3e1ca25a92307456c43a9488de0d789 SHA256 c4876a5ebf6ffd2e7696656e69cae42528c08674db1a9ed92920e6f50e0145c2
EBUILD calculate-install-2.2.19-r3.ebuild 905 RMD160 1f9ca2bbc0f6fbe1ab614d067c1073bc2237d61a SHA1 956a812e79e13acf7fbcf91f04cd9fe191a120d6 SHA256 b29ebbbb50b754b4576b33ad8e41e9a50229f5785e4a751a5a8a269f57022eae
EBUILD calculate-install-2.2.19.ebuild 774 RMD160 d551b0b0a6e51b5ecfd9bd6310aeaba6b0a04620 SHA1 0493b095e1009496ed991229e86c80f9abcb898c SHA256 465794cf6ba461260664d9ca06238655c2e41e1f4eb65b170ffef22f5b163aff
EBUILD calculate-install-2.2.9999.ebuild 595 RMD160 8f9b9a14fed39ded9c2a9d9343aa4e892d620172 SHA1 09aff28bdaa486868e2caddc7911732a905336ee SHA256 534e6c6e465177e269ce7beed96dab08a124878591088c1bf38095e855ca1180
MISC ChangeLog 23763 RMD160 c8472dd55fce7714790c28ed11b299536a5003b0 SHA1 9a1b9c43c40ec2623ec763cc82115d0f057c4bae SHA256 679441b7126aa6017d3480b3ec21bd5dc456684d49471a3c0d9f8f7c17bb11c9
MISC ChangeLog 24018 RMD160 8a734bee88ef177444bd7e015867c06199d65205 SHA1 533d22e94b895bb44aa18a03464fa02f891cc7a6 SHA256 5290157641fc0b48ec0d5efb8d4d3e4875974642be6a53d4373c7ce401669352
MISC metadata.xml 310 RMD160 769e4f17a9354da6b168b72a5d65d978f65bf6dd SHA1 83aaae376052d69c7327e880cf028ebc0dea608b SHA256 c29d3efc676d8308872920db5223c78469db86ac236b5d45c3ee98ceb8fca846

@ -0,0 +1,41 @@
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
EAPI="3"
inherit distutils eutils
SRC_URI="ftp://ftp.calculate.ru/pub/calculate/calculate2/${PN}/${P}.tar.bz2"
DESCRIPTION="The program of installation Calculate Linux"
HOMEPAGE="http://www.calculate-linux.org/main/en/calculate2"
LICENSE="Apache-2.0"
SLOT="0"
KEYWORDS="amd64 x86"
IUSE="minimal"
DEPEND="~sys-apps/calculate-templates-2.2.19
~sys-apps/calculate-lib-2.2.19
app-portage/layman
!app-misc/livecd-tools
!minimal? ( sys-boot/grub
sys-apps/gptfdisk
sys-fs/dosfstools
sys-fs/squashfs-tools
sys-block/parted )"
RDEPEND="${DEPEND}"
src_unpack() {
unpack "${A}"
cd "${S}"
# update to raidlvm
epatch "${FILESDIR}/calculate-install-2.2.19_lvmraid_rc2.patch"
}
pkg_postinst() {
einfo "For configure calculate-install perform:"
einfo " cl-install --install"
}

@ -2,6 +2,13 @@
# Copyright 1999-2011 Gentoo Foundation; Distributed under the GPL v2
# $Header: $
*calculate-lib-2.2.19-r5 (26 Jul 2011)
26 Jul 2011; Mike Hiretsky (mhiretskiy) <mh@calculate.ru>
+calculate-lib-2.2.19-r5.ebuild,
+files/calculate-lib-2.2.19_lvmraid_rc2.patch:
Update for raid lvm
*calculate-lib-2.2.19-r1 (20 Jul 2011)
20 Jul 2011; Mike Hiretsky (mhiretskiy) <mh@calculate.ru>

@ -3,6 +3,7 @@ AUX calculate-lib-2.2.18-to_2.2.19_rc1.patch 3700 RMD160 29b1ff4dee8ebff2f9a131e
AUX calculate-lib-2.2.19_2.2.20_rc1.patch 6312 RMD160 dc9ea8d0964ecdca54449f00e71a3e385efe36e5 SHA1 ed1168d158236d03f79686aeaf8ce635871fad60 SHA256 ec39ee91efd7d9f43f3c14e13200a4ff6578270e4985743523be8b6074ce15b9
AUX calculate-lib-2.2.19_fix_detect_video.patch 1265 RMD160 7080753d4f7937cb4ff1b0fa9135719911fd9231 SHA1 bd2c56488511338962c8f2a9bb3e1ed045c466f4 SHA256 8d2815dcbb99576b27b8a8c3efdd5ae84bc2acff1abe7b3ffaa68f68b4d4bc83
AUX calculate-lib-2.2.19_lvmraid_rc1.patch 29023 RMD160 3f2778691e38b151a3677a545e906e290e083f28 SHA1 e2f1a74247016ddecbb88572e4c2f0707b1edeaa SHA256 b24055f0d670b778505fe52559529651dc612597648a6a7cc035b60acefb07f6
AUX calculate-lib-2.2.19_lvmraid_rc2.patch 29724 RMD160 aac416459d263c52db23e67bc0388d2944338e68 SHA1 2b298afaa57a239600a491adf402fa3c0f98b868 SHA256 50523f213ffced8eff86e95911ce58bd8db1ce36e04f8fa8f1e0e823f5ba03b5
DIST calculate-lib-2.1.11.tar.bz2 61687 RMD160 93ca4f84ff2cd7018addfd4de162959d78e51f78 SHA1 53149951c346fea7709cb43b4d8ebefe63acb0fd SHA256 62976c08d4fb4810389ace6f5a99abb5a962f6c8d9053ff943d0669480fb5599
DIST calculate-lib-2.1.8.tar.bz2 61178 RMD160 4a4ed063a9b4d3b82723f5f6eb046c97ad9fcda1 SHA1 93eb20057afff6e98c409388e1259a3ad078bb7a SHA256 ef8e315001663da7a45e69b82dc7c158fb0e10bd567efa95bf8a654ed441144a
DIST calculate-lib-2.2.18.tar.bz2 111559 RMD160 294326d180c3de46ef1f5c56d4da10313e123d87 SHA1 e6340c81573421eca1f8b882f4a4929830df8bdd SHA256 8e8c0124ab9e2efa270fba9529c36a4dd12aa6d616d005e35945bbd999b6a3a5
@ -17,8 +18,9 @@ EBUILD calculate-lib-2.2.19-r1.ebuild 768 RMD160 46ff73396ecc8e2edc58a77103b037e
EBUILD calculate-lib-2.2.19-r2.ebuild 768 RMD160 46ff73396ecc8e2edc58a77103b037e0212ec2bc SHA1 4d733b8cb2e3245d395251f0e8840f2b78b35f15 SHA256 abf627bbfa04b1e4ea3cc705cc683fd0d9398dd7f952ffa0082899437d99d542
EBUILD calculate-lib-2.2.19-r3.ebuild 854 RMD160 8825d51df1c6ca570f7fd9b9b91c0967a4a272e5 SHA1 19b7f0025d0fcb278fb0065b1bd0980f3dba2a94 SHA256 415868961950664d85220a6d242cc5ad3e5ffe238c05978832d9007530e0319b
EBUILD calculate-lib-2.2.19-r4.ebuild 766 RMD160 3ecf0c49ba379ccc98493549b8c226fe1548fc00 SHA1 fceffdd13b176028ace38782acc3a766982d088e SHA256 d142cd85e128642cbeaccea41c181486d74c4f5ea501d67620c95d26d0c6c3be
EBUILD calculate-lib-2.2.19-r5.ebuild 793 RMD160 5784660046ff341b4ae1bda6bb88049fae05de08 SHA1 e662dad4e80f281e80cb5c399c1ede0c505cf16a SHA256 ccaf03b638bb894192782b1ec1067e8fa989dd41909c59b3ecf8bb650ec0d1f9
EBUILD calculate-lib-2.2.19.ebuild 639 RMD160 d2dda2492b257947c88e37acdfdcffd30266ef29 SHA1 c0fee75613aa560848d32f7314737bc094d0dceb SHA256 bafff10516a4b7557c379e20592026a684be9b34dd38b381e136bd457c2c1dc0
EBUILD calculate-lib-2.2.9999.ebuild 726 RMD160 6dce718f317825c712f7c9595a3e712ef6222cf9 SHA1 42e1607a36e826310ef5ed317d717c5aa8acc2bf SHA256 dce73aafa346ea1fd88b6e99d8f6184a562de56e3eb871c1b5849890b13c34c2
EBUILD calculate-lib-9999.ebuild 476 RMD160 3df165f011b324fa8dc37d0443e941263943dd61 SHA1 069ab864dc83f32c69c4349d807d25e1196756ee SHA256 07a628ede4f47849908dd543f879ab8b40a5ca887b892fa0f5cf6c1ef2a24cab
MISC ChangeLog 23345 RMD160 c2cd3750c273d5e9592432bdaf97b010cc5c9bbc SHA1 cf45d395761507b5f748ad431647e88beb72fc80 SHA256 19a08f1c4902462468512839a084748042c05cdb5d2fae5bc029df4f0655e2c0
MISC ChangeLog 23552 RMD160 1fabde1e932fbfb3985d61a8a94251355ed49fb0 SHA1 aae2d72ef971a06c76ec6dd21ecda968da0a807c SHA256 150edef3927d2b86ee9b5f004d50601ecbc7920487f7f0d2aa498f8fe15caef1
MISC metadata.xml 303 RMD160 774b65ed76939d6878496ad6ef6451849bdced05 SHA1 7d08569697a290ede98c88ab59db3cdc3037bd15 SHA256 181519d9679fd9aee9a7a9806733a50728d3da0b1e0ad54f31499200f7f5c6ec

@ -0,0 +1,34 @@
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
EAPI="3"
inherit distutils eutils
SRC_URI="ftp://ftp.calculate.ru/pub/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-fs/lvm2
sys-fs/mdadm
sys-apps/file[python]"
RDEPEND="${DEPEND}"
src_unpack() {
unpack "${A}"
cd "${S}"
# update to lvmraid
epatch "${FILESDIR}/calculate-lib-2.2.19_lvmraid_rc2.patch"
}

@ -0,0 +1,747 @@
diff --git pym/cl_fill.py pym/cl_fill.py
index a846970..082b67e 100644
--- pym/cl_fill.py
+++ pym/cl_fill.py
@@ -23,8 +23,10 @@ import cl_overriding
from cl_vars_share import varsShare, clLocale
from os.path import exists as pathexists
from os import path
-from cl_utils import isMount, genpassword, getAvailableX11Drivers, \
- listDirectory,isPkgInstalled,lspci
+from cl_utils import isMount, genpassword, \
+ getAvailableVideo, process, \
+ listDirectory,isPkgInstalled,lspci, readLinesFile, \
+ getUdevDeviceInfo
from utils import ip
from encrypt import getHash
@@ -186,22 +188,24 @@ class fillVars(varsShare):
rootparam=re_res.group(1)
# check root for /dev/sd view
if re.match("^\/dev\/[a-z]+.*$", rootparam):
- return rootparam
+ return getUdevDeviceInfo(
+ name=rootparam.strip()).get('DEVNAME','')
# check root set by uuid
- uuidpath = '/dev/disk/by-uuid'
- if os.access(uuidpath,os.R_OK):
- uuidDevs = filter(path.islink,
- map(lambda x: path.join(uuidpath,x),
- os.listdir(uuidpath)))
- mapUuidDev = dict(map(lambda x:(path.basename(x),
- path.normpath(path.join(uuidpath,
- os.readlink(x)))), uuidDevs))
- else:
- mapUuidDev = {}
if re.match("^UUID=.*$",rootparam):
- uuid = rootparam[5:]
- if uuid in mapUuidDev:
- return mapUuidDev[uuid]
+ uuid = rootparam[5:].strip("\"'")
+ blkidProcess = process('/sbin/blkid','-c','/dev/null','-U',
+ uuid)
+ if blkidProcess.success():
+ return getUdevDeviceInfo(
+ name=blkidProcess.read().strip()).get('DEVNAME','')
+ # check root set by label
+ if re.match("^LABEL=.*$",rootparam):
+ uuid = rootparam[6:].strip("\"'")
+ blkidProcess = process('/sbin/blkid','-c','/dev/null','-L',
+ uuid)
+ if blkidProcess.success():
+ return getUdevDeviceInfo(
+ name=blkidProcess.read().strip()).get('DEVNAME','')
# get device mounted to root
dfLines = self._runos("LANG=C df /")
if not dfLines:
@@ -388,23 +392,25 @@ class fillVars(varsShare):
xorg_conf = '/etc/X11/xorg.conf'
# Try analize Xorg.{DISPLAY}.log
display = os.environ.get('DISPLAY')
- list_avialable_drivers = \
- getAvailableX11Drivers(prefix=self.Get('cl_chroot_path'))
- if display and list_avialable_drivers:
+ list_available_drivers = \
+ getAvailableVideo(prefix=self.Get('cl_chroot_path'))
+ if display and list_available_drivers:
reDriver = re.compile('|'.join(map(lambda x: "%s_drv.so"%x,
- list_avialable_drivers)))
- display_number = re.search(r':(\d+)\..*', display)
+ list_available_drivers)))
+ display_number = re.search(r':(\d+)(\..*)?', display)
+ reDriverName = re.compile(r'([^/]+)_drv.so')
if display_number:
xorg_log_file = '/var/log/Xorg.%s.log' % \
display_number.group(1)
if path.exists(xorg_log_file):
- matchStrs = [i for i in open(xorg_log_file)
- if "drv" in i and reDriver.search(i)]
+ matchStrs = \
+ map(lambda x:x.group(1),
+ filter(lambda x:x,
+ map(reDriverName.search,
+ filter(lambda x:"drv" in x and reDriver.search(x),
+ readLinesFile(xorg_log_file)))))
if matchStrs:
- resDriver = re.search(r'([^/]+)_drv.so',
- matchStrs[-1])
- if resDriver:
- return resDriver.group(1)
+ return matchStrs[-1]
# analize /etc/X11/xorg.conf
if path.exists(xorg_conf):
@@ -413,19 +419,15 @@ class fillVars(varsShare):
if matchSect:
resDriver = re.search(r'^\S*Driver\s*"([^"]+)"',
matchSect.group(0),re.S)
- if resDriver and resDriver.group(1) in list_avialable_drivers:
+ if resDriver and resDriver.group(1) in list_available_drivers:
return resDriver.group(1)
videoVal = self.getValueFromCmdLine("calculate","video")
videoVal = {'i915':'intel'}.get(videoVal,videoVal)
if not isPkgInstalled('xorg-server') or \
- videoVal in list_avialable_drivers:
+ videoVal in list_available_drivers:
return videoVal
- workedModules = map(lambda x:x[0],
- filter(lambda x:x[1].isdigit() and int(x[1])>0,
- map(lambda x:x.split()[:3:2],
- open('/proc/modules','r'))))
- return self.getVideoByDefault(list_avialable_drivers)
+ return self.getVideoByDefault(list_available_drivers)
def get_os_x11_height(self):
"""Get screen height in pixeles"""
@@ -559,19 +561,7 @@ class fillVars(varsShare):
def get_cl_kernel_uid(self):
"""Get UID of symlink kernel, initramfs and System.map"""
- uuidpath = '/dev/disk/by-uuid'
- if not os.access(uuidpath,os.R_OK):
- return ""
- uuidDevs = filter(path.islink,map(lambda x: path.join(uuidpath,x),
- os.listdir(uuidpath)))
- mapDevUuid = dict(map(lambda x:(path.normpath(path.join(uuidpath,
- os.readlink(x))),
- path.basename(x)),
- uuidDevs))
- if self.Get('os_root_dev') in mapDevUuid:
- return mapDevUuid[self.Get('os_root_dev')][:8]
- else:
- return ""
+ return self.getKernelUid(self.Get('os_root_dev'))
def get_cl_chroot_status(self):
"""Detect chroot mode by mtab content"""
diff --git pym/cl_opt.py pym/cl_opt.py
index 833677e..52b414a 100644
--- pym/cl_opt.py
+++ pym/cl_opt.py
@@ -282,7 +282,7 @@ class opt(optparse.OptionParser):
}]
variable_view = \
[{'shortOption':"v",
- 'longOption':"vars",
+ 'longOption':"show-variables",
'action':'count',
'help':_("print variables, if the two options is verbose "
"(added print hidden variables)")
@@ -290,11 +290,11 @@ class opt(optparse.OptionParser):
{'longOption':"filter",
'optVal':"FILTER",
'help':_("filtered variables (as a regular expression is used *), \
-is used in conjunction with the options '-v --vars'")
+is used in conjunction with the options '-v --show-variables'")
},
{'longOption':"xml",
'help':_("output variables in the format of XML, \
-is used in conjunction with the option '-v --vars'")
+is used in conjunction with the option '-v --show-variables'")
}]
variable_control = variable_set + variable_view
diff --git pym/cl_utils.py pym/cl_utils.py
index 5d4d51a..d2e6231 100644
--- pym/cl_utils.py
+++ pym/cl_utils.py
@@ -221,7 +221,10 @@ class process:
else:
stdin=kwarg["stdin"].getStdout
self.stdout = kwarg.get("stdout",PIPE)
- self.envdict = kwarg.get("envdict",None)
+ self.envdict = kwarg.get("envdict",{})
+ if "lang" in kwarg:
+ self.envdict["LANG"] = kwarg.get('lang')
+ self.langc = "langc" in kwarg
self.stderr = kwarg.get("stderr",PIPE)
self.command = [command] + list(params)
@@ -364,7 +367,7 @@ class processProgress(process):
pass
def runOsCommand(cmd,in_str=None, env_dict=None):
- """Выполняет внешнюю программу
+ """Run system command
Параметры:
cmd внешняя программа
@@ -392,30 +395,17 @@ def runOsCommand(cmd,in_str=None, env_dict=None):
return retcode, res
def genpassword(passlen=9):
- '''Вернуть случайный набор символов указанной длины
-
- Параметры:
- passlen длина пароля который нужно сгенерировать
-
- Возвращаемые параметры:
- Сгенерированный пароль указанной длины
- '''
- res=''.join([choice(string.ascii_letters+string.digits)\
- for i in xrange(passlen)])
- return res
+ """Return random charset specified lenght (passlen)"""
+ return ''.join(map(lambda x:choice(string.ascii_letters+string.digits),
+ xrange(0,passlen)))
def getpathenv():
- """Вернуть пути для запуска утилит"""
- bindir=['/sbin','/bin','/usr/sbin','/usr/bin']
+ """Return path for run utilities"""
+ bindir=set(filter(path.exists,
+ ['/sbin','/bin','/usr/sbin','/usr/bin']))
env=os.environ
- if env and env.has_key('PATH'):
- lpath=env['PATH'].split(":")
- npath=[]
- for dirname in bindir:
- if path.exists(dirname) and dirname not in lpath:
- npath.append(dirname)
- lpath=npath+lpath
- return ":".join(lpath)
+ envPath = set(env.get('PATH','').split(":")) | bindir
+ return ":".join(envPath)
class MultiReplace:
"""MultiReplace function object
@@ -627,7 +617,6 @@ def isFstabMount(pathname,mapDevUuid={},listFstab=[]):
absPath = "swap"
else:
absPath = path.abspath(pathname)
- devuuid = '/dev/disk/by-uuid'
if not mapDevUuid:
mapDevUuid.update(getUUIDDict())
# convert fstab to
@@ -649,6 +638,69 @@ def isFstabMount(pathname,mapDevUuid={},listFstab=[]):
filter(lambda x: absPath in x and x[1] != "none",
listFstab),[""]))[0]
+class SingletonParam(type):
+ def __init__(cls, name, bases, dict):
+ super(SingletonParam, cls).__init__(name, bases, dict)
+ cls.instance = {}
+
+ def __call__(cls,*args,**kw):
+ keyarg = args[0] if args else ""
+ if not keyarg in cls.instance:
+ cls.instance[keyarg] = super(SingletonParam, cls).__call__(*args, **kw)
+ return cls.instance[keyarg]
+
+class FStab(object):
+ """Data reader for fstab"""
+ __metaclass__ = SingletonParam
+ fstab_file = '/etc/fstab'
+ NAME, DIR, TYPE, OPTS, FREQ, PASSNO = range(0,6)
+
+ def __init__(self,fstab_file=None):
+ if fstab_file:
+ self.fstab_file = fstab_file
+ self.cache = []
+ self.rotateCache = []
+ self.dictUUID = getUUIDDict()
+ self.rebuildCache()
+
+ def rebuildCache(self):
+ """Rebuild cache from fstab file"""
+ self.cache = \
+ map(lambda x:map(lambda y:y.strip(),x.split()),
+ filter(lambda x:x and not x.lstrip().startswith("#"),
+ open(self.fstab_file,'r').read().split('\n')))
+ for data in self.cache:
+ convertDev = lambda x: path.realpath(x) if x.startswith('/') else x
+ data[0] = getUdevDeviceInfo(
+ name=convertDev(self.dictUUID.get(data[0],data[0]))
+ ).get('DEVNAME','')
+ data[1] = data[1] if data[2] != "swap" else "swap"
+ self.rotateCache = zip(*self.cache)
+
+ def getBy(self,what=DIR,where=NAME,eq=None,noteq=None,allentry=False):
+ """Get data from fstab"""
+ if not eq is None:
+ filterfunc = lambda x: x[where] == eq
+ else:
+ filterfunc = lambda x: x[where] != noteq
+ res = map(lambda x:x[what],filter(filterfunc,self.cache))
+ if allentry:
+ return res
+ else:
+ return "" if not res else res[-1]
+
+ def getFields(self,*fields):
+ """Get all data by specifie fields"""
+ return zip(*reduce(lambda x,y:x+[self.rotateCache[y]],fields,[]))
+
+ def isExists(self,what=DIR,eq=None,noteq=None):
+ """Field with condition exist in fstab"""
+ if not eq is None:
+ filterfunc = lambda x: x[what] == eq
+ else:
+ filterfunc = lambda x: x[what] != noteq
+ return bool(filter(filterfunc,self.cache))
+
def isMount(pathname):
"""В случае монтирования директории выдает другой примонтированный путь"""
absPath = path.abspath(pathname)
@@ -805,6 +857,27 @@ def listDirectory(directory,fullPath=False):
pass
return []
+def getInstalledVideo(prefix="/"):
+ """Get installed video drivers"""
+ x11Drivers = path.join(prefix,"usr/lib/xorg/modules/drivers")
+ return map(lambda x:x[:-7],
+ filter(lambda x:x.endswith('_drv.so'),
+ listDirectory(x11Drivers)))
+
+def getDistfilesVideo(prefix="/"):
+ """Get video drivers from distfiles"""
+ distFiles = path.join(prefix,"usr/portage/distfiles")
+ return list(set(
+ map(lambda x:'fglrx' if x.startswith('ati-driver') else "nvidia",
+ filter(lambda x:x.startswith('ati-driver-installer') or
+ x.startswith('NVIDIA-Linux'),
+ listDirectory(distFiles)))))
+
+def getAvailableVideo(prefix="/"):
+ """Get available video drivers (installed and maybe installed)"""
+ return list(set(getInstalledVideo(prefix=prefix) + \
+ getDistfilesVideo(prefix=prefix)))
+
def readLinesFile(filename):
"""Read file by line"""
try:
@@ -823,38 +896,34 @@ def readFile(filename):
return open(filename,'r').read()
except (OSError,IOError):
pass
- finally:
- return ""
+ return ""
def getUUIDDict(revers=False):
"""Get dict UUID -> dev"""
- devuuid = '/dev/disk/by-uuid'
- datafunc = lambda x,y: (x,y)
+ blkidProcess = process("/sbin/blkid","-s","UUID","-c","/dev/null")
if revers:
datafunc = lambda x,y: (y,x)
+ else:
+ datafunc = lambda x,y: (x,y)
+ DEV,UUID = 0,1
+ reSplit = re.compile('^([^:]+):.*UUID="([^"]+)"',re.S)
return dict(
- map(lambda x:datafunc("UUID=%s"%path.basename(x),
- path.normpath(path.join(devuuid,os.readlink(x)))),
- filter(path.islink,
- listDirectory(devuuid,fullPath=True))))
+ map(lambda x:datafunc("UUID=%s"%x[UUID],
+ getUdevDeviceInfo(name=x[DEV]).get('DEVNAME',x[DEV])),
+ map(lambda x:x.groups(),
+ filter(lambda x:x,
+ map(reSplit.search,
+ blkidProcess)))))
def detectDeviceForPartition(dev):
- """Detect parent device for partition by /sys/block (sysfs)"""
- reDeviceSplit = re.compile("^(.*/)?(.*?)(\d+)$")
- device = map(lambda x:filter(lambda x:x in dev,
- x[1]),
- os.walk('/sys/block'))
- if device:
- device = device[0]
- parentdevices = \
- filter(lambda x: path.split(dev)[-1] in \
- reduce(lambda y,z:y+z[1],
- os.walk(path.join('/sys/block',x)),[]), device)
- if parentdevices:
- return parentdevices[0]
- res = reDeviceSplit.search(dev)
- if res:
- return res.groups()[1]
+ """Detect parent device for partition by udev and return property"""
+ prop = getUdevDeviceInfo(name=dev)
+ if prop.get('DEVTYPE','') != 'partition':
+ return ''
+ parentpath = path.dirname(prop.get('DEVPATH',''))
+ if parentpath:
+ devProp = getUdevDeviceInfo(path=parentpath)
+ return devProp.get('DEVNAME','')
return None
def getProgPath(progname):
@@ -872,7 +941,7 @@ def getProgPath(progname):
return False
def checkUtils(*utils):
- """Check utils and exit if it not found"""
+ """Check utils, exit if it not found and return fullpath"""
retval = []
for util in utils:
utilPath = getProgPath(util)
@@ -965,8 +1034,97 @@ def getSquashList():
return map(lambda x:{"lzma":"xz"}.get(x,x),
list(set(usesSquashFs) & wantMethod))
+def addUdevInfo(prop):
+ """Function for compatibility with util-linux with version less
+ that 2.18
+ TODO: need realization, now only stub
+
+ ID_PART_TABLE_TYPE
+ ID_PART_ENTRY_TYPE
+ ID_PART_ENTRY_NUMBER
+ """
+ return prop
+
+def getUdevDeviceInfo(path="",name=""):
+ """Get device info by syspath of name"""
+ udevadmCmd = getProgPath('/sbin/udevadm')
+ typeQuery = "--path" if path else "--name"
+ value = path if path else name
+ return addUdevInfo(dict(
+ filter(lambda x:x[0],
+ map(lambda x:x.partition("=")[0::2],
+ process(udevadmCmd,"info","--query","property",
+ typeQuery,value).read().split("\n")))))
+
+def countPartitions(devname):
+ """Count partition for specified device"""
+ syspath = getUdevDeviceInfo(name=devname).get('DEVPATH','')
+ if not syspath:
+ return 0
+ deviceName = path.basename(syspath)
+ if not syspath.startswith("/sys"):
+ syspath = pathJoin("/sys",syspath)
+ return len(filter(lambda x:x.startswith(deviceName),
+ listDirectory(syspath)))
+
+def getLvmGroups():
+ """Get LVM groups"""
+ pvdisplayCmd = getProgPath('/sbin/pvdisplay')
+ pvdata = process(pvdisplayCmd,"-C","-o", "vg_name","--noh")
+ return filter(lambda x:x,pvdata.read().split())
+
+def getLvmPartitions(vg_name,lv_name,cache=[]):
+ """Get lvm partitions"""
+ if not cache:
+ pvdisplayCmd = getProgPath('/sbin/pvdisplay')
+ pvdata = process(pvdisplayCmd,"-C","-o",
+ "vg_name,lv_name,pv_name","--noh")
+ if pvdata.success():
+ cache.extend(
+ filter(lambda x:x and len(x)==3,
+ map(lambda x:x.split(),
+ pvdata.read().split('\n'))))
+ if cache:
+ res = map(lambda x:x[2],
+ filter(lambda x:x[0]==vg_name and x[1]==lv_name,cache))
+ if res:
+ return res
+ return []
+
+def getPartitionDevice(syspath):
+ """Get real parent device by partition,lvm,mdraid"""
+ prop = getUdevDeviceInfo(path=syspath)
+ # real device
+ if prop.get('ID_TYPE',"") == "disk" and \
+ prop.get('DEVTYPE',"") == "disk":
+ return prop.get('DEVNAME',"")
+ # partition
+ if prop.get('DEVTYPE') == "partition":
+ return getPartitionDevice(path.dirname(syspath))
+ # md raid
+ if prop.get('MD_LEVEL',"").startswith("raid"):
+ if not syspath.startswith('/sys'):
+ syspathpath = pathJoin('/sys',syspath)
+ syspath = pathJoin(syspath,"md")
+ for rd in filter(lambda x:path.basename(x).startswith('rd'),
+ listDirectory(syspath,fullPath=True)):
+ rdBlockPath = path.join(rd,"block")
+ if path.exists(rdBlockPath):
+ return getPartitionDevice(path.realpath(rdBlockPath))
+ else:
+ return ""
+ # lvm
+ if prop.get('DM_LV_NAME',"") != "":
+ parts = getLvmPartitions(prop.get('DM_VG_NAME',''),
+ prop.get('DM_LV_NAME',''))
+ if parts:
+ propPartLvm = getUdevDeviceInfo(name=parts[0])
+ if 'DEVPATH' in propPartLvm:
+ return getPartitionDevice(propPartLvm['DEVPATH'])
+ return ""
+
def getAvailableX11Drivers(prefix="/"):
- """Get available x11 drivers"""
+ """Get available x11 drivers (Depricated Function)"""
xorg_modules_dir = path.join(prefix,'usr/lib/xorg/modules/drivers')
return map(lambda x: x[:-7],
filter(lambda x:x.endswith('_drv.so'),
@@ -1002,32 +1160,149 @@ def lspci(filtername=None,shortInfo=False):
'name':sfunc(device[3])}
return retData
-def getUdevDeviceInfo(path="",name=""):
- """Get device info by syspath of name"""
- udevadmCmd = getProgPath('/sbin/udevadm')
- typeQuery = "--path" if path else "--name"
- value = path if path else name
- return dict(
- filter(lambda x:x[0],
- map(lambda x:x.partition("=")[0::2],
- process(udevadmCmd,"info","--query","property",
- typeQuery,value).read().split("\n"))))
-
def getPartitionSize(dev):
"""Get partition size"""
SECTORSIZE=512
- syspath = getUdevDeviceInfo(name=dev).get('DEVPATH','')
- if syspath:
- sizeFile = pathJoin("/sys",syspath,"size")
- if path.exists(sizeFile):
- size = float(open(sizeFile,'r').read().strip())*SECTORSIZE
- suffix = ((1024**0,""),
- (1024**1,"KiB"),
- (1024**2,"MiB"),
- (1024**3,"GiB"),
- (1024**4,"TiB"),
- (1024**5,"PiB"))
- suffix = filter(lambda x:size >=x[0],suffix)[-1]
- if suffix:
- return "%.1f %s"%(size/suffix[0],suffix[1])
+ sizeFile = pathJoin(dev,"size")
+ if path.exists(sizeFile):
+ size = float(open(sizeFile,'r').read().strip())*SECTORSIZE
+ suffix = ((1024**0,""),
+ (1024**1,"KiB"),
+ (1024**2,"MiB"),
+ (1024**3,"GiB"),
+ (1024**4,"TiB"),
+ (1024**5,"PiB"))
+ suffix = filter(lambda x:size >=x[0],suffix)
+ if suffix:
+ suffix = suffix[-1]
+ return "%.1f %s"%(size/suffix[0],suffix[1])
return "0"
+
+def getDeviceType(syspath):
+ """Get device type (disk,partition,lvm,raid)"""
+ prop = getUdevDeviceInfo(path=syspath)
+ # real device
+ if prop.get('ID_CDROM',""):
+ return "cdrom"
+ if prop.get('ID_TYPE',"") == "disk" and \
+ prop.get('DEVTYPE',"") == "disk":
+ return "disk"
+ # partition
+ if prop.get('DEVTYPE') == "partition":
+ return getDeviceType(path.dirname(syspath))+"-partition"
+ # md raid
+ if prop.get('MD_LEVEL',"").startswith("raid"):
+ if not syspath.startswith('/sys'):
+ syspathpath = pathJoin('/sys',syspath)
+ syspath = pathJoin(syspath,"md")
+ for rd in filter(lambda x:path.basename(x).startswith('rd'),
+ listDirectory(syspath,fullPath=True)):
+ rdBlockPath = path.join(rd,"block")
+ if path.exists(rdBlockPath):
+ return getDeviceType(path.realpath(rdBlockPath))+"-raid"
+ else:
+ return "loop"
+ # lvm
+ if prop.get('DM_LV_NAME',"") != "":
+ parts = getLvmPartitions(prop.get('DM_VG_NAME',''),
+ prop.get('DM_LV_NAME',''))
+ if parts:
+ propPartLvm = getUdevDeviceInfo(name=parts[0])
+ if 'DEVPATH' in propPartLvm:
+ return getDeviceType(propPartLvm['DEVPATH'])+"-lvm"
+ return "loop"
+
+def getRaidPartitions(raidpath):
+ """Get raid partitions"""
+ prop = getUdevDeviceInfo(path=raidpath)
+ raidParts = []
+ if prop.get('MD_LEVEL',"").startswith("raid"):
+ if not raidpath.startswith('/sys'):
+ raidpath = pathJoin('/sys',raidpath)
+ raidpath = pathJoin(raidpath,"md")
+ for rd in filter(lambda x:path.basename(x).startswith('rd'),
+ listDirectory(raidpath,fullPath=True)):
+ rdpath = path.join(raidpath,rd,"block")
+ if path.exists(rdpath):
+ raidParts.append(
+ getUdevDeviceInfo(path=path.realpath(rdpath)).get(
+ "DEVNAME",''))
+ return filter(lambda x:x,raidParts)
+
+
+def getPartitionType(prop):
+ """Get type of dos part table (primary,extended or logical)"""
+ if prop.get('ID_PART_TABLE_TYPE') == 'dos':
+ partId = prop.get('ID_PART_ENTRY_TYPE','')
+ partNumber = prop.get('ID_PART_ENTRY_NUMBER','')
+ if partId and partNumber:
+ if partId == "0x5":
+ return "extended"
+ elif int(partNumber)>4:
+ return "logical"
+ else:
+ return "primary"
+ return prop.get('ID_PART_TABLE_TYPE','')
+
+def detectBuild(pathname,dictInfo):
+ """Detect build by root passwd 'root'"""
+ shadowPath = pathJoin(pathname,'/etc/shadow')
+ if r"root:$1$JMvNh5xg$VnV1DyJdTcwuZ0hp5YiJG0:14349:0:::::" in \
+ readFile(shadowPath):
+ dictInfo['type'] = ' assemble'
+ elif path.exists(pathJoin(pathname,"delta")) and \
+ path.exists(pathJoin(pathname,"workspace")):
+ dictInfo['type'] = " builder"
+ issue = readFile(pathJoin(pathname,'etc/gentoo-release'))
+ if "Server" in issue:
+ if "Scratch" in issue:
+ dictInfo['name'] = "CSS"
+ else:
+ dictInfo['name'] = "CDS"
+ elif "Desktop" in issue:
+ if "XFCE" in issue:
+ dictInfo['name'] = "CLDX"
+ elif "KDE" in issue:
+ dictInfo['name'] = "CLD"
+ elif "GNOME" in issue:
+ dictInfo['name'] = "CLDG"
+ elif "Scratch" in issue:
+ dictInfo['name'] = "CLS"
+ else:
+ dictInfo['type'] = ''
+ return dictInfo
+
+def getOsProberHash(getContentFunc=None):
+ """Get partition content by os-prober"""
+ os_prober = getProgPath('/usr/bin/os-prober')
+ if os_prober:
+ DEV,LONG,SHORT,TYPE = 0,1,2,3
+ osProberList = \
+ map(lambda x:[getUdevDeviceInfo(name=x[DEV]).get('DEVNAME',''),
+ x[LONG],x[SHORT],x[TYPE]],
+ filter(lambda x:len(x)>=4,
+ map(lambda x:x.split(":"),
+ process(os_prober))))
+ for osRecord in osProberList:
+ if "Gentoo" in osRecord[SHORT] and getContentFunc:
+ osDescr = getContentFunc(osRecord[DEV],addFunc=detectBuild)
+ if "name" in osDescr and "march" in osDescr and \
+ "build" in osDescr and "ver" in osDescr and \
+ (osDescr["ver"] != "0" or osDescr["build"]):
+ if osDescr['build']:
+ osDescr['build'] = "-%s"%osDescr['build']
+ else:
+ osDescr['build'] = "-%s"%osDescr['ver']
+ osRecord[SHORT] = \
+ "{name}-{march}{build}{type}".format(**osDescr)
+ else:
+ osRecord[SHORT] = "Gentoo"
+ elif "Gentoo" in osRecord[SHORT] and "Calculate" in osRecord[LONG]:
+ osRecord[SHORT] = "Calculate"
+ osProberHash = \
+ dict(
+ map(lambda x:(x[DEV],x[SHORT]),
+ osProberList))
+ else:
+ osProberHash = {}
+ return osProberHash
diff --git pym/cl_vars_share.py pym/cl_vars_share.py
index 755ae89..29274c5 100644
--- pym/cl_vars_share.py
+++ pym/cl_vars_share.py
@@ -16,7 +16,7 @@
import os
import sys
-from cl_utils import getpathenv, runOsCommand, typeFile
+from cl_utils import getpathenv, runOsCommand, typeFile,process
import re
from os import path, R_OK
try:
@@ -528,6 +528,16 @@ class varsShare:
if reRes:
return reRes[0]
+ def selectVar(self,selField,where="",eq=""):
+ """Select value from matrix variables
+
+ Example:
+ selectVar("os_disk_dev",where="os_disk_mount",eq="/")"""
+ res = filter(lambda x:x[1] == eq,
+ zip(self.Get(selField),
+ self.Get(where))) or [("","")]
+ return res[0][0]
+
def getVersionFromGentooFiles(self,systemroot):
"""Get version from gentoo files"""
gentooFile = path.join(systemroot,"etc/gentoo-release")
@@ -582,16 +592,22 @@ class varsShare:
filter(lambda x:x[1].isdigit() and int(x[1])>0,
map(lambda x:x.split()[:3:2],
open('/proc/modules','r'))))
- if "nvidia" in drivers_list:
- defaultNvidia = "nvidia"
- elif "nouveau" in workedModules:
+ if "nouveau" in workedModules:
defaultNvidia = "nouveau"
+ elif "nvidia" in drivers_list:
+ defaultNvidia = "nvidia"
else:
defaultNvidia = "nv"
+ if "radeon" in workedModules:
+ defaultAti = "radeon"
+ elif "fglrx" in drivers_list:
+ defaultAti = "fglrx"
+ else:
+ defaultAti = "radeon"
defaultDriver = {
'vesa':'vesa',
'nvidia':defaultNvidia,
- 'ati':'fglrx' if "fglrx" in drivers_list else "radeon",
+ 'ati':defaultAti,
'intel':'intel',
'via':'via',
'vmware':'vmware'}
@@ -601,3 +617,13 @@ class varsShare:
return defaultDriver[hr_video]
else:
return "vesa"
+
+ def getKernelUid(self,device):
+ """Get Kernel UID by UUID of device"""
+ blkidProcess = process('/sbin/blkid','-c','/dev/null','-s','UUID',
+ '-o','value',device)
+ res = blkidProcess.read().strip()
+ if res:
+ return res[:8]
+ else:
+ return "no_uid"

@ -2,6 +2,12 @@
# Copyright 1999-2011 Gentoo Foundation; Distributed under the GPL v2
# $Header: $
*calculate-utilities-2.2.19-r7 (26 Jul 2011)
26 Jul 2011; Mike Hiretsky (mhiretskiy) <mh@calculate.ru>
+calculate-utilities-2.2.19-r7.ebuild:
Update for install and lib
*calculate-utilities-2.2.19-r6 (25 Jul 2011)
25 Jul 2011; Mike Hiretsky (mhiretskiy) <mh@calculate.ru>

@ -9,6 +9,7 @@ EBUILD calculate-utilities-2.2.19-r3.ebuild 880 RMD160 263f3de7fbf855f7a95233fcf
EBUILD calculate-utilities-2.2.19-r4.ebuild 880 RMD160 83485c42c30986ffef19cb80a1eff0be4cbbb88e SHA1 956b0083676c70e9b148d86efef0ca66d391cfc9 SHA256 96f15b3a44799a2634234ac467178d5749f2c5e2bf711f997cc56f3f8477955d
EBUILD calculate-utilities-2.2.19-r5.ebuild 880 RMD160 8f303ba90fe206f3c036bf3e1648d39767c35ca0 SHA1 4d1d2327077e9112c78b43320acae734e85711e4 SHA256 bc0d62b93d4f214a9eb7b3d10e0e247809e4bb0c528846036f0784d18a97e49f
EBUILD calculate-utilities-2.2.19-r6.ebuild 880 RMD160 3c01a3a3aff9230589c70ab2367d6c63f2a7e745 SHA1 89773dad25ce7e58705f979ce3bc2dfd7a5e726a SHA256 64ca5ae1dfdce7fe42a001a492fdcec0b4c3326acb0f12a4d288f46d89bdb86f
EBUILD calculate-utilities-2.2.19-r7.ebuild 880 RMD160 be5b601ad2b663467d9b5076d9ef8277ebbe86a4 SHA1 acd4974cc618785598619b9f7bfcbeccde8fe1fc SHA256 919c6618eb85f6ac6b34b3b928d4ea96942d0542c5adf2fd196f2a1517517299
EBUILD calculate-utilities-2.2.19.ebuild 862 RMD160 3c63622728c5486252332890f946fb29bc5af5ca SHA1 1d923fbbb9959dbfed1fbe3f08e530e2e365d940 SHA256 881356df9ab4e47bff03ca9eed44656b38702b1f60055c4b1c446ba49e7f4040
EBUILD calculate-utilities-2.2.9999.ebuild 840 RMD160 0c7324a9ed480118ac19f62b162c9ee62c25f964 SHA1 7dadab1430ed147334ed7e9b4fcc86dc99e25d56 SHA256 f3ee28f9f765e7302c83eb4a15a09bdf066f09e6b40e34f6d52157a946df5e66
MISC ChangeLog 16722 RMD160 b77e260456b17bf2bcc6eff4418050475b34edc5 SHA1 f07562e301566bafb2b59443868864afbf01b2a3 SHA256 6b5cabbcf9c01ab419eb07d7c33af7583ec10bd84b63d3ce6ab0675d4f22010c
MISC ChangeLog 16899 RMD160 a37707a5e25ce85885494d0368dd74112ee408e3 SHA1 b46877c9bb4610895e35f02dd05274c07847939a SHA256 1f32f8db8be1e7628c950ba47411375e54fc35cdb7c3e3c207433ad82b53a69a

@ -0,0 +1,37 @@
# Copyright 1999-2011 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_client
cl_desktop
cl_installgui
cl_server
"
RDEPEND="${RDEPEND}
=sys-apps/calculate-install-2.2.19-r3
=sys-apps/calculate-templates-2.2.19-r4
=sys-apps/calculate-lib-2.2.19-r5
=sys-apps/calculate-i18n-2.2.19-r2
cl_assemble? ( =sys-apps/calculate-assemble-2.2.19-r1 )
cl_builder? ( =sys-apps/calculate-builder-2.2.19-r1 )
cl_client? ( =sys-apps/calculate-client-2.2.19 )
cl_desktop? ( =sys-apps/calculate-desktop-2.2.19 )
cl_installgui? ( =app-misc/calculate-install-gui-2.2.19 )
cl_server? ( =sys-apps/calculate-server-2.1.14-r6 )
"
Loading…
Cancel
Save