[entropy.const] drop another global variable, etpConst['packagestmpdir']
This commit is contained in:
+1
-2
@@ -364,8 +364,7 @@ def _do_text_cleanup(main_cmd, options):
|
||||
print_error(darkgreen(_("Another Entropy is currently running.")))
|
||||
return 1
|
||||
|
||||
dirs = [etpConst['packagestmpdir'], etpConst['logdir'],
|
||||
etpConst['entropyunpackdir']]
|
||||
dirs = [etpConst['logdir'], etpConst['entropyunpackdir']]
|
||||
for rel in etpConst['packagesrelativepaths']:
|
||||
# backward compatibility, packages are moved to packages/ dir,
|
||||
# including nonfree, restricted etc.
|
||||
|
||||
+16
-15
@@ -13,6 +13,8 @@ import os
|
||||
import sys
|
||||
import shutil
|
||||
import tempfile
|
||||
import subprocess
|
||||
import codecs
|
||||
|
||||
from entropy.const import etpConst, etpSys, etpUi
|
||||
from entropy.output import red, bold, brown, blue, darkred, darkgreen, purple, \
|
||||
@@ -283,27 +285,27 @@ def _database_resurrect(entropy_client):
|
||||
print_error(mytxt)
|
||||
return
|
||||
# spawn process
|
||||
rnd_num = entropy.tools.get_random_number()
|
||||
tmpfile = os.path.join(etpConst['packagestmpdir'], "%s" % (rnd_num,))
|
||||
if os.path.isfile(tmpfile):
|
||||
os.remove(tmpfile)
|
||||
os.system("find "+etpConst['systemroot']+"/ -mount 1> "+tmpfile)
|
||||
if not os.path.isfile(tmpfile):
|
||||
tmp_fd, tmp_path = tempfile.mkstemp(prefix="resurrect.")
|
||||
os.close(tmp_fd)
|
||||
rc = subprocess.call("find '%s/' -mount 1> '%s'" % (
|
||||
etpConst['systemroot'], tmp_path), shell=True)
|
||||
if rc != 0:
|
||||
mytxt = "%s: %s!" % (
|
||||
darkred(_("Attention")),
|
||||
red(_("'find' couldn't generate an output file")),
|
||||
red(_("find failed to run")),
|
||||
)
|
||||
print_error(mytxt)
|
||||
return
|
||||
|
||||
f = open(tmpfile, "r")
|
||||
# creating list of files
|
||||
filelist = set()
|
||||
item = f.readline().strip()
|
||||
while item:
|
||||
filelist.add(item)
|
||||
enc = etpConst['conf_encoding']
|
||||
with codecs.open(tmp_path, "r", encoding=enc) as f:
|
||||
# creating list of files
|
||||
filelist = set()
|
||||
item = f.readline().strip()
|
||||
f.close()
|
||||
while item:
|
||||
filelist.add(item)
|
||||
item = f.readline().strip()
|
||||
os.remove(tmp_path)
|
||||
entries = len(filelist)
|
||||
|
||||
mytxt = red(" %s...") % (
|
||||
@@ -349,7 +351,6 @@ def _database_resurrect(entropy_client):
|
||||
print_info(mytxt)
|
||||
count = str(len(pkgsfound))
|
||||
cnt = 0
|
||||
os.remove(tmpfile)
|
||||
|
||||
for pkgfound in pkgsfound:
|
||||
cnt += 1
|
||||
|
||||
+29
-20
@@ -16,8 +16,9 @@ if sys.hexversion >= 0x3000000:
|
||||
else:
|
||||
from commands import getoutput
|
||||
import shutil
|
||||
import tempfile
|
||||
|
||||
from entropy.const import etpConst, etpSys, etpUi
|
||||
from entropy.const import etpConst, etpSys, etpUi, const_setup_directory
|
||||
from entropy.output import red, darkred, darkgreen, brown, bold, \
|
||||
print_info, print_error, print_warning
|
||||
from entropy.i18n import _
|
||||
@@ -98,10 +99,9 @@ def quickpkg_handler(entropy_client, mypackages, savedir = None):
|
||||
print_error(darkred(" * ")+red(mytxt+"."))
|
||||
return 1
|
||||
|
||||
if savedir == None:
|
||||
savedir = etpConst['packagestmpdir']
|
||||
if not os.path.isdir(etpConst['packagestmpdir']):
|
||||
os.makedirs(etpConst['packagestmpdir'])
|
||||
if savedir is None:
|
||||
savedir = etpConst['entropyunpackdir']
|
||||
const_setup_directory(savedir)
|
||||
else:
|
||||
if not os.path.isdir(savedir):
|
||||
print_error(darkred(" * ")+red("--savedir ") + \
|
||||
@@ -174,19 +174,24 @@ def common_flate(entropy_client, mytbz2s, action, savedir = None):
|
||||
|
||||
if savedir:
|
||||
if not os.path.isdir(savedir):
|
||||
print_error(darkred(" * ")+bold("--savedir")+":"+red(" %s." % (_("directory does not exist"),)))
|
||||
print_error(darkred(" * ") + bold("--savedir") + ":" \
|
||||
+ red(" %s." % (_("directory does not exist"),)))
|
||||
return 1
|
||||
else:
|
||||
savedir = etpConst['packagestmpdir']
|
||||
savedir = etpConst['entropyunpackdir']
|
||||
const_setup_directory(savedir)
|
||||
|
||||
for tbz2 in mytbz2s:
|
||||
|
||||
valid_etp = True
|
||||
if action == "deflate":
|
||||
valid_etp = entropy.tools.is_entropy_package_file(tbz2)
|
||||
if not (os.path.isfile(tbz2) and tbz2.endswith(etpConst['packagesext']) and \
|
||||
valid_etp):
|
||||
print_error(darkred(" * ")+bold(tbz2)+red(" %s" % (_("is not a valid Entropy package"),)))
|
||||
if not (os.path.isfile(tbz2) and \
|
||||
tbz2.endswith(etpConst['packagesext']) and \
|
||||
valid_etp):
|
||||
print_error(
|
||||
darkred(" * ") + bold(tbz2) + \
|
||||
red(" %s" % (_("is not a valid Entropy package"),)))
|
||||
return 1
|
||||
|
||||
if action == "inflate":
|
||||
@@ -211,7 +216,8 @@ def inflate_handler(entropy_client, mytbz2s, savedir):
|
||||
for tbz2 in mytbz2s:
|
||||
print_info(darkgreen(" * ")+darkred("Inflating: ")+tbz2, back = True)
|
||||
etptbz2path = savedir+os.path.sep+os.path.basename(tbz2)
|
||||
if os.path.realpath(tbz2) != os.path.realpath(etptbz2path): # can convert a file without copying
|
||||
if os.path.realpath(tbz2) != os.path.realpath(etptbz2path):
|
||||
# can convert a file without copying
|
||||
shutil.copy2(tbz2, etptbz2path)
|
||||
info_package = bold(os.path.basename(etptbz2path)) + ": "
|
||||
entropy_client.output(
|
||||
@@ -234,21 +240,24 @@ def inflate_handler(entropy_client, mytbz2s, savedir):
|
||||
mydata['download'] = mydata['download'][:-len(etpConst['packagesext'])] + \
|
||||
"~9999" + etpConst['packagesext']
|
||||
# migrate to the proper format
|
||||
final_tbz2path = os.path.join(os.path.dirname(etptbz2path), os.path.basename(mydata['download']))
|
||||
final_tbz2path = os.path.join(os.path.dirname(etptbz2path),
|
||||
os.path.basename(mydata['download']))
|
||||
shutil.move(etptbz2path, final_tbz2path)
|
||||
etptbz2path = final_tbz2path
|
||||
# create temp database
|
||||
dbpath = etpConst['packagestmpdir']+os.path.sep+str(entropy.tools.get_random_number())
|
||||
while os.path.isfile(dbpath):
|
||||
dbpath = etpConst['packagestmpdir']+os.path.sep+str(entropy.tools.get_random_number())
|
||||
|
||||
tmp_dir = etpConst['entropyunpackdir']
|
||||
tmp_fd, tmp_path = tempfile.mkstemp(prefix="inflate.", dir=tmp_dir)
|
||||
os.close(tmp_fd)
|
||||
# create
|
||||
mydbconn = entropy_client.open_generic_repository(dbpath)
|
||||
mydbconn = entropy_client.open_generic_repository(tmp_path)
|
||||
mydbconn.initializeRepository()
|
||||
idpackage = mydbconn.addPackage(mydata, revision = mydata['revision'])
|
||||
mydbconn.close()
|
||||
entropy.tools.aggregate_entropy_metadata(etptbz2path, dbpath)
|
||||
os.remove(dbpath)
|
||||
print_info(darkgreen(" * ")+darkred("%s: " % (_("Inflated package"),))+etptbz2path)
|
||||
entropy.tools.aggregate_entropy_metadata(etptbz2path, tmp_path)
|
||||
os.remove(tmp_path)
|
||||
print_info(darkgreen(" * ") + \
|
||||
darkred("%s: " % (_("Inflated package"),)) + \
|
||||
etptbz2path)
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
@@ -381,7 +381,8 @@ class Trigger:
|
||||
"PV": pv, # package version
|
||||
"PR": pr, # package revision (portage)
|
||||
"PVR": pvr, # package version+revision
|
||||
"PVRTE": pvrte, # package version+revision+entropy tag+entropy rev
|
||||
# package version+revision+entropy tag+entropy rev
|
||||
"PVRTE": pvrte,
|
||||
"PER": per, # package entropy revision
|
||||
"PET": pet, # package entropy tag
|
||||
"SLOT": slot, # package slot
|
||||
@@ -389,8 +390,10 @@ class Trigger:
|
||||
"P": p, # complete package atom
|
||||
"WORKDIR": unpackdir, # temporary package workdir
|
||||
"B": unpackdir, # unpacked binary package directory?
|
||||
"D": imagedir, # package unpack destination (before merging to live)
|
||||
"ENTROPY_TMPDIR": etpConst['packagestmpdir'], # entropy temporary directory
|
||||
# package unpack destination (before merging to live)
|
||||
"D": imagedir,
|
||||
# entropy temporary directory
|
||||
"ENTROPY_TMPDIR": etpConst['entropyunpackdir'],
|
||||
"CFLAGS": cflags, # compile flags
|
||||
"CXXFLAGS": cxxflags, # compile flags
|
||||
"CHOST": chost, # *nix CHOST
|
||||
|
||||
@@ -213,8 +213,6 @@ def const_default_settings(rootdir):
|
||||
'backed_up': {},
|
||||
# entropy default installation directory
|
||||
'installdir': '/usr/lib/entropy',
|
||||
# etpConst['packagestmpdir'] --> temp directory
|
||||
'packagestmpdir': default_etp_dir+default_etp_tmpdir,
|
||||
|
||||
# directory where entropy stores its configuration
|
||||
'confdir': default_etp_confdir,
|
||||
|
||||
@@ -1973,7 +1973,7 @@ class EntropyRepositoryBase(TextInterface, EntropyRepositoryPluginStore):
|
||||
|
||||
# now move these dirs
|
||||
for mydir in mydirs:
|
||||
to_path = os.path.join(etpConst['packagestmpdir'],
|
||||
to_path = os.path.join(etpConst['entropyunpackdir'],
|
||||
os.path.basename(mydir))
|
||||
mytxt = "%s: %s '%s' %s '%s'" % (
|
||||
bold(_("SPM")),
|
||||
|
||||
Reference in New Issue
Block a user