chrooting support updates

git-svn-id: http://svn.sabayonlinux.org/projects/entropy/trunk@807 cd1c1023-2f26-0410-ae45-c471fc1f0318
This commit is contained in:
(no author)
2007-12-06 15:23:59 +00:00
parent 0a477c4127
commit 90fc065662
7 changed files with 284 additions and 137 deletions
+39 -31
View File
@@ -967,27 +967,27 @@ def removePackage(infoDict):
# collision check
if etpConst['collisionprotect'] > 0:
if clientDbconn.isFileAvailable(file) and os.path.isfile(file): # in this way we filter out directories
if not etpUi['quiet']: print_warning(darkred(" ## ")+red("Collision found during remove of ")+file+red(" - cannot overwrite"))
equoLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"Collision found during remove of "+file+" - cannot overwrite")
if clientDbconn.isFileAvailable(file) and os.path.isfile(etpConst['systemroot']+file): # in this way we filter out directories
if not etpUi['quiet']: print_warning(darkred(" ## ")+red("Collision found during remove of ")+etpConst['systemroot']+file+red(" - cannot overwrite"))
equoLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"Collision found during remove of "+etpConst['systemroot']+file+" - cannot overwrite")
continue
protected = False
if (not infoDict['removeconfig']) and (not infoDict['diffremoval']):
try:
# -- CONFIGURATION FILE PROTECTION --
if os.access(file,os.R_OK):
if os.access(etpConst['systemroot']+file,os.R_OK):
for x in protect:
if file.startswith(x):
if etpConst['systemroot']+file.startswith(x):
protected = True
break
if (protected):
for x in mask:
if file.startswith(x):
if etpConst['systemroot']+file.startswith(x):
protected = False
break
if (protected) and os.path.isfile(file):
protected = istextfile(file)
if (protected) and os.path.isfile(etpConst['systemroot']+file):
protected = istextfile(etpConst['systemroot']+file)
else:
protected = False # it's not a file
# -- CONFIGURATION FILE PROTECTION --
@@ -996,29 +996,29 @@ def removePackage(infoDict):
if (protected):
equoLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"[remove] Protecting config file: "+file)
if not etpUi['quiet']: print_warning(darkred(" ## ")+red("[remove] Protecting config file: ")+file)
equoLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"[remove] Protecting config file: "+etpConst['systemroot']+file)
if not etpUi['quiet']: print_warning(darkred(" ## ")+red("[remove] Protecting config file: ")+etpConst['systemroot']+file)
else:
try:
os.lstat(file)
os.lstat(etpConst['systemroot']+file)
except OSError:
continue # skip file, does not exist
if os.path.isdir(file) and os.path.islink(file): # S_ISDIR returns False for directory symlinks, so using os.path.isdir
if os.path.isdir(etpConst['systemroot']+file) and os.path.islink(etpConst['systemroot']+file): # S_ISDIR returns False for directory symlinks, so using os.path.isdir
# valid directory symlink
#print "symlink dir",file
directories.add((file,"link"))
elif os.path.isdir(file):
directories.add((etpConst['systemroot']+file,"link"))
elif os.path.isdir(etpConst['systemroot']+file):
# plain directory
#print "plain dir",file
directories.add((file,"dir"))
directories.add((etpConst['systemroot']+file,"dir"))
else: # files, symlinks or not
# just a file or symlink or broken directory symlink (remove now)
try:
#print "plain file",file
os.remove(file)
os.remove(etpConst['systemroot']+file)
# add its parent directory
dirfile = os.path.dirname(file)
dirfile = os.path.dirname(etpConst['systemroot']+file)
if os.path.isdir(dirfile) and os.path.islink(dirfile):
#print "symlink dir2",dirfile
directories.add((dirfile,"link"))
@@ -1034,12 +1034,13 @@ def removePackage(infoDict):
while 1:
taint = False
for directory in directories:
mydir = etpConst['systemroot']+directory[0]
if directory[1] == "link":
try:
mylist = os.listdir(directory[0])
mylist = os.listdir(mydir)
if not mylist:
try:
os.remove(directory[0])
os.remove(mydir)
taint = True
except OSError:
pass
@@ -1047,10 +1048,10 @@ def removePackage(infoDict):
pass
elif directory[1] == "dir":
try:
mylist = os.listdir(directory[0])
mylist = os.listdir(mydir)
if not mylist:
try:
os.rmdir(directory[0])
os.rmdir(mydir)
taint = True
except OSError:
pass
@@ -1111,7 +1112,8 @@ def installPackage(infoDict):
for dir in subdirs:
imagepathDir = currentdir + "/" + dir
rootdir = imagepathDir[len(imageDir):]
rootdir = etpConst['systemroot']+imagepathDir[len(imageDir):]
#print rootdir
# handle broken symlinks
if os.path.islink(rootdir) and not os.path.exists(rootdir):# broken symlink
@@ -1143,10 +1145,12 @@ def installPackage(infoDict):
for file in files:
fromfile = currentdir+"/"+file
tofile = fromfile[len(imageDir):]
todbfile = fromfile[len(imageDir):]
tofile = etpConst['systemroot']+fromfile[len(imageDir):]
#print tofile
if etpConst['collisionprotect'] > 1:
if clientDbconn.isFileAvailable(tofile):
if clientDbconn.isFileAvailable(todbfile):
print_warning(darkred(" ## ")+red("Collision found during install for ")+tofile+" - cannot overwrite")
equoLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"WARNING!!! Collision found during install for "+tofile+" - cannot overwrite")
equoLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"[collision] Protecting config file: "+tofile)
@@ -1220,7 +1224,7 @@ def installPackage(infoDict):
if (protected):
# add to disk cache
confTools.addtocache(tofile)
confTools.addtocache(todbfile)
# inject into database
print_info(red(" ## ")+blue("Updating database with: ")+red(infoDict['atom']))
@@ -1244,7 +1248,7 @@ def installPackage(infoDict):
rc = 0
if (etpConst['gentoo-compat']):
equoLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"Installing new Gentoo database entry: "+str(infoDict['atom']))
rc = installPackageIntoGentooDatabase(infoDict,pkgpath, newidpackage = newidpackage)
rc = installPackageIntoGentooDatabase(infoDict, pkgpath, newidpackage = newidpackage)
# remove unpack dir
shutil.rmtree(unpackDir,True)
@@ -1287,7 +1291,7 @@ def removePackageFromGentooDatabase(atom):
if x == "/":
x = "\/"
skippedKey += x
os.system("sed -i '/"+skippedKey+"/d' /var/lib/portage/world")
os.system("sed -i '/"+skippedKey+"/d' "+etpConst['systemroot']+"/var/lib/portage/world")
return 0
@@ -1332,7 +1336,11 @@ def installPackageIntoGentooDatabase(infoDict,packageFile, newidpackage = -1):
break
if (pkgToRemove):
removePath = portDbDir+pkgToRemove
os.system("rm -rf "+removePath)
shutil.rmtree(removePath,True)
try:
os.rmdir(removePath)
except OSError:
pass
#print "removing -> "+removePath
### INSTALL NEW
@@ -1381,9 +1389,9 @@ def installPackageIntoGentooDatabase(infoDict,packageFile, newidpackage = -1):
pass
# test if /var/cache/edb/counter is fine
if os.path.isfile(edbCOUNTER):
if os.path.isfile(etpConst['edbcounter']):
try:
f = open(edbCOUNTER,"r")
f = open(etpConst['edbcounter'],"r")
counter = int(f.readline().strip())
f.close()
except:
@@ -1399,7 +1407,7 @@ def installPackageIntoGentooDatabase(infoDict,packageFile, newidpackage = -1):
f.write(str(counter)+"\n")
f.flush()
f.close()
f = open(edbCOUNTER,"w")
f = open(etpConst['edbcounter'],"w")
f.write(str(counter))
f.flush()
f.close()
+214 -92
View File
@@ -261,8 +261,9 @@ def call_ext_generic(pkgdata, stage):
def fontconfig(pkgdata):
fontdirs = set()
for xdir in pkgdata['content']:
if xdir.startswith("/usr/share/fonts"):
origdir = xdir[16:]
xdir = etpConst['systemroot']+xdir
if xdir.startswith(etpConst['systemroot']+"/usr/share/fonts"):
origdir = xdir[len(etpConst['systemroot'])+16:]
if origdir:
if origdir.startswith("/"):
origdir = origdir.split("/")[1]
@@ -287,7 +288,8 @@ def iconscache(pkgdata):
equoLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"[POST] Updating icons cache...")
print_info(red(" ##")+brown(" Updating icons cache..."))
for file in pkgdata['content']:
if file.startswith("/usr/share/icons") and file.endswith("index.theme"):
file = etpConst['systemroot']+file
if file.startswith(etpConst['systemroot']+"/usr/share/icons") and file.endswith("index.theme"):
cachedir = os.path.dirname(file)
generate_icons_cache(cachedir)
@@ -329,10 +331,13 @@ def kernelmod(pkgdata):
# get kernel modules dir name
name = ''
for file in pkgdata['content']:
if file.startswith("/lib/modules/"):
name = file.split("/")[3]
file = etpConst['systemroot']+file
if file.startswith(etpConst['systemroot']+"/lib/modules/"):
name = file[len(etpConst['systemroot']):]
name = name.split("/")[3]
break
run_depmod(name)
if name:
run_depmod(name)
def pythoninst(pkgdata):
equoLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"[POST] Configuring Python...")
@@ -346,25 +351,36 @@ def sqliteinst(pkgdata):
def initdisable(pkgdata):
for file in pkgdata['removecontent']:
if file.startswith("/etc/init.d/") and os.path.isfile(file):
file = etpConst['systemroot']+file
if file.startswith(etpConst['systemroot']+"/etc/init.d/") and os.path.isfile(etpConst['systemroot']+file):
# running?
running = os.path.isfile(INITSERVICES_DIR+'/started/'+os.path.basename(file))
scheduled = not os.system('rc-update show | grep '+os.path.basename(file)+'&> /dev/null')
running = os.path.isfile(etpConst['systemroot']+INITSERVICES_DIR+'/started/'+os.path.basename(file))
if not etpConst['systemroot']:
myroot = "/"
else:
myroot = etpConst['systemroot']+"/"
scheduled = not os.system('ROOT="'+myroot+'" rc-update show | grep '+os.path.basename(file)+'&> /dev/null')
initdeactivate(file, running, scheduled)
def initinform(pkgdata):
for file in pkgdata['content']:
if file.startswith("/etc/init.d/") and not os.path.isfile(file):
equoLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"[PRE] A new service will be installed: "+file)
print_info(red(" ##")+brown(" A new service will be installed: ")+file)
file = etpConst['systemroot']+file
if file.startswith(etpConst['systemroot']+"/etc/init.d/") and not os.path.isfile(etpConst['systemroot']+file):
equoLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"[PRE] A new service will be installed: "+etpConst['systemroot']+file)
print_info(red(" ##")+brown(" A new service will be installed: ")+etpConst['systemroot']+file)
def removeinit(pkgdata):
for file in pkgdata['removecontent']:
if file.startswith("/etc/init.d/") and os.path.isfile(file):
file = etpConst['systemroot']+file
if file.startswith(etpConst['systemroot']+"/etc/init.d/") and os.path.isfile(etpConst['systemroot']+file):
equoLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"[POST] Removing boot service: "+os.path.basename(file))
print_info(red(" ##")+brown(" Removing boot service: ")+os.path.basename(file))
if not etpConst['systemroot']:
myroot = "/"
else:
myroot = etpConst['systemroot']+"/"
try:
os.system('rc-update del '+os.path.basename(file)+' &> /dev/null')
os.system('ROOT="'+myroot+'" rc-update del '+os.path.basename(file)+' &> /dev/null')
except:
pass
@@ -379,7 +395,13 @@ def openglsetup(pkgdata):
if eselect == 0:
equoLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"[POST] Reconfiguring OpenGL to "+opengl+" ...")
print_info(red(" ##")+brown(" Reconfiguring OpenGL..."))
os.system("eselect opengl set --use-old "+opengl)
if not etpConst['systemroot']:
myroot = "/"
else:
myroot = etpConst['systemroot']+"/"
quietstring = ''
if etpUi['quiet']: quietstring = " &>/dev/null"
os.system('ROOT="'+myroot+'" eselect opengl set --use-old '+opengl+quietstring)
else:
equoLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"[POST] Eselect NOT found, cannot run OpenGL trigger")
print_info(red(" ##")+brown(" Eselect NOT found, cannot run OpenGL trigger"))
@@ -389,7 +411,13 @@ def openglsetup_xorg(pkgdata):
if eselect == 0:
equoLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"[POST] Reconfiguring OpenGL to fallback xorg-x11 ...")
print_info(red(" ##")+brown(" Reconfiguring OpenGL..."))
os.system("eselect opengl set xorg-x11")
if not etpConst['systemroot']:
myroot = "/"
else:
myroot = etpConst['systemroot']+"/"
quietstring = ''
if etpUi['quiet']: quietstring = " &>/dev/null"
os.system('ROOT="'+myroot+'" eselect opengl set xorg-x11'+quietstring)
else:
equoLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"[POST] Eselect NOT found, cannot run OpenGL trigger")
print_info(red(" ##")+brown(" Eselect NOT found, cannot run OpenGL trigger"))
@@ -421,15 +449,17 @@ def removebootablekernel(pkgdata):
def mountboot(pkgdata):
# is in fstab?
if etpConst['systemroot']:
return
if os.path.isfile("/etc/fstab"):
f = open("/etc/fstab","r")
fstab = f.readlines()
fstab = f.readlines()
fstab = entropyTools.listToUtf8(fstab)
f.close()
for line in fstab:
fsline = line.split()
if len(fsline) > 1:
if fsline[1] == "/boot":
f.close()
for line in fstab:
fsline = line.split()
if len(fsline) > 1:
if fsline[1] == "/boot":
if not os.path.ismount("/boot"):
# trigger mount /boot
rc = os.system("mount /boot &> /dev/null")
@@ -442,6 +472,8 @@ def mountboot(pkgdata):
break
def kbuildsycoca(pkgdata):
if etpConst['systemroot']:
return
kdedirs = ''
try:
kdedirs = os.environ['KDEDIRS']
@@ -461,44 +493,55 @@ def kbuildsycoca(pkgdata):
def gconfinstallschemas(pkgdata):
gtest = os.system("which gconftool-2 &> /dev/null")
if gtest == 0:
if gtest == 0 or etpConst['systemroot']:
schemas = [x for x in pkgdata['content'] if x.startswith("/etc/gconf/schemas") and x.endswith(".schemas")]
print_info(red(" ##")+brown(" Installing GConf2 schemas..."))
for schema in schemas:
os.system("""
unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL
export GCONF_CONFIG_SOURCE=$(gconftool-2 --get-default-source)
gconftool-2 --makefile-install-rule """+schema+""" 1>/dev/null
""")
if not etpConst['systemroot']:
os.system("""
unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL
export GCONF_CONFIG_SOURCE=$(gconftool-2 --get-default-source)
gconftool-2 --makefile-install-rule """+schema+""" 1>/dev/null
""")
else:
os.system(""" echo "
unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL
export GCONF_CONFIG_SOURCE=$(gconftool-2 --get-default-source)
gconftool-2 --makefile-install-rule """+schema+""" " | chroot """+etpConst['systemroot']+""" &>/dev/null
""")
def pygtksetup(pkgdata):
python_sym_files = [x for x in pkgdata['content'] if x.endswith("pygtk.py-2.0") or x.endswith("pygtk.pth-2.0")]
print python_sym_files
for file in python_sym_files:
file = etpConst['systemroot']+file
filepath = file[:-4]
sympath = os.path.basename(file)
if os.path.isfile(file):
try:
if os.path.isfile(file[:-4]):
os.remove(file[:-4])
os.symlink(file,file[:-4])
if os.path.isfile(filepath):
os.remove(filepath)
os.symlink(sympath,filepath)
except OSError:
pass
def pygtkremove(pkgdata):
python_sym_files = [x for x in pkgdata['content'] if x.startswith("/usr/lib/python") and (x.endswith("pygtk.py-2.0") or x.endswith("pygtk.pth-2.0"))]
for file in python_sym_files:
file = etpConst['systemroot']+file
if os.path.isfile(file[:-4]):
os.remove(file[:-4])
def susetuid(pkgdata):
if os.path.isfile("/bin/su"):
print_info(red(" ##")+brown(" Configuring '/bin/su' executable SETUID"))
os.chown("/bin/su",0,0)
os.system("chmod 4755 /bin/su")
#os.chmod("/bin/su",4755) #FIXME: probably there's something I don't know here since
if os.path.isfile(etpConst['systemroot']+"/bin/su"):
print_info(red(" ##")+brown(" Configuring '"+etpConst['systemroot']+"/bin/su' executable SETUID"))
os.chown(etpConst['systemroot']+"/bin/su",0,0)
os.system("chmod 4755 "+etpConst['systemroot']+"/bin/su")
#os.chmod("/bin/su",4755) #FIXME: probably there's something I don't know here since, masks?
def cleanpy(pkgdata):
pyfiles = [x for x in pkgdata['content'] if x.endswith(".py")]
for file in pyfiles:
file = etpConst['systemroot']+file
if os.path.isfile(file+"o"):
try: os.remove(file+"o")
except OSError: pass
@@ -508,36 +551,55 @@ def cleanpy(pkgdata):
def createkernelsym(pkgdata):
for file in pkgdata['content']:
if file.startswith("/usr/src/"):
file = etpConst['systemroot']+file
if file.startswith(etpConst['systemroot']+"/usr/src/"):
# extract directory
try:
todir = file.split("/")[3]
todir = file[len(etpConst['systemroot']):]
todir = todir.split("/")[3]
except:
continue
if os.path.isdir("/usr/src/"+todir):
if os.path.isdir(etpConst['systemroot']+"/usr/src/"+todir):
# link to /usr/src/linux
equoLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"[POST] Creating kernel symlink /usr/src/linux for /usr/src/"+todir)
print_info(red(" ##")+brown(" Creating kernel symlink /usr/src/linux for /usr/src/"+todir))
if os.path.isfile("/usr/src/linux") or os.path.islink("/usr/src/linux"):
os.remove("/usr/src/linux")
os.symlink(todir,"/usr/src/linux")
equoLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"[POST] Creating kernel symlink "+etpConst['systemroot']+"/usr/src/linux for /usr/src/"+todir)
print_info(red(" ##")+brown(" Creating kernel symlink "+etpConst['systemroot']+"/usr/src/linux for /usr/src/"+todir))
if os.path.isfile(etpConst['systemroot']+"/usr/src/linux") or os.path.islink(etpConst['systemroot']+"/usr/src/linux"):
os.remove(etpConst['systemroot']+"/usr/src/linux")
if os.path.isdir(etpConst['systemroot']+"/usr/src/linux"):
mydir = etpConst['systemroot']+"/usr/src/linux."+str(entropyTools.getRandomNumber())
while os.path.isdir(mydir):
mydir = etpConst['systemroot']+"/usr/src/linux."+str(entropyTools.getRandomNumber())
shutil.move(etpConst['systemroot']+"/usr/src/linux",mydir)
try:
os.symlink(todir,etpConst['systemroot']+"/usr/src/linux")
except OSError: # not important in the end
pass
break
def run_ldconfig(pkgdata):
if not etpConst['systemroot']:
myroot = "/"
else:
myroot = etpConst['systemroot']+"/"
equoLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"[POST] Running ldconfig")
print_info(red(" ##")+brown(" Regenerating /etc/ld.so.cache"))
os.system("ldconfig &> /dev/null")
os.system("ldconfig -r "+myroot+" &> /dev/null")
def env_update(pkgdata):
if not etpConst['systemroot']:
myroot = "/"
else:
myroot = etpConst['systemroot']+"/"
equoLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"[POST] Running env-update")
if os.access("/usr/sbin/env-update",os.X_OK):
print_info(red(" ##")+brown(" Updating environment using env-update"))
os.system("env-update &> /dev/null")
os.system('ROOT="'+myroot+'" env-update --no-ldconfig &> /dev/null')
def add_java_config_2(pkgdata):
vms = set()
for vm in pkgdata['content']:
if vm.startswith("/usr/share/java-config-2/vm/") and os.path.isfile(vm):
vm = etpConst['systemroot']+vm
if vm.startswith(etpConst['systemroot']+"/usr/share/java-config-2/vm/") and os.path.isfile(vm):
vms.add(vm)
# sort and get the latter
if vms:
@@ -545,11 +607,14 @@ def add_java_config_2(pkgdata):
vms.reverse()
myvm = vms[0].split("/")[-1]
if myvm:
if os.access("/usr/bin/java-config",os.X_OK):
if os.access(etpConst['systemroot']+"/usr/bin/java-config",os.X_OK):
equoLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"[POST] Configuring JAVA using java-config with VM: "+myvm)
# set
print_info(red(" ##")+brown(" Setting system VM to ")+bold(myvm)+brown("..."))
os.system("java-config -S "+myvm)
if not etpConst['systemroot']:
os.system("java-config -S "+myvm)
else:
os.system("echo 'java-config -S "+myvm+"' | chroot "+etpConst['systemroot']+" &> /dev/null")
else:
equoLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"[POST] ATTENTION /usr/bin/java-config does not exist. I was about to set JAVA VM: "+myvm)
print_info(red(" ##")+bold(" Attention: ")+brown("/usr/bin/java-config does not exist. Cannot set JAVA VM."))
@@ -570,7 +635,7 @@ def setup_font_dir(fontdir):
os.system('/usr/bin/mkfontscale '+unicode(fontdir))
# mkfontdir
if os.access('/usr/bin/mkfontdir',os.X_OK):
os.system('/usr/bin/mkfontdir -e /usr/share/fonts/encodings -e /usr/share/fonts/encodings/large '+unicode(fontdir))
os.system('/usr/bin/mkfontdir -e '+etpConst['systemroot']+'/usr/share/fonts/encodings -e '+etpConst['systemroot']+'/usr/share/fonts/encodings/large '+unicode(fontdir))
return 0
'''
@@ -588,8 +653,12 @@ def setup_font_cache(fontdir):
@output: returns int() as exit status
'''
def set_gcc_profile(profile):
if not etpConst['systemroot']:
myroot = "/"
else:
myroot = etpConst['systemroot']+"/"
if os.access('/usr/bin/gcc-config',os.X_OK):
os.system('/usr/bin/gcc-config '+profile)
os.system('ROOT="'+myroot+'" /usr/bin/gcc-config '+profile)
return 0
'''
@@ -597,6 +666,10 @@ def set_gcc_profile(profile):
@output: returns int() as exit status
'''
def set_binutils_profile(profile):
if not etpConst['systemroot']:
myroot = "/"
else:
myroot = etpConst['systemroot']+"/"
if os.access('/usr/bin/binutils-config',os.X_OK):
os.system('/usr/bin/binutils-config '+profile)
return 0
@@ -607,7 +680,7 @@ def set_binutils_profile(profile):
'''
def generate_icons_cache(cachedir):
if os.access('/usr/bin/gtk-update-icon-cache',os.X_OK):
os.system('/usr/bin/gtk-update-icon-cache -qf '+cachedir)
os.system('ROOT="'+myroot+'" /usr/bin/gtk-update-icon-cache -qf '+cachedir)
return 0
'''
@@ -615,8 +688,12 @@ def generate_icons_cache(cachedir):
@output: returns int() as exit status
'''
def update_mime_db():
if os.access('/usr/bin/update-mime-database',os.X_OK):
os.system('/usr/bin/update-mime-database /usr/share/mime')
if os.access(etpConst['systemroot']+'/usr/bin/update-mime-database',os.X_OK):
if not etpConst['systemroot']:
os.system('/usr/bin/update-mime-database /usr/share/mime')
else:
os.system("echo '/usr/bin/update-mime-database /usr/share/mime' | chroot "+etpConst['systemroot']+" &> /dev/null")
return 0
'''
@@ -624,8 +701,11 @@ def update_mime_db():
@output: returns int() as exit status
'''
def update_mime_desktop_db():
if os.access('/usr/bin/update-desktop-database',os.X_OK):
os.system('/usr/bin/update-desktop-database -q /usr/share/applications')
if os.access(etpConst['systemroot']+'/usr/bin/update-desktop-database',os.X_OK):
if not etpConst['systemroot']:
os.system('/usr/bin/update-desktop-database -q /usr/share/applications')
else:
os.system("echo '/usr/bin/update-desktop-database -q /usr/share/applications' | chroot "+etpConst['systemroot']+" &> /dev/null")
return 0
'''
@@ -633,10 +713,17 @@ def update_mime_desktop_db():
@output: returns int() as exit status
'''
def update_scrollkeeper_db():
if os.access('/usr/bin/scrollkeeper-update',os.X_OK):
if not os.path.isdir('/var/lib/scrollkeeper'):
os.makedirs('/var/lib/scrollkeeper')
os.system('/usr/bin/scrollkeeper-update -q -p /var/lib/scrollkeeper')
if os.access(etpConst['systemroot']+'/usr/bin/scrollkeeper-update',os.X_OK):
if not os.path.isdir(etpConst['systemroot']+'/var/lib/scrollkeeper'):
os.makedirs(etpConst['systemroot']+'/var/lib/scrollkeeper')
if not etpConst['systemroot']:
os.system('/usr/bin/scrollkeeper-update -q -p /var/lib/scrollkeeper')
else:
os.system("echo '/usr/bin/scrollkeeper-update -q -p /var/lib/scrollkeeper' | chroot "+etpConst['systemroot']+" &> /dev/null")
return 0
'''
@@ -644,6 +731,8 @@ def update_scrollkeeper_db():
@output: returns int() as exit status
'''
def reload_gconf_db():
if etpConst['systemroot']:
return 0
rc = os.system('pgrep -x gconfd-2')
if (rc == 0):
pids = getoutput('pgrep -x gconfd-2').split("\n")
@@ -661,15 +750,15 @@ def reload_gconf_db():
@output: returns int() as exit status
'''
def update_moduledb(item):
if os.access('/usr/sbin/module-rebuild',os.X_OK):
if os.path.isfile(MODULEDB_DIR+'moduledb'):
f = open(MODULEDB_DIR+'moduledb',"r")
if os.access(etpConst['systemroot']+'/usr/sbin/module-rebuild',os.X_OK):
if os.path.isfile(etpConst['systemroot']+MODULEDB_DIR+'moduledb'):
f = open(etpConst['systemroot']+MODULEDB_DIR+'moduledb',"r")
moduledb = f.readlines()
moduledb = entropyTools.listToUtf8(moduledb)
f.close()
avail = [x for x in moduledb if x.strip() == item]
if (not avail):
f = open(MODULEDB_DIR+'moduledb',"aw")
f = open(etpConst['systemroot']+MODULEDB_DIR+'moduledb',"aw")
f.write(item+"\n")
f.flush()
f.close()
@@ -681,7 +770,11 @@ def update_moduledb(item):
'''
def run_depmod(name):
if os.access('/sbin/depmod',os.X_OK):
os.system('/sbin/depmod -a -b / -r '+name+' &> /dev/null')
if not etpConst['systemroot']:
myroot = "/"
else:
myroot = etpConst['systemroot']+"/"
os.system('/sbin/depmod -a -b '+myroot+' -r '+name+' &> /dev/null')
return 0
'''
@@ -691,11 +784,20 @@ def run_depmod(name):
def python_update_symlink():
bins = [x for x in os.listdir("/usr/bin") if x.startswith("python2.")]
if bins: # don't ask me why but it happened...
versions = [x[6:] for x in bins]
versions.sort()
latest = versions[-1]
os.system('ln -sf /usr/bin/python'+str(latest)+' /usr/bin/python')
os.system('ln -sf /usr/bin/python'+str(latest)+' /usr/bin/python2')
bins.sort()
latest = bins[-1]
latest = etpConst['systemroot']+latest
filepath = os.path.dirname(latest)+"/python"
sympath = os.path.basename(latest)
if os.path.isfile(latest):
try:
if os.path.isfile(filepath):
os.remove(filepath)
os.symlink(sympath,filepath)
except OSError:
pass
return 0
'''
@@ -704,10 +806,20 @@ def python_update_symlink():
'''
def sqlite_update_symlink():
bins = [x for x in os.listdir("/usr/bin") if x.startswith("lemon-")]
versions = [x[6:] for x in bins]
versions.sort()
latest = versions[-1]
os.system('ln -sf /usr/bin/lemon-'+str(latest)+' /usr/bin/lemon')
if bins:
bins.sort()
latest = bins[-1]
filepath = os.path.dirname(latest)+"/lemon"
sympath = os.path.basename(latest)
if os.path.isfile(latest):
try:
if os.path.isfile(filepath):
os.remove(filepath)
os.symlink(sympath,filepath)
except OSError:
pass
return 0
'''
@@ -715,10 +827,17 @@ def sqlite_update_symlink():
@output: returns int() as exit status
'''
def initdeactivate(file, running, scheduled):
if (running):
os.system(file+' stop --quiet')
if not etpConst['systemroot']:
myroot = "/"
if (running):
os.system(file+' stop --quiet')
else:
myroot = etpConst['systemroot']+"/"
if (scheduled):
os.system('rc-update del '+os.path.basename(file))
os.system('ROOT="'+myroot+'" rc-update del '+os.path.basename(file))
return 0
'''
@@ -726,15 +845,16 @@ def initdeactivate(file, running, scheduled):
@output: returns int() as exit status
'''
def configure_boot_grub(kernel,initramfs):
if not os.path.isdir("/boot/grub"):
os.makedirs("/boot/grub")
if os.path.isfile("/boot/grub/grub.conf"):
if not os.path.isdir(etpConst['systemroot']+"/boot/grub"):
os.makedirs(etpConst['systemroot']+"/boot/grub")
if os.path.isfile(etpConst['systemroot']+"/boot/grub/grub.conf"):
# open in append
grub = open("/boot/grub/grub.conf","aw")
grub = open(etpConst['systemroot']+"/boot/grub/grub.conf","aw")
# get boot dev
boot_dev = get_grub_boot_dev()
# test if entry has been already added
grubtest = open("/boot/grub/grub.conf","r")
grubtest = open(etpConst['systemroot']+"/boot/grub/grub.conf","r")
content = grubtest.readlines()
content = entropyTools.listToUtf8(content)
for line in content:
@@ -747,7 +867,7 @@ def configure_boot_grub(kernel,initramfs):
else:
# create
boot_dev = "(hd0,0)"
grub = open("/boot/grub/grub.conf","w")
grub = open(etpConst['systemroot']+"/boot/grub/grub.conf","w")
# write header - guess (hd0,0)... since it is weird having a running system without a bootloader, at least, grub.
grub_header = '''
default=0
@@ -772,8 +892,8 @@ timeout=10
grub.close()
def remove_boot_grub(kernel,initramfs):
if os.path.isdir("/boot/grub") and os.path.isfile("/boot/grub/grub.conf"):
f = open("/boot/grub/grub.conf","r")
if os.path.isdir(etpConst['systemroot']+"/boot/grub") and os.path.isfile(etpConst['systemroot']+"/boot/grub/grub.conf"):
f = open(etpConst['systemroot']+"/boot/grub/grub.conf","r")
grub_conf = f.readlines()
grub_conf = entropyTools.listToUtf8(grub_conf)
kernelname = os.path.basename(kernel)
@@ -805,20 +925,22 @@ def remove_boot_grub(kernel,initramfs):
# skip completed
found = False
new_conf.append(grub_conf[count])
f = open("/boot/grub/grub.conf","w")
f = open(etpConst['systemroot']+"/boot/grub/grub.conf","w")
f.writelines(new_conf)
f.flush()
f.close()
def get_grub_boot_dev():
if etpConst['systemroot']:
return "(hd0,0)"
import re
df_avail = os.system("which df &> /dev/null")
if df_avail != 0:
print "DEBUG: cannot find df!! Cannot properly configure kernel! Defaulting to (hd0,0)"
print_generic("DEBUG: cannot find df!! Cannot properly configure kernel! Defaulting to (hd0,0)")
return "(hd0,0)"
grub_avail = os.system("which grub &> /dev/null")
if grub_avail != 0:
print "DEBUG: cannot find grub!! Cannot properly configure kernel! Defaulting to (hd0,0)"
print_generic("DEBUG: cannot find grub!! Cannot properly configure kernel! Defaulting to (hd0,0)")
return "(hd0,0)"
gboot = getoutput("df /boot").split("\n")[-1].split()[0]
@@ -866,12 +988,12 @@ def get_grub_boot_dev():
grub_dev = grub_disk[:-1]+","+gpartnum+")"
return grub_dev
else:
print "DEBUG: cannot match grub device with linux one!! Cannot properly configure kernel! Defaulting to (hd0,0)"
print_generic("DEBUG: cannot match grub device with linux one!! Cannot properly configure kernel! Defaulting to (hd0,0)")
return "(hd0,0)"
else:
print "DEBUG: cannot find generated device.map!! Cannot properly configure kernel! Defaulting to (hd0,0)"
print_generic("DEBUG: cannot find generated device.map!! Cannot properly configure kernel! Defaulting to (hd0,0)")
return "(hd0,0)"
else:
print "DEBUG: cannot run df /boot!! Cannot properly configure kernel! Defaulting to (hd0,0)"
print_generic("DEBUG: cannot run df /boot!! Cannot properly configure kernel! Defaulting to (hd0,0)")
return "(hd0,0)"
+7 -1
View File
@@ -648,7 +648,7 @@ def installPackages(packages = [], atomsdata = [], deps = True, emptydeps = Fals
installedfrom = clientDbconn.retrievePackageFromInstalledTable(idpackage)
repoinfo = red("[")+brown("from: ")+bold(installedfrom)+red("] ")
if not (etpUi['quiet'] or returnQueue): print_info(red(" ## ")+"["+red("W")+"] "+repoinfo+enlightenatom(pkgatom))
if (runQueue) or (removalQueue):
# show download info
if not (etpUi['quiet'] or returnQueue): print_info(red(" @@ ")+blue("Packages needing install:\t")+red(str(len(runQueue))))
@@ -736,6 +736,12 @@ def installPackages(packages = [], atomsdata = [], deps = True, emptydeps = Fals
returnActionQueue['runQueue'] = {}
returnActionQueue['runQueue']['queue'] = runQueue[:]
returnActionQueue['runQueue']['data'] = {}
returnActionQueue['extrainfo'] = {}
try:
dsize = deltaSize
except:
dsize = 0
returnActionQueue['extrainfo']['deltaSize'] = dsize
# running tasks
+1 -1
View File
@@ -80,6 +80,6 @@ def initConfig_clientConstants():
if line.startswith("configprotectskip|") and (len(line.split("|")) == 2):
configprotect = line.split("|")[1].strip()
for x in configprotect.split():
etpConst['configprotectskip'].append(x)
etpConst['configprotectskip'].append(etpConst['systemroot']+x)
initConfig_clientConstants()
+14 -4
View File
@@ -57,10 +57,15 @@ def openRepositoryDatabase(repositoryName, xcache = True, indexing = True):
conn = etpDatabase(readOnly = True, dbFile = dbfile, clientDatabase = True, dbname = etpConst['dbnamerepoprefix']+repositoryName, xcache = xcache, indexing = indexing)
# initialize CONFIG_PROTECT
if (etpRepositories[repositoryName]['configprotect'] == None) or (etpRepositories[repositoryName]['configprotectmask'] == None):
etpRepositories[repositoryName]['configprotect'] = conn.listConfigProtectDirectories()
etpRepositories[repositoryName]['configprotectmask'] = conn.listConfigProtectDirectories(mask = True)
etpRepositories[repositoryName]['configprotect'] += [x for x in etpConst['configprotect'] if x not in etpRepositories[repositoryName]['configprotect']]
etpRepositories[repositoryName]['configprotectmask'] += [x for x in etpConst['configprotectmask'] if x not in etpRepositories[repositoryName]['configprotectmask']]
etpRepositories[repositoryName]['configprotect'] = [etpConst['systemroot']+x for x in etpRepositories[repositoryName]['configprotect']]
etpRepositories[repositoryName]['configprotectmask'] = [etpConst['systemroot']+x for x in etpRepositories[repositoryName]['configprotectmask']]
etpRepositories[repositoryName]['configprotect'] += [etpConst['systemroot']+x for x in etpConst['configprotect'] if etpConst['systemroot']+x not in etpRepositories[repositoryName]['configprotect']]
etpRepositories[repositoryName]['configprotectmask'] += [etpConst['systemroot']+x for x in etpConst['configprotectmask'] if etpConst['systemroot']+x not in etpRepositories[repositoryName]['configprotectmask']]
return conn
def fetchRepositoryIfNotAvailable(reponame):
@@ -88,10 +93,15 @@ def openClientDatabase(xcache = True, generate = False, indexing = True):
if (not etpConst['dbconfigprotect']):
# config protect not prepared
if (not generate):
etpConst['dbconfigprotect'] = conn.listConfigProtectDirectories()
etpConst['dbconfigprotectmask'] = conn.listConfigProtectDirectories(mask = True)
etpConst['dbconfigprotect'] += [x for x in etpConst['configprotect'] if x not in etpConst['dbconfigprotect']]
etpConst['dbconfigprotectmask'] += [x for x in etpConst['configprotectmask'] if x not in etpConst['dbconfigprotectmask']]
etpConst['dbconfigprotect'] = [etpConst['systemroot']+x for x in etpConst['dbconfigprotect']]
etpConst['dbconfigprotectmask'] = [etpConst['systemroot']+x for x in etpConst['dbconfigprotect']]
etpConst['dbconfigprotect'] += [etpConst['systemroot']+x for x in etpConst['configprotect'] if etpConst['systemroot']+x not in etpConst['dbconfigprotect']]
etpConst['dbconfigprotectmask'] += [etpConst['systemroot']+x for x in etpConst['configprotectmask'] if etpConst['systemroot']+x not in etpConst['dbconfigprotectmask']]
return conn
'''
+2 -1
View File
@@ -405,7 +405,6 @@ dbOR = "|or|"
dbKEYWORDS = "KEYWORDS"
dbCONTENTS = "CONTENTS"
dbCOUNTER = "COUNTER"
edbCOUNTER = "/var/cache/edb/counter"
### Application disk cache
@@ -444,6 +443,7 @@ def initConfig_entropyConstants(rootdir):
ETP_CONF_DIR = rootdir+"/etc/entropy"
ETP_SYSLOG_DIR = rootdir+"/var/log/entropy/"
ETP_VAR_DIR = rootdir+"/var/tmp/entropy"
edbCOUNTER = rootdir+"/var/cache/edb/counter"
const_resetCache()
@@ -543,6 +543,7 @@ def initConfig_entropyConstants(rootdir):
'branch': "3.5", # default choosen branch (overridden by setting in repositories.conf)
'keywords': set([etpSys['arch'],"~"+etpSys['arch']]), # default allowed package keywords
'gentoo-compat': False, # Gentoo compatibility (/var/db/pkg + Portage availability)
'edbcounter': edbCOUNTER,
'filesystemdirs': ['/bin','/boot','/emul','/etc','/lib','/lib32','/lib64','/opt','/sbin','/usr','/var'], # directory of the filesystem
'filesystemdirsmask': [
'/var/cache','/var/db','/var/empty','/var/lib/portage','/var/lib/entropy','/var/log','/var/mail','/var/tmp','/var/www', '/usr/portage',
+7 -7
View File
@@ -139,7 +139,7 @@ def getAtomCategory(atom):
# please always force =pkgcat/pkgname-ver if possible
def getInstalledAtom(atom):
mypath = etpConst['systemroot']+"/"
mypath = etpConst['systemroot']
mytree = portage.vartree(root=mypath)
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"getInstalledAtom: called -> "+str(atom))
rc = mytree.dep_match(str(atom))
@@ -152,7 +152,7 @@ def getInstalledAtom(atom):
return None
def getPackageSlot(atom):
mypath = etpConst['systemroot']+"/"
mypath = etpConst['systemroot']
mytree = portage.vartree(root=mypath)
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"getPackageSlot: called. ")
if atom.startswith("="):
@@ -167,7 +167,7 @@ def getPackageSlot(atom):
def getInstalledAtoms(atom):
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"getInstalledAtoms: called -> "+atom)
mypath = etpConst['systemroot']+"/"
mypath = etpConst['systemroot']
mytree = portage.vartree(root=mypath)
rc = mytree.dep_match(str(atom))
if (rc != []):
@@ -487,7 +487,7 @@ def synthetizeRoughDependencies(roughDependencies, useflags = None):
return dependencies, conflicts
def getPortageAppDbPath():
rc = getPortageEnv("ROOT")+etpConst['systemroot']+portage_const.VDB_PATH
rc = etpConst['systemroot']+"/"+portage_const.VDB_PATH
if (not rc.endswith("/")):
return rc+"/"
return rc
@@ -554,9 +554,9 @@ def refillCounter():
except:
continue
newcounter = max(counters)
if not os.path.isdir(os.path.dirname(edbCOUNTER)):
os.makedirs(os.path.dirname(edbCOUNTER))
f = open(edbCOUNTER,"w")
if not os.path.isdir(os.path.dirname(etpConst['edbcounter'])):
os.makedirs(os.path.dirname(etpConst['edbcounter']))
f = open(etpConst['edbcounter'],"w")
f.write(str(newcounter))
f.flush()
f.close()