post install saga #4:
modüler artık dikkat 1: yeni bağımlılıklar mudur release 8 comar release 14 dikkat 2: kernel release 47 ile birlikte kernel modüllerinin update-modules yapmasına gerek kalmıyor, bu betikleri çıkarmadım henüz (hepsi sadece bunu yapıyor zaten) bir zararı yok ama gereksiz, çıkarıcaz onları. dikkat 3: unittestlerde problem yok, tetex, texinfo, comar, mudur, baselayout, zip, tar, zlib gibi bazı paketlerde kurup kaldırma denemeleri yaptım. bir sorun yok gibi görünüyor, bir regresyon çıkarsa bildiriniz lütfen.
This commit is contained in:
+22
-74
@@ -108,10 +108,7 @@ class Install(AtomicOperation):
|
|||||||
self.check_reinstall()
|
self.check_reinstall()
|
||||||
self.extract_install()
|
self.extract_install()
|
||||||
self.store_pisi_files()
|
self.store_pisi_files()
|
||||||
self.update_environment()
|
|
||||||
self.update_info()
|
|
||||||
|
|
||||||
self.register_comar()
|
|
||||||
self.postinstall()
|
self.postinstall()
|
||||||
|
|
||||||
txn = ctx.dbenv.txn_begin()
|
txn = ctx.dbenv.txn_begin()
|
||||||
@@ -240,32 +237,22 @@ class Install(AtomicOperation):
|
|||||||
self.remove_old = Remove(pkg.name)
|
self.remove_old = Remove(pkg.name)
|
||||||
self.remove_old.run_preremove()
|
self.remove_old.run_preremove()
|
||||||
|
|
||||||
def register_comar(self):
|
|
||||||
self.config_later = False
|
|
||||||
|
|
||||||
if self.metadata.package.providesComar:
|
|
||||||
if ctx.comar:
|
|
||||||
import pisi.comariface as comariface
|
|
||||||
self.register_comar_scripts()
|
|
||||||
else:
|
|
||||||
self.config_later = True # configure-pending will register scripts later
|
|
||||||
|
|
||||||
def postinstall(self):
|
def postinstall(self):
|
||||||
if 'System.Package' in [x.om for x in self.metadata.package.providesComar]:
|
self.config_later = False
|
||||||
if ctx.comar:
|
if ctx.comar:
|
||||||
import pisi.comariface as comariface
|
import pisi.comariface
|
||||||
ctx.ui.notify(pisi.ui.configuring, package = self.pkginfo, files = self.files)
|
ctx.ui.notify(pisi.ui.configuring, package = self.pkginfo, files = self.files)
|
||||||
try:
|
pisi.comariface.post_install(
|
||||||
comariface.run_postinstall(self.pkginfo.name)
|
self.pkginfo.name,
|
||||||
except Exception, e:
|
self.metadata.package.providesComar,
|
||||||
if ctx.get_option('ignore_script_errors'):
|
self.package.comar_dir(),
|
||||||
ctx.ui.warning(_('Ignoring script error: ') + unicode(e))
|
os.path.join(self.package.pkg_dir(), ctx.const.metadata_xml),
|
||||||
else:
|
os.path.join(self.package.pkg_dir(), ctx.const.files_xml),
|
||||||
raise e
|
)
|
||||||
ctx.ui.notify(pisi.ui.configured, package = self.pkginfo, files = self.files)
|
ctx.ui.notify(pisi.ui.configured, package = self.pkginfo, files = self.files)
|
||||||
else:
|
else:
|
||||||
self.config_later = True
|
self.config_later = True
|
||||||
|
|
||||||
def extract_install(self):
|
def extract_install(self):
|
||||||
"unzip package in place"
|
"unzip package in place"
|
||||||
|
|
||||||
@@ -346,15 +333,6 @@ class Install(AtomicOperation):
|
|||||||
ctx.ui.info(_('Storing %s') % fpath, verbose=True)
|
ctx.ui.info(_('Storing %s') % fpath, verbose=True)
|
||||||
self.package.extract_file(fpath, self.package.pkg_dir())
|
self.package.extract_file(fpath, self.package.pkg_dir())
|
||||||
|
|
||||||
def register_comar_scripts(self):
|
|
||||||
"register COMAR scripts"
|
|
||||||
|
|
||||||
for pcomar in self.metadata.package.providesComar:
|
|
||||||
scriptPath = os.path.join(self.package.comar_dir(),pcomar.script)
|
|
||||||
import pisi.comariface
|
|
||||||
pisi.comariface.register(pcomar, self.metadata.package.name,
|
|
||||||
scriptPath)
|
|
||||||
|
|
||||||
def update_databases(self, txn):
|
def update_databases(self, txn):
|
||||||
"update databases"
|
"update databases"
|
||||||
if self.reinstall:
|
if self.reinstall:
|
||||||
@@ -375,25 +353,6 @@ class Install(AtomicOperation):
|
|||||||
# installed packages
|
# installed packages
|
||||||
ctx.packagedb.add_package(self.pkginfo, pisi.itembyrepodb.installed, txn=txn)
|
ctx.packagedb.add_package(self.pkginfo, pisi.itembyrepodb.installed, txn=txn)
|
||||||
|
|
||||||
def update_info(self):
|
|
||||||
for x in self.files.list:
|
|
||||||
if x.type == 'info':
|
|
||||||
pisi.util.run_batch('LC_ALL=C install-info /%s /usr/share/info/dir' % x.path)
|
|
||||||
|
|
||||||
def update_environment(self):
|
|
||||||
# check if we have any shared objects or anything under
|
|
||||||
# /etc/env.d
|
|
||||||
shared = False
|
|
||||||
for x in self.files.list:
|
|
||||||
if x.path.endswith('.so') or x.path.startswith('/etc/env.d'):
|
|
||||||
shared = True
|
|
||||||
break
|
|
||||||
if not ctx.get_option('bypass_ldconfig'):
|
|
||||||
if shared:
|
|
||||||
ctx.ui.info(_("Regenerating /etc/ld.so.cache..."), verbose=True)
|
|
||||||
util.env_update()
|
|
||||||
else:
|
|
||||||
ctx.ui.warning(_("Bypassing ldconfig"), verbose=True)
|
|
||||||
|
|
||||||
def install_single(pkg, upgrade = False):
|
def install_single(pkg, upgrade = False):
|
||||||
"""install a single package from URI or ID"""
|
"""install a single package from URI or ID"""
|
||||||
@@ -442,7 +401,6 @@ class Remove(AtomicOperation):
|
|||||||
self.check_dependencies()
|
self.check_dependencies()
|
||||||
|
|
||||||
self.run_preremove()
|
self.run_preremove()
|
||||||
self.update_info()
|
|
||||||
for fileinfo in self.files.list:
|
for fileinfo in self.files.list:
|
||||||
self.remove_file(fileinfo)
|
self.remove_file(fileinfo)
|
||||||
|
|
||||||
@@ -506,18 +464,13 @@ class Remove(AtomicOperation):
|
|||||||
dpath = os.path.dirname(dpath)
|
dpath = os.path.dirname(dpath)
|
||||||
|
|
||||||
def run_preremove(self):
|
def run_preremove(self):
|
||||||
if ctx.comar and self.package.providesComar:
|
if ctx.comar:
|
||||||
import pisi.comariface as comariface
|
import pisi.comariface
|
||||||
try:
|
pisi.comariface.pre_remove(
|
||||||
comariface.run_preremove(self.package_name)
|
self.package_name,
|
||||||
except Exception, e:
|
os.path.join(self.package.pkg_dir(), ctx.const.metadata_xml),
|
||||||
if ctx.get_option('ignore_script_errors'):
|
os.path.join(self.package.pkg_dir(), ctx.const.files_xml),
|
||||||
ctx.ui.warning(_('Ignoring script error: ') + unicode(e))
|
)
|
||||||
else:
|
|
||||||
raise e
|
|
||||||
else:
|
|
||||||
# FIXME: store this somewhere
|
|
||||||
pass
|
|
||||||
|
|
||||||
def remove_pisi_files(self):
|
def remove_pisi_files(self):
|
||||||
util.clean_dir(self.package.pkg_dir())
|
util.clean_dir(self.package.pkg_dir())
|
||||||
@@ -527,11 +480,6 @@ class Remove(AtomicOperation):
|
|||||||
ctx.filesdb.remove_files(self.files, txn)
|
ctx.filesdb.remove_files(self.files, txn)
|
||||||
pisi.packagedb.remove_tracking_package(self.package_name, txn)
|
pisi.packagedb.remove_tracking_package(self.package_name, txn)
|
||||||
|
|
||||||
def update_info(self):
|
|
||||||
for x in self.files.list:
|
|
||||||
if x.type == 'info':
|
|
||||||
pisi.util.run_batch('LC_ALL=C install-info --delete /%s /usr/share/info/dir ' % x.path)
|
|
||||||
|
|
||||||
|
|
||||||
def remove_single(package_name):
|
def remove_single(package_name):
|
||||||
Remove(package_name).run()
|
Remove(package_name).run()
|
||||||
|
|||||||
+64
-68
@@ -1,6 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
# Copyright (C) 2005, TUBITAK/UEKAE
|
# Copyright (C) 2005-2006, TUBITAK/UEKAE
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify it under
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
# the terms of the GNU General Public License as published by the Free
|
# the terms of the GNU General Public License as published by the Free
|
||||||
@@ -9,47 +9,33 @@
|
|||||||
#
|
#
|
||||||
# Please read the COPYING file.
|
# Please read the COPYING file.
|
||||||
#
|
#
|
||||||
# Authors: Baris Metin <baris@pardus.org.tr>
|
|
||||||
# Gurer Ozen <gurer@pardus.org.tr>
|
|
||||||
|
|
||||||
import comar
|
import os
|
||||||
|
|
||||||
import gettext
|
import gettext
|
||||||
__trans = gettext.translation('pisi', fallback=True)
|
__trans = gettext.translation('pisi', fallback=True)
|
||||||
_ = __trans.ugettext
|
_ = __trans.ugettext
|
||||||
|
|
||||||
|
import comar
|
||||||
import pisi
|
import pisi
|
||||||
import pisi.context as ctx
|
import pisi.context as ctx
|
||||||
|
|
||||||
|
|
||||||
class Error(pisi.Error):
|
class Error(pisi.Error):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def make_com():
|
def make_com():
|
||||||
try:
|
try:
|
||||||
import comar
|
|
||||||
|
|
||||||
if ctx.comar_sockname:
|
if ctx.comar_sockname:
|
||||||
comard = comar.Link(sockname=ctx.comar_sockname)
|
com = comar.Link(sockname=ctx.comar_sockname)
|
||||||
else:
|
else:
|
||||||
comard = comar.Link()
|
com = comar.Link()
|
||||||
return comard
|
return com
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise Error(_("COMAR: comard not fully installed"))
|
raise Error(_("comar package is not fully installed"))
|
||||||
except comar.Error:
|
except comar.Error:
|
||||||
raise Error(_("COMAR: comard not running or defunct"))
|
raise Error(_("cannot connect to comar"))
|
||||||
|
|
||||||
def register(pcomar, name, path):
|
|
||||||
ctx.ui.info(_("Registering COMAR script %s") % pcomar.script)
|
|
||||||
com = make_com()
|
|
||||||
assert(com)
|
|
||||||
com.register(pcomar.om, name, path)
|
|
||||||
|
|
||||||
while 1:
|
|
||||||
reply = com.read_cmd()
|
|
||||||
if reply[0] == com.RESULT:
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
raise Error, _("COMAR.register ERROR!")
|
|
||||||
|
|
||||||
def wait_comar():
|
def wait_comar():
|
||||||
import socket, time
|
import socket, time
|
||||||
@@ -67,13 +53,8 @@ def wait_comar():
|
|||||||
time.sleep(0.2)
|
time.sleep(0.2)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def run_postinstall(package_name):
|
def wait_for_result(com, package_name=None):
|
||||||
"run postinstall scripts trough COMAR"
|
multiple = False
|
||||||
|
|
||||||
com = make_com()
|
|
||||||
assert(com)
|
|
||||||
ctx.ui.info(_("Running post-install script for %s") % package_name)
|
|
||||||
com.call_package("System.Package.postInstall", package_name)
|
|
||||||
while 1:
|
while 1:
|
||||||
try:
|
try:
|
||||||
reply = com.read_cmd()
|
reply = com.read_cmd()
|
||||||
@@ -82,48 +63,63 @@ def run_postinstall(package_name):
|
|||||||
# our precious communication link, so we waitsss
|
# our precious communication link, so we waitsss
|
||||||
if package_name == "comar":
|
if package_name == "comar":
|
||||||
if not wait_comar():
|
if not wait_comar():
|
||||||
raise Error, _("Could not restart Comar")
|
raise Error, _("Could not restart comar")
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
raise Error, _("Comar daemon closed the connection")
|
raise Error, _("connection with comar unexpectedly closed")
|
||||||
if reply[0] == com.RESULT:
|
|
||||||
break
|
cmd = reply[0]
|
||||||
elif reply[0] == com.NONE: # package has no postInstall script
|
if cmd == com.RESULT and not multiple:
|
||||||
break
|
return
|
||||||
elif reply[0] == com.FAIL:
|
elif cmd == com.NONE and not multiple:
|
||||||
e = _("COMAR.call_package(System.Package.postInstall, %s) failed!: %s") % (
|
# no post/pre function, that is ok
|
||||||
package_name, reply[2])
|
return
|
||||||
|
elif cmd == com.RESULT_START:
|
||||||
|
multiple = True
|
||||||
|
elif cmd == com.RESULT_END:
|
||||||
|
return
|
||||||
|
elif cmd == com.FAIL:
|
||||||
|
e = _("Configuration error: %s") % reply[2]
|
||||||
raise Error, e
|
raise Error, e
|
||||||
else:
|
elif cmd == com.ERROR:
|
||||||
raise Error, _("COMAR.call_package ERROR: %d") % reply[0]
|
e = _("Script error: %s") % reply[2]
|
||||||
|
raise Error, e
|
||||||
def run_preremove(package_name):
|
elif cmd == com.DENIED:
|
||||||
|
raise Error, _("comar denied our access")
|
||||||
|
|
||||||
|
def post_install(package_name, provided_scripts, scriptpath, metapath, filepath):
|
||||||
|
ctx.ui.info(_("Configuring package"))
|
||||||
|
self_post = False
|
||||||
com = make_com()
|
com = make_com()
|
||||||
assert(com)
|
|
||||||
|
for script in provided_scripts:
|
||||||
|
ctx.ui.info(_("Registering %s comar script") % script.om)
|
||||||
|
if script.om == "System.Package":
|
||||||
|
self_post = True
|
||||||
|
com.register(script.om, package_name, os.path.join(scriptpath, script.script))
|
||||||
|
wait_for_result(com)
|
||||||
|
|
||||||
|
ctx.ui.info(_("Calling post install handlers"))
|
||||||
|
com.call("System.PackageHandler.setupPackage", [ "metapath", metapath, "filepath", filepath ])
|
||||||
|
wait_for_result(com)
|
||||||
|
|
||||||
|
if self_post:
|
||||||
|
ctx.ui.info(_("Running package's post install script"))
|
||||||
|
com.call_package("System.Package.postInstall", package_name)
|
||||||
|
wait_for_result(com, package_name)
|
||||||
|
|
||||||
# First, call preRemove script!
|
def pre_remove(package_name, metapath, filepath):
|
||||||
ctx.ui.info(_("Running pre-remove script for %s") % package_name)
|
ctx.ui.info(_("Configuring package for removal"))
|
||||||
|
com = make_com()
|
||||||
|
|
||||||
|
ctx.ui.info(_("Running package's pre remove script"))
|
||||||
com.call_package("System.Package.preRemove", package_name)
|
com.call_package("System.Package.preRemove", package_name)
|
||||||
while 1:
|
wait_for_result(com)
|
||||||
reply = com.read_cmd()
|
|
||||||
if reply[0] == com.RESULT:
|
ctx.ui.info(_("Calling pre remove handlers"))
|
||||||
break
|
com.call("System.PackageHandler.cleanupPackage", [ "metapath", metapath, "filepath", filepath ])
|
||||||
elif reply[0] == com.NONE: # package has no preRemove script
|
wait_for_result(com)
|
||||||
break
|
|
||||||
elif reply[0] == com.FAIL:
|
ctx.ui.info(_("Unregistering comar scripts"))
|
||||||
e = _("COMAR.call_package(System.Package.preRemove, %s) failed!: %s") % (
|
|
||||||
package_name, reply[2])
|
|
||||||
raise Error, e
|
|
||||||
else:
|
|
||||||
raise Error, _("COMAR.call_package ERROR: %d") % reply[0]
|
|
||||||
|
|
||||||
# and then, remove package's Comar Scripts...
|
|
||||||
ctx.ui.info(_("Unregistering COMAR scripts for %s") % package_name)
|
|
||||||
com.remove(package_name)
|
com.remove(package_name)
|
||||||
while 1:
|
wait_for_result(com)
|
||||||
reply = com.read_cmd()
|
|
||||||
if reply[0] == com.RESULT:
|
|
||||||
break
|
|
||||||
elif reply[1] == com.ERROR:
|
|
||||||
raise Error, "COMAR.remove failed!"
|
|
||||||
|
|||||||
@@ -1,149 +0,0 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# Copyright (C) 2006, TUBITAK/UEKAE
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or modify it
|
|
||||||
# under the terms of the GNU General Public License as published by the
|
|
||||||
# Free Software Foundation; either version 2 of the License, or (at your
|
|
||||||
# option) any later version. Please read the COPYING file.
|
|
||||||
#
|
|
||||||
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
import subprocess
|
|
||||||
import getopt
|
|
||||||
|
|
||||||
header = "### This file is automatically generated by update-environment"
|
|
||||||
|
|
||||||
header_note = """
|
|
||||||
#
|
|
||||||
# Please do not edit this file directly. If you want to change
|
|
||||||
# anything, please take a look at the files in /etc/env.d
|
|
||||||
# and read the Pardus initialization system documentation.
|
|
||||||
#
|
|
||||||
# Bu otomatik olarak oluşturulmuş bir dosyadır.
|
|
||||||
# Lütfen bu dosyayı elle değiştirmeyin. Değiştirmek istediğiniz
|
|
||||||
# şeyler varsa, /etc/env.d dizinindeki dosyalara ve Pardus
|
|
||||||
# açılış sistemi belgesine bakın.
|
|
||||||
#
|
|
||||||
"""
|
|
||||||
|
|
||||||
specials = (
|
|
||||||
"KDEDIRS",
|
|
||||||
"PATH",
|
|
||||||
"CLASSPATH",
|
|
||||||
"LDPATH",
|
|
||||||
"MANPATH",
|
|
||||||
"INFOPATH",
|
|
||||||
"ROOTPATH",
|
|
||||||
"CONFIG_PROTECT",
|
|
||||||
"CONFIG_PROTECT_MASK",
|
|
||||||
"PRELINK_PATH",
|
|
||||||
"PRELINK_PATH_MASK",
|
|
||||||
"PYTHONPATH",
|
|
||||||
"ADA_INCLUDE_PATH",
|
|
||||||
"ADA_OBJECTS_PATH",
|
|
||||||
)
|
|
||||||
|
|
||||||
def read_env_d(envdir):
|
|
||||||
dict = {}
|
|
||||||
|
|
||||||
paths = []
|
|
||||||
for name in os.listdir(envdir):
|
|
||||||
path = os.path.join(envdir, name)
|
|
||||||
# skip dirs (.svn, .cvs, etc)
|
|
||||||
if os.path.isdir(path):
|
|
||||||
continue
|
|
||||||
# skip backup and version control files
|
|
||||||
if name.endswith("~") or name.endswith(".bak") or name.endswith(",v"):
|
|
||||||
continue
|
|
||||||
# skip pisi's config file backups
|
|
||||||
# .oldconfig is obsolete, but checked anyway cause it may still exist at old systems
|
|
||||||
if name.endswith(".oldconfig") or name.endswith(".newconfig"):
|
|
||||||
continue
|
|
||||||
paths.append(path)
|
|
||||||
paths.sort()
|
|
||||||
|
|
||||||
for path in paths:
|
|
||||||
for line in file(path):
|
|
||||||
if line == "" or line.startswith("#"):
|
|
||||||
continue
|
|
||||||
|
|
||||||
line = line.rstrip("\n")
|
|
||||||
if "=" in line:
|
|
||||||
key, value = line.split("=", 1)
|
|
||||||
key = key.strip()
|
|
||||||
value = value.strip()
|
|
||||||
if value.startswith('"') or value.startswith("'"):
|
|
||||||
value = value[1:-1]
|
|
||||||
|
|
||||||
# Merge for special variables, override for others
|
|
||||||
if key in specials:
|
|
||||||
if dict.has_key(key):
|
|
||||||
dict[key].extend(value.split(":"))
|
|
||||||
else:
|
|
||||||
dict[key] = value.split(":")
|
|
||||||
else:
|
|
||||||
dict[key] = value
|
|
||||||
|
|
||||||
return dict
|
|
||||||
|
|
||||||
def generate_profile_env(envdict, format='export %s="%s"\n'):
|
|
||||||
profile = ""
|
|
||||||
keys = envdict.keys()
|
|
||||||
keys.sort()
|
|
||||||
for key in keys:
|
|
||||||
if key != "LDPATH":
|
|
||||||
tmp = envdict[key]
|
|
||||||
if isinstance(tmp, list):
|
|
||||||
tmp = ":".join(tmp)
|
|
||||||
profile += format % (key, tmp)
|
|
||||||
return header + header_note + profile
|
|
||||||
|
|
||||||
def generate_ld_so_conf(envdict):
|
|
||||||
ldpaths = envdict["LDPATH"]
|
|
||||||
tmp = "\n".join(ldpaths)
|
|
||||||
return tmp + "\n"
|
|
||||||
|
|
||||||
def update_file(path, content):
|
|
||||||
f = file(path, "w")
|
|
||||||
f.write(content)
|
|
||||||
f.close()
|
|
||||||
|
|
||||||
def update_environment(prefix):
|
|
||||||
join = os.path.join
|
|
||||||
|
|
||||||
env = read_env_d(join(prefix, "etc/env.d"))
|
|
||||||
update_file(join(prefix, "etc/profile.env"), generate_profile_env(env))
|
|
||||||
update_file(join(prefix, "etc/csh.env"), generate_profile_env(env, 'setenv %s %s\n'))
|
|
||||||
if env.has_key("LDPATH"):
|
|
||||||
update_file(join(prefix, "etc/ld.so.conf"), generate_ld_so_conf(env))
|
|
||||||
subprocess.call(["/sbin/ldconfig", "-r", prefix])
|
|
||||||
|
|
||||||
#
|
|
||||||
# Command line driver
|
|
||||||
#
|
|
||||||
|
|
||||||
def usage():
|
|
||||||
print "update-environment [--destdir <prefix>]"
|
|
||||||
|
|
||||||
def main(argv):
|
|
||||||
prefix = "/"
|
|
||||||
|
|
||||||
try:
|
|
||||||
opts, args = getopt.gnu_getopt(argv, "h", [ "help", "destdir=" ])
|
|
||||||
except getopt.GetoptError:
|
|
||||||
usage()
|
|
||||||
|
|
||||||
for o, a in opts:
|
|
||||||
if o in ("-h", "--help"):
|
|
||||||
usage()
|
|
||||||
sys.exit(0)
|
|
||||||
if o in ("--destdir"):
|
|
||||||
prefix = a
|
|
||||||
|
|
||||||
update_environment(prefix)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main(sys.argv[1:])
|
|
||||||
Reference in New Issue
Block a user