Исправления для утилит Calculate

atratsevskiy
Mike Khiretskiy 10 years ago
parent a07373e4a9
commit 90fa6bc06c

@ -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/calculate3/${PN}/${P}.tar.bz2
http://mirror.yandex.ru/calculate/calculate3/${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="3"
KEYWORDS="x86 amd64"
IUSE="pxe minimal"
DEPEND="~sys-apps/calculate-core-3.2.3
!<sys-apps/calculate-install-2.2.29
app-portage/layman
>=virtual/udev-197
!app-misc/livecd-tools
sys-apps/iproute2[-minimal]
!minimal? ( sys-boot/grub
sys-apps/gptfdisk
>=sys-apps/util-linux-2.19.1
sys-fs/dosfstools
sys-fs/squashfs-tools
sys-block/parted )
pxe? ( sys-apps/calculate-server
net-ftp/tftp-hpa
net-misc/dhcp
net-fs/nfs-utils )"
src_unpack() {
unpack "${A}"
cd "${S}"
# apply revision changes
epatch "${FILESDIR}/calculate-install-3.2.3-r8.patch"
}

@ -0,0 +1,258 @@
diff --git data/calculate data/calculate
index 45f3d71..fcd0433 100644
--- data/calculate
+++ data/calculate
@@ -156,7 +156,7 @@ start() {
stop() {
local roottype=`variable_value main.os_root_type`
- if [[ $roottype == "hdd" ]] && rc-config list boot | grep -q "calculate "
+ if [[ $roottype == "hdd" ]] && rc-config list boot | grep -q -e "calculate " -e "calculate$"
then
rc-update del calculate boot
local distdir="/usr/portage/distfiles"
diff --git pym/install/migrate_users.py pym/install/migrate_users.py
index d00a5c5..f862eb2 100644
--- pym/install/migrate_users.py
+++ pym/install/migrate_users.py
@@ -401,11 +401,11 @@ class migrate:
notWrite = lambda x: not os.access(x, os.W_OK)
filesNotRead = filter(notRead,checkThisFiles)
if filesNotRead:
- raise MigrationError(_("Failed to read files") + ": " +\
+ raise MigrationError(_("Failed to read files") + _(": ") +
", ".join(filesNotRead))
filesNotWrite = filter(notWrite,checkNewFiles)
if filesNotWrite:
- raise MigrationError(_("Failed to write to files") + ": " +\
+ raise MigrationError(_("Failed to write to files") + _(": ") +
", ".join(filesNotWrite))
# Check permissions backup files
checkNewBackupFiles = map(lambda x:pathJoin(self.prefixNewSystem,x+"-"),
@@ -415,7 +415,7 @@ class migrate:
not os.access(os.path.dirname(x), os.W_OK))
filesNotWrite = filter(notWriteBackup, checkNewBackupFiles)
if filesNotWrite:
- raise MigrationError(_("Failed to write to files") + ": " +\
+ raise MigrationError(_("Failed to write to files") + _(": ") +
", ".join(filesNotWrite))
return True
diff --git pym/install/variables/autopartition.py pym/install/variables/autopartition.py
index 1a5e7d4..8504910 100644
--- pym/install/variables/autopartition.py
+++ pym/install/variables/autopartition.py
@@ -39,16 +39,18 @@ setLocalTranslate('cl_install3',sys.modules[__name__])
class SizeHelper:
+ default_size = Sizes.M
+
def set(self,value):
# convert table from value to MB
- sizeMap = {'kB':1/1000.0,
- 'K':1/1024.0,
- 'M':1.0,
- 'Mb':1000/1024.0,
- 'G':1024,
- 'Gb':1000,
- 'T':1024*1024,
- 'Tb':1000*1000}
+ sizeMap = {'kB':Sizes.kB,
+ 'K':Sizes.K,
+ 'M':Sizes.M,
+ 'Mb':Sizes.Mb,
+ 'G':Sizes.G,
+ 'Gb':Sizes.Gb,
+ 'T':Sizes.T,
+ 'Tb':Sizes.Tb}
value = value.strip()
reSizeValue = re.compile('^(\d+)\s*(%s)?'%"|".join(sizeMap.keys()))
res = reSizeValue.search(value)
@@ -57,7 +59,9 @@ class SizeHelper:
intValue = int(res.group(1))
if res.group(2):
intValue = intValue * sizeMap[res.group(2)]
- return str(int(intValue))
+ else:
+ intValue = intValue * self.default_size
+ return str(intValue)
MINROOTSIZE=7*Sizes.G
@@ -377,6 +381,7 @@ class VariableClAutopartitionSwapSize(SizeHelper,AutopartitionHelper,Variable):
"""
Swap size
"""
+ type = "size-m"
opt = ["--swap-size"]
metavalue = "SIZE"
untrusted = True
@@ -386,13 +391,13 @@ class VariableClAutopartitionSwapSize(SizeHelper,AutopartitionHelper,Variable):
self.help = _("set the swap partition size for autopartition")
def get(self):
- size = int(self.Get('hr_memory_size')) / Sizes.M
- if size < Sizes.K:
- size = Sizes.K
+ size = int(self.Get('hr_memory_size'))
+ if size < Sizes.G:
+ size = Sizes.G
return str(size)
def humanReadable(self):
- return humanreadableSize(int(self.Get())*Sizes.M)
+ return humanreadableSize(int(self.Get()))
class VariableClAutopartitionDevice(AutopartitionHelper,Variable):
"""
@@ -554,10 +559,23 @@ class VariableClAutopartitionScheme(AutopartitionHelper,Variable,AutoPartition):
raise VariableError(
_("The bios_grub partition need the partition table to be GPT"))
+class VariableClAutopartitionRootSizeDefault(Variable):
+ """
+ Размер root раздела при авторазметке
+ """
+ value = str(Sizes.G*15)
+
+class VariableClAutopartitionRootSizeMin(Variable):
+ """
+ Минимальнй размер root раздела
+ """
+ value = str(Sizes.G*7)
+
class VariableClAutopartitionRootSize(SizeHelper,AutopartitionHelper,Variable):
"""
Root partition size for autopartition
"""
+ type = "size-m"
opt = ["--root-size"]
metavalue = "SIZE"
untrusted = True
@@ -567,25 +585,24 @@ class VariableClAutopartitionRootSize(SizeHelper,AutopartitionHelper,Variable):
self.help = _("set the root partition size for autopartition")
def get(self):
- if self.Get('os_install_linux_system') == 'server':
- size = 1024*20 # in M
- else:
- size = 1024*10 # in M
- deviceSize = self.Get('cl_autopartition_device_size')
- if Sizes().from_M(size) >= deviceSize:
- size = max(Sizes().to_M(deviceSize),Sizes().to_M(MINROOTSIZE))
+ size = int(self.Get('cl_autopartition_root_size_default'))
+ deviceSize = int(self.Get('cl_autopartition_device_size'))
+ minRootSize = int(self.Get('cl_autopartition_root_size_min'))
+ if size >= deviceSize:
+ size = max(deviceSize, minRootSize)
return str(size)
def check(self,value):
- if self.Get('cl_autopartition_device') and \
- self.Get('cl_autopartition_set') == "on":
- if int(value) < Sizes().to_M(MINROOTSIZE):
+ minRootSize = int(self.Get('cl_autopartition_root_size_min'))
+ if (self.Get('cl_autopartition_device') and
+ self.Get('cl_autopartition_set') == "on"):
+ if int(value) < minRootSize:
raise VariableError(
_("The root partition should be at least {size}").format(
- size="7 Gb"))
+ size="%s Gb"%(Sizes().to_G(minRootSize))))
def humanReadable(self):
- return humanreadableSize(int(self.Get())*Sizes.M)
+ return humanreadableSize(int(self.Get()))
class VariableClAutopartitionTable(AutopartitionHelper,Variable):
"""
@@ -829,19 +846,20 @@ class VariableClAutopartitionDiskSize(ReadonlyVariable,AutopartitionHelper):
"""
type = "list"
- def generateSize(self,scheme,memory,bootsize,uefisize,rootsize,availsize):
+ def generateSize(self,scheme,memory,bootsize,uefisize,rootsize,availsize, minrootsize):
args = {'swap':memory,
'root': rootsize,
'root2': rootsize,
'boot': bootsize,
'uefi': uefisize,
}
+ minrootsize = int(minrootsize)
deviceOpts = list(self.deviceOpts(scheme))
for line in deviceOpts[:-1]:
availsize -= int(args.get(line,0))
yield str(args.get(line,0))
- if "root" in deviceOpts[-1] and availsize < MINROOTSIZE:
- yield str(MINROOTSIZE)
+ if "root" in deviceOpts[-1] and availsize < minrootsize:
+ yield str(minrootsize)
elif availsize < 1*Sizes.G:
yield str(1*Sizes.G)
else:
@@ -854,12 +872,13 @@ class VariableClAutopartitionDiskSize(ReadonlyVariable,AutopartitionHelper):
availSize = self.Get('cl_autopartition_device_size')
if device:
return list(self.generateSize(scheme,
- str(int(self.Get('cl_autopartition_swap_size'))
- *Sizes.M),
+ self.Get('cl_autopartition_swap_size'),
self.Get('cl_autopartition_boot_size'),
self.Get('cl_autopartition_uefi_size'),
- str(int(self.Get('cl_autopartition_root_size'))
- *Sizes.M),int(availSize)))
+ self.Get('cl_autopartition_root_size'),
+ int(availSize),
+ self.Get('cl_autopartition_root_size_min')
+ ))
return []
def humanReadable(self):
diff --git pym/install/variables/disk.py pym/install/variables/disk.py
index 17b0e2c..0e9d5ed 100644
--- pym/install/variables/disk.py
+++ pym/install/variables/disk.py
@@ -40,7 +40,8 @@ setLocalTranslate('cl_install3',sys.modules[__name__])
class DeviceHelper:
sysBlockPath = '/sys/block'
- rePassDevice = re.compile("^(?!%s)"%"|".join(['fd','ram','loop']))
+ rePassDevice = re.compile("^(?!%s)"%"|".join(['sr','fd',
+ 'ram','loop']))
def getDeviceFromSysPath(self):
"""Get interest devices from sys block path"""
@@ -125,7 +126,8 @@ class VariableOsDeviceDev(ReadonlyVariable,DeviceHelper):
def _getDiskName(devpath):
"""Get devname only for by udevadm that devpath is device (disk)"""
prop = getUdevDeviceInfo(devpath)
- if prop.get("ID_TYPE","")=="disk" and \
+ if (prop.get("ID_TYPE","")=="disk" or
+ path.exists(path.join(devpath,"device"))) and \
prop.get("DEVTYPE","")=="disk":
return prop.get('DEVNAME','')
diff --git pym/install/wsdl_install.py pym/install/wsdl_install.py
index 1c117be..cf2d1ea 100644
--- pym/install/wsdl_install.py
+++ pym/install/wsdl_install.py
@@ -137,7 +137,8 @@ class Wsdl(WsdlBase):
'method_name':"install_pxe",
'category':__("Installation"),
'title':__("PXE Install"),
- 'image':'network-server,preferences-desktop-remote-desktop',
+ 'image':('gnome-network-properties,network-server,'
+ 'preferences-desktop-remote-desktop'),
'command':'cl-install-pxe',
'gui':True,
'rights':['installpxe'],
@@ -187,7 +188,7 @@ class Wsdl(WsdlBase):
'method_name':"setup_network",
'category':__("Configuration"),
'title':__("Network"),
- 'image':'gnome-network-properties,'
+ 'image':'network-workgroup,'
'network-idle,preferences-system-network',
'command':'cl-setup-network',
'gui':True,

@ -0,0 +1,37 @@
# 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/calculate3/${PN}/${P}.tar.bz2
http://mirror.yandex.ru/calculate/calculate3/${PN}/${P}.tar.bz2"
DESCRIPTION="The program of update Calculate Linux"
HOMEPAGE="http://www.calculate-linux.org/main/en/calculate2"
LICENSE="Apache-2.0"
SLOT="3"
KEYWORDS="x86 amd64"
IUSE=""
DEPEND="~sys-apps/calculate-core-3.2.3
~sys-apps/calculate-install-3.2.3
dev-python/pexpect"
RDEPEND="${DEPEND}"
pkg_preinst() {
dosym /usr/sbin/cl-core /usr/sbin/cl-update
dosym /usr/sbin/cl-core /usr/sbin/cl-update-profile
}
src_unpack() {
unpack "${A}"
cd "${S}"
# apply revision changes
epatch "${FILESDIR}/calculate-update-3.2.3-r7.patch"
}

@ -0,0 +1,271 @@
diff --git pym/update/emerge_parser.py pym/update/emerge_parser.py
index 143fa9f..e288c40 100644
--- pym/update/emerge_parser.py
+++ pym/update/emerge_parser.py
@@ -447,7 +447,8 @@ class InstallingPackage(NotifierInformationBlock):
"of {c}(\d+){c}\) {c}([^\s\033]+){c}".format(c=_color_block))
def notify(self, observer, groups):
- binary = bool(self.binary and groups[2] in self.binary)
+ strpkg = str(EmergePackage(groups[2]))
+ binary = bool(self.binary and strpkg in self.binary)
observer(EmergePackage(groups[2]), binary=binary)
def mark_binary(self, package):
diff --git pym/update/update.py pym/update/update.py
index 9387524..2f1e9f4 100644
--- pym/update/update.py
+++ pym/update/update.py
@@ -284,7 +284,7 @@ class Update(object):
except OSError as e:
raise UpdateError(_("Failed to modify the "
"{repname} repository").format(
- repname=repname)+":"+str(e))
+ repname=repname)+_(": ")+str(e))
finally:
if path.exists(rpath_new):
removeDir(rpath_new)
@@ -404,7 +404,7 @@ class Update(object):
cpu_num = self.clVars.Get('hr_cpu_num')
if repname in OverlayOwnCache():
self.printWARNING(
- _("Repository %s has own cache") % repname.capitalize())
+ _("Repository %s has its own cache") % repname.capitalize())
else:
self.startTask(_("Updating the %s repository cache") %
repname.capitalize())
@@ -794,7 +794,7 @@ class Update(object):
def _display_error(self, error):
lines_num = int(self.clVars.Get('update.cl_update_lines_limit'))
- error = "\n".join(str(error).split('<br/>')[-lines_num:])
+ error = "<br/>".join(str(error).split('<br/>')[-lines_num:])
self.printPre(self._emerge_translate(error))
def emerge(self, param, *packages):
@@ -833,10 +833,12 @@ class Update(object):
try:
emerge = EmergeParser(EmergeCommand(["--depclean"],
emerge_default_opts=deo))
+ outdated_kernel = False
try:
emerge.question.action = lambda x: False
emerge.run()
if not emerge.uninstall_packages.list:
+ UpdateInfo(self.clVars).outdated_kernel = False
return True
kernel_pkg = self.clVars.Get('cl_update_kernel_pkg')
if any(("%s-%s" % (x['CATEGORY/PN'], x['PVR'])) == kernel_pkg
@@ -850,6 +852,7 @@ class Update(object):
emerge.close()
emerge = None
if not pkglist:
+ UpdateInfo(self.clVars).outdated_kernel = True
return True
emerge = EmergeParser(
EmergeCommand(pkglist,
@@ -857,6 +860,9 @@ class Update(object):
emerge_default_opts=deo))
emerge.question.action = lambda x: False
emerge.run()
+ outdated_kernel = True
+ else:
+ outdated_kernel = False
self._display_remove_list(emerge)
except EmergeError:
self._display_error(emerge.prepare_error)
@@ -864,6 +870,7 @@ class Update(object):
if (self.askConfirm(
_("Would you like to unmerge these packages?")) != 'yes'):
return False
+ UpdateInfo(self.clVars).outdated_kernel = outdated_kernel
self._startEmerging(emerge)
finally:
if emerge:
@@ -907,7 +914,7 @@ class Update(object):
try:
if not profile_dv:
raise UpdateError(
- _("Failed to use new profile. Try again."))
+ _("Failed to use the new profile. Try again."))
for var_name in ('cl_update_rep_rev',
'cl_update_rep_path',
'cl_update_rep_url',
diff --git pym/update/update_info.py pym/update/update_info.py
index a162631..72069e0 100644
--- pym/update/update_info.py
+++ pym/update/update_info.py
@@ -14,12 +14,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+import os
+from os import path
from itertools import ifilter
from calculate.core.datavars import DataVarsCore
from calculate.core.server.gen_pid import search_worked_process
from calculate.lib.cl_template import SystemIni
from calculate.lib.utils.content import getCfgFiles
-from calculate.lib.utils.files import getRunCommands
+from calculate.lib.utils.files import getRunCommands, readFile
+import time
class UpdateInfo(object):
@@ -72,3 +75,27 @@ class UpdateInfo(object):
В системе уже есть работающий процесс обновления
"""
return search_worked_process("update", self.dv)
+
+ @property
+ def outdated_kernel(self):
+ flag_path = self.dv.Get('update.cl_update_outdated_kernel_path')
+ if path.exists(flag_path):
+ try:
+ flag_kernel = readFile(flag_path).strip()
+ current_kernel = self.dv.Get('update.cl_update_kernel_version')
+ if flag_kernel != current_kernel:
+ return True
+ except ValueError:
+ pass
+ return False
+
+ @outdated_kernel.setter
+ def outdated_kernel(self, value):
+ flag_path = self.dv.Get('update.cl_update_outdated_kernel_path')
+
+ if value:
+ with open(flag_path, 'w') as f:
+ f.write(self.dv.Get('update.cl_update_kernel_version'))
+ else:
+ if path.exists(flag_path):
+ os.unlink(flag_path)
diff --git pym/update/utils/cl_update.py pym/update/utils/cl_update.py
index 509aed1..cdc6fcc 100644
--- pym/update/utils/cl_update.py
+++ pym/update/utils/cl_update.py
@@ -45,6 +45,13 @@ class ClUpdateAction(Action):
return bool(PackageList(task.list)[pkg])
return func
+ def need_depclean(pkg, task_name):
+ def func(Get):
+ task = EmergeLog(EmergeLogNamedTask(task_name))
+ return (bool(PackageList(task.list)[pkg])
+ or Get('cl_update_outdated_kernel_set') == 'on')
+ return func
+
def need_upgrade(pkg):
def func():
return bool(Eix(pkg, Eix.Option.Upgrade).get_packages())
@@ -124,7 +131,7 @@ class ClUpdateAction(Action):
{'name': 'update_other:update_depclean',
'message': __("Calculating dependencies"),
'method': 'Update.depclean()',
- 'condition': was_installed('.*', log_names['depclean']),
+ 'condition': need_depclean('.*', log_names['depclean']),
'decoration': 'Update.update_task("%s")' % log_names['depclean']
},
]
diff --git pym/update/variables/update.py pym/update/variables/update.py
index 3bbd583..b2299fc 100644
--- pym/update/variables/update.py
+++ pym/update/variables/update.py
@@ -33,6 +33,7 @@ from calculate.update.profile import RepositoryStorageSet, DEFAULT_BRANCH
from calculate.lib.variables.linux import VariableOsLinuxName, \
VariableOsLinuxSubname, VariableOsLinuxVer, VariableOsLinuxShortname
from calculate.lib.variables.env import VariableClTemplateLocation
+from calculate.update.update_info import UpdateInfo
setLocalTranslate('cl_update3', sys.modules[__name__])
@@ -57,9 +58,9 @@ class VariableClUpdateWorld(Variable):
metavalue = "MODE"
def init(self):
- self.help = ("'rebuild' - " + _("rebuild system packages list") +
- ",\n'merge' - " + _("append profile system packages list") +
- ",\n'update' - " + _("update system packages list"))
+ self.help = ("'rebuild' - " + _("rebuild the system packages list") +
+ ",\n'merge' - " + _("append the profile packages list") +
+ ",\n'update' - " + _("update the system packages list"))
self.label = _("System packages list")
def choice(self):
@@ -321,10 +322,10 @@ class VariableClUpdateEgencacheForce(Variable):
#untrusted = True
def init(self):
- self.help = ("'force' - " + _("force the update overlays cache") +
- ",\n'skip' - " + _("skip the overlays cache update") +
- ",\n'auto' - " + _("update overlays cache if it is outdated"))
- self.label = _("Update overlays cache")
+ self.help = ("'force' - " + _("force the update of the overlays cache") +
+ ",\n'skip' - " + _("skip the update of the overlays cache") +
+ ",\n'auto' - " + _("update the overlays cache if outdated"))
+ self.label = _("Update the overlays cache")
def choice(self):
return [("force", _("Force")),
@@ -563,7 +564,7 @@ class VariableClUpdateTemplatesLocate(Variable):
def init(self):
self.label = _("Templates location")
- self.help = _("select location for templates %s") \
+ self.help = _("select the location for templates %s") \
%",".join(self.get())
def get(self):
@@ -884,7 +885,7 @@ class VariableClUpdateProfileSystem(Variable):
raise VariableError("")
if repo_name not in list(self.Get('cl_update_profile_rep_name')):
raise VariableError(
- _("Overlay %s not specified in cl_update_rep_name")%
+ _("Overlay %s is not specified in cl_update_rep_name")%
repo_name)
except (DataVarsError,VariableError) as e:
if str(e):
@@ -1021,8 +1022,8 @@ class VariableClUpdateEmergelistSet(Variable):
opt = ["-e","--emergelist"]
def init(self):
- self.label = _("Emerge like packages list")
- self.help = _("display packages list in emerge format")
+ self.label = _("Emerge-like packages list")
+ self.help = _("display the packages list in emerge format")
class VariableClUpdateKernelVersion(ReadonlyVariable):
"""
@@ -1087,3 +1088,19 @@ class VariableClUpdateCleanpkgSet(Variable):
def init(self):
self.label = _("Clean obsolete programs archives")
self.help = _("clean obsolete programs archives")
+
+class VariableClUpdateOutdatedKernelPath(Variable):
+ """
+ Файл-флаг наличия устаревшего, неудаленного ядра
+ """
+ value = "/var/lib/calculate/calculate-update/outdated_kernel"
+
+class VariableClUpdateOutdatedKernelSet(ReadonlyVariable):
+ """
+ Есть наличие устаревшего ядра
+ """
+ type = "bool"
+
+ def get(self):
+ ui = UpdateInfo(self.parent)
+ return "on" if ui.outdated_kernel else "off"
diff --git pym/update/wsdl_update.py pym/update/wsdl_update.py
index 250af39..61baa29 100644
--- pym/update/wsdl_update.py
+++ pym/update/wsdl_update.py
@@ -142,7 +142,7 @@ class Wsdl(WsdlBase):
# категория метода
'category': __('Configuration'),
# заголовок метода
- 'title': __("The Update Check"),
+ 'title': __("Update Check"),
# иконка для графической консоли
'image': 'software-properties,preferences-desktop',
# метод присутствует в графической консоли

@ -0,0 +1,26 @@
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
EAPI=4
DESCRIPTION="Calculate Utilities meta package"
HOMEPAGE="http://www.calculate-linux.org/main/en/calculate2"
SRC_URI=""
LICENSE="Apache-2.0"
SLOT="3"
KEYWORDS="x86 amd64"
IUSE="cl_consolegui cl_client cl_desktop cl_console"
RDEPEND="${RDEPEND}
=sys-apps/calculate-install-3.2.3-r8
=sys-apps/calculate-i18n-3.2.3-r3
=sys-apps/calculate-lib-3.2.3-r6
=sys-apps/calculate-core-3.2.3-r4
=sys-apps/calculate-update-3.2.3-r7
cl_client? ( =sys-apps/calculate-client-3.2.3-r4 )
cl_desktop? ( =sys-apps/calculate-desktop-3.2.3-r2 )
cl_consolegui? ( =sys-apps/calculate-console-gui-3.2.3-r3 )
cl_console? ( =sys-apps/calculate-console-3.2.3-r3 )
"
Loading…
Cancel
Save