a lot of work is taking place, something could be a little bit broken, please be patient
git-svn-id: http://svn.sabayonlinux.org/projects/entropy/trunk@600 cd1c1023-2f26-0410-ae45-c471fc1f0318
This commit is contained in:
+107
-72
@@ -98,89 +98,126 @@ def update(options):
|
||||
# collect differences between the packages in the database and the ones on the system
|
||||
|
||||
reagentRequestSeekStore = False
|
||||
reagentRequestRepackage = False
|
||||
repackageItems = []
|
||||
_options = []
|
||||
for opt in options:
|
||||
if opt.startswith("--seekstore"):
|
||||
reagentRequestSeekStore = True
|
||||
elif opt.startswith("--repackage"):
|
||||
reagentRequestRepackage = True
|
||||
else:
|
||||
if (reagentRequestRepackage) and (not opt.startswith("--")):
|
||||
if not opt in repackageItems:
|
||||
repackageItems.append(opt)
|
||||
continue
|
||||
_options.append(opt)
|
||||
options = _options
|
||||
|
||||
|
||||
if (not reagentRequestSeekStore):
|
||||
|
||||
print_info(yellow(" * ")+red("Scanning the database for differences..."))
|
||||
dbconn = databaseTools.etpDatabase(readOnly = True, noUpload = True)
|
||||
from portageTools import getInstalledPackagesCounters, quickpkg, getPackageSlot
|
||||
installedPackages = getInstalledPackagesCounters()
|
||||
installedCounters = {}
|
||||
databasePackages = dbconn.listAllPackages()
|
||||
toBeAdded = []
|
||||
toBeRemoved = []
|
||||
|
||||
# fill lists
|
||||
|
||||
# packages to be added
|
||||
for x in installedPackages[0]:
|
||||
installedCounters[x[1]] = 1
|
||||
counter = dbconn.isCounterAvailable(x[1])
|
||||
if (not counter):
|
||||
toBeAdded.append(x)
|
||||
|
||||
if (not reagentRequestRepackage):
|
||||
print_info(yellow(" * ")+red("Scanning the database for differences..."))
|
||||
from portageTools import getInstalledPackagesCounters, quickpkg, getPackageSlot
|
||||
installedPackages = getInstalledPackagesCounters()
|
||||
installedCounters = {}
|
||||
databasePackages = dbconn.listAllPackages()
|
||||
toBeAdded = []
|
||||
toBeRemoved = []
|
||||
|
||||
# packages to be added
|
||||
for x in installedPackages[0]:
|
||||
installedCounters[x[1]] = 1
|
||||
counter = dbconn.isCounterAvailable(x[1])
|
||||
if (not counter):
|
||||
toBeAdded.append(x)
|
||||
|
||||
# packages to be removed from the database
|
||||
databaseCounters = dbconn.listAllCounters()
|
||||
for x in databaseCounters:
|
||||
match = installedCounters.get(x[0], None)
|
||||
#print match
|
||||
if (not match):
|
||||
# check if the package is in toBeAdded
|
||||
if (toBeAdded):
|
||||
atomkey = dep_getkey(dbconn.retrieveAtom(x[1]))
|
||||
atomslot = dbconn.retrieveSlot(x[1])
|
||||
add = True
|
||||
for pkgdata in toBeAdded:
|
||||
addslot = getPackageSlot(pkgdata[0])
|
||||
addkey = dep_getkey(pkgdata[0])
|
||||
# workaround for ebuilds not having slot
|
||||
if addslot == None:
|
||||
addslot = ''
|
||||
if (atomkey == addkey) and (atomslot == addslot):
|
||||
# do not add to toBeRemoved
|
||||
add = False
|
||||
break
|
||||
if add:
|
||||
toBeRemoved.append(x[1])
|
||||
else:
|
||||
toBeRemoved.append(x[1])
|
||||
|
||||
if (not toBeRemoved) and (not toBeAdded):
|
||||
print_info(yellow(" * ")+red("Nothing to do, check later."))
|
||||
# then exit gracefully
|
||||
sys.exit(0)
|
||||
|
||||
if (toBeRemoved):
|
||||
print_info(yellow(" @@ ")+blue("These are the packages that would be removed from the database:"))
|
||||
for x in toBeRemoved:
|
||||
atom = dbconn.retrieveAtom(x)
|
||||
print_info(yellow(" # ")+red(atom))
|
||||
rc = askquestion(">> Would you like to remove them now ?")
|
||||
if rc == "Yes":
|
||||
rwdbconn = databaseTools.etpDatabase(readOnly = False, noUpload = True)
|
||||
for x in toBeRemoved:
|
||||
atom = rwdbconn.retrieveAtom(x)
|
||||
print_info(yellow(" @@ ")+blue("Removing from database: ")+red(atom), back = True)
|
||||
rwdbconn.removePackage(x)
|
||||
rwdbconn.closeDB()
|
||||
print_info(yellow(" @@ ")+blue("Database removal complete."))
|
||||
|
||||
if (toBeAdded):
|
||||
print_info(yellow(" @@ ")+blue("These are the packages that would be added/updated to the add list:"))
|
||||
for x in toBeAdded:
|
||||
print_info(yellow(" # ")+red(x[0]))
|
||||
rc = askquestion(">> Would you like to packetize them now ?")
|
||||
if rc == "No":
|
||||
# packages to be removed from the database
|
||||
databaseCounters = dbconn.listAllCounters()
|
||||
for x in databaseCounters:
|
||||
match = installedCounters.get(x[0], None)
|
||||
#print match
|
||||
if (not match):
|
||||
# check if the package is in toBeAdded
|
||||
if (toBeAdded):
|
||||
atomkey = dep_getkey(dbconn.retrieveAtom(x[1]))
|
||||
atomslot = dbconn.retrieveSlot(x[1])
|
||||
add = True
|
||||
for pkgdata in toBeAdded:
|
||||
addslot = getPackageSlot(pkgdata[0])
|
||||
addkey = dep_getkey(pkgdata[0])
|
||||
# workaround for ebuilds not having slot
|
||||
if addslot == None:
|
||||
addslot = ''
|
||||
if (atomkey == addkey) and (atomslot == addslot):
|
||||
# do not add to toBeRemoved
|
||||
add = False
|
||||
break
|
||||
if add:
|
||||
toBeRemoved.append(x[1])
|
||||
else:
|
||||
toBeRemoved.append(x[1])
|
||||
|
||||
if (not toBeRemoved) and (not toBeAdded):
|
||||
print_info(yellow(" * ")+red("Nothing to do, check later."))
|
||||
# then exit gracefully
|
||||
sys.exit(0)
|
||||
|
||||
if (toBeRemoved):
|
||||
print_info(yellow(" @@ ")+blue("These are the packages that would be removed from the database:"))
|
||||
for x in toBeRemoved:
|
||||
atom = dbconn.retrieveAtom(x)
|
||||
print_info(yellow(" # ")+red(atom))
|
||||
rc = askquestion(">> Would you like to remove them now ?")
|
||||
if rc == "Yes":
|
||||
rwdbconn = databaseTools.etpDatabase(readOnly = False, noUpload = True)
|
||||
for x in toBeRemoved:
|
||||
atom = rwdbconn.retrieveAtom(x)
|
||||
print_info(yellow(" @@ ")+blue("Removing from database: ")+red(atom), back = True)
|
||||
rwdbconn.removePackage(x)
|
||||
rwdbconn.closeDB()
|
||||
print_info(yellow(" @@ ")+blue("Database removal complete."))
|
||||
|
||||
if (toBeAdded):
|
||||
print_info(yellow(" @@ ")+blue("These are the packages that would be added/updated to the add list:"))
|
||||
for x in toBeAdded:
|
||||
print_info(yellow(" # ")+red(x[0]))
|
||||
rc = askquestion(">> Would you like to packetize them now ?")
|
||||
if rc == "No":
|
||||
sys.exit(0)
|
||||
|
||||
else:
|
||||
if not repackageItems:
|
||||
print_info(yellow(" * ")+red("Nothing to do, check later."))
|
||||
# then exit gracefully
|
||||
sys.exit(0)
|
||||
|
||||
from portageTools import getPortageAppDbPath,quickpkg
|
||||
appdb = getPortageAppDbPath()
|
||||
|
||||
packages = []
|
||||
for item in repackageItems:
|
||||
match = dbconn.atomMatch(item)
|
||||
if match[0] == -1:
|
||||
print_warning(darkred(" !!! ")+red("Cannot match ")+bold(item))
|
||||
else:
|
||||
cat = dbconn.retrieveCategory(match[0])
|
||||
name = dbconn.retrieveName(match[0])
|
||||
version = dbconn.retrieveVersion(match[0])
|
||||
slot = dbconn.retrieveSlot(match[0])
|
||||
if os.path.isdir(appdb+"/"+cat+"/"+name+"-"+version):
|
||||
packages.append([cat+"/"+name+"-"+version,0])
|
||||
|
||||
# FIXME: complete this
|
||||
if not packages:
|
||||
print_info(yellow(" * ")+red("Nothing to do, check later."))
|
||||
# then exit gracefully
|
||||
sys.exit(0)
|
||||
|
||||
toBeAdded = packages
|
||||
|
||||
# package them
|
||||
print_info(yellow(" @@ ")+blue("Compressing packages..."))
|
||||
for x in toBeAdded:
|
||||
@@ -324,9 +361,7 @@ def extractPkgData(package, etpBranch = etpConst['branch']):
|
||||
f.close()
|
||||
|
||||
print_info(yellow(" * ")+red(info_package+"Setting package branch..."),back = True)
|
||||
# always unstable when created
|
||||
i = etpConst['branches'].index(etpBranch)
|
||||
etpData['branch'] = etpConst['branches'][i]
|
||||
etpData['branch'] = etpBranch
|
||||
|
||||
print_info(yellow(" * ")+red(info_package+"Getting package description..."),back = True)
|
||||
# Fill description
|
||||
|
||||
Reference in New Issue
Block a user