Commit 5da131b2 authored by Jack Jansen's avatar Jack Jansen

Added two keys to database format: User-install-skips is an array of pathname

prefixes, any file that is skipped during a per-user install that matches
this set is *not* an error; Systemwide-only is a boolean that says the
package cannot be installer per-user.
parent 2a97dcce
...@@ -78,7 +78,7 @@ class PimpUnpacker: ...@@ -78,7 +78,7 @@ class PimpUnpacker:
self._dir = dir self._dir = dir
self._renames = renames self._renames = renames
def unpack(self, archive, output=None): def unpack(self, archive, output=None, package=None):
return None return None
class PimpCommandUnpacker(PimpUnpacker): class PimpCommandUnpacker(PimpUnpacker):
...@@ -86,7 +86,7 @@ class PimpCommandUnpacker(PimpUnpacker): ...@@ -86,7 +86,7 @@ class PimpCommandUnpacker(PimpUnpacker):
_can_rename = False _can_rename = False
def unpack(self, archive, output=None): def unpack(self, archive, output=None, package=None):
cmd = self.argument % archive cmd = self.argument % archive
if _cmd(output, self._dir, cmd): if _cmd(output, self._dir, cmd):
return "unpack command failed" return "unpack command failed"
...@@ -96,7 +96,7 @@ class PimpTarUnpacker(PimpUnpacker): ...@@ -96,7 +96,7 @@ class PimpTarUnpacker(PimpUnpacker):
_can_rename = True _can_rename = True
def unpack(self, archive, output=None): def unpack(self, archive, output=None, package=None):
tf = tarfile.open(archive, "r") tf = tarfile.open(archive, "r")
members = tf.getmembers() members = tf.getmembers()
skip = [] skip = []
...@@ -132,6 +132,8 @@ class PimpTarUnpacker(PimpUnpacker): ...@@ -132,6 +132,8 @@ class PimpTarUnpacker(PimpUnpacker):
tf.extract(member, self._dir) tf.extract(member, self._dir)
if skip: if skip:
names = [member.name for member in skip if member.name[-1] != '/'] names = [member.name for member in skip if member.name[-1] != '/']
if package:
names = package.filterExpectedSkips(names)
if names: if names:
return "Not all files were unpacked: %s" % " ".join(names) return "Not all files were unpacked: %s" % " ".join(names)
...@@ -181,6 +183,9 @@ class PimpPreferences: ...@@ -181,6 +183,9 @@ class PimpPreferences:
self.installLocations = [] self.installLocations = []
self.installDir = installDir self.installDir = installDir
def isUserInstall(self):
return self.installDir != DEFAULT_INSTALLDIR
def check(self): def check(self):
"""Check that the preferences make sense: directories exist and are """Check that the preferences make sense: directories exist and are
writable, the install directory is on sys.path, etc.""" writable, the install directory is on sys.path, etc."""
...@@ -370,7 +375,9 @@ ALLOWED_KEYS = [ ...@@ -370,7 +375,9 @@ ALLOWED_KEYS = [
"Pre-install-command", "Pre-install-command",
"Post-install-command", "Post-install-command",
"Prerequisites", "Prerequisites",
"MD5Sum" "MD5Sum",
"User-install-skips",
"Systemwide-only",
] ]
class PimpPackage: class PimpPackage:
...@@ -394,6 +401,7 @@ class PimpPackage: ...@@ -394,6 +401,7 @@ class PimpPackage:
def shortdescription(self): return self.description().splitlines()[0] def shortdescription(self): return self.description().splitlines()[0]
def homepage(self): return self._dict.get('Home-page') def homepage(self): return self._dict.get('Home-page')
def downloadURL(self): return self._dict.get('Download-URL') def downloadURL(self): return self._dict.get('Download-URL')
def systemwideOnly(self): return self._dict.get('Systemwide-only')
def fullname(self): def fullname(self):
"""Return the full name "name-version-flavor" of a package. """Return the full name "name-version-flavor" of a package.
...@@ -485,6 +493,10 @@ class PimpPackage: ...@@ -485,6 +493,10 @@ class PimpPackage:
return [(None, return [(None,
"%s: This package cannot be installed automatically (no Download-URL field)" % "%s: This package cannot be installed automatically (no Download-URL field)" %
self.fullname())] self.fullname())]
if self.systemwideOnly() and self._db.preferences.isUserInstall():
return [(None,
"%s: This package can only be installed system-wide" %
self.fullname())]
if not self._dict.get('Prerequisites'): if not self._dict.get('Prerequisites'):
return [] return []
for item in self._dict['Prerequisites']: for item in self._dict['Prerequisites']:
...@@ -617,6 +629,22 @@ class PimpPackage: ...@@ -617,6 +629,22 @@ class PimpPackage:
if not line in sys.path: if not line in sys.path:
sys.path.append(line) sys.path.append(line)
def filterExpectedSkips(self, names):
"""Return a list that contains only unpexpected skips"""
if not self._db.preferences.isUserInstall():
return names
expected_skips = self._dict.get('User-install-skips')
if not expected_skips:
return names
newnames = []
for name in names:
for skip in expected_skips:
if name[:len(skip)] == skip:
break
else:
newnames.append(name)
return newnames
class PimpPackage_binary(PimpPackage): class PimpPackage_binary(PimpPackage):
def unpackPackageOnly(self, output=None): def unpackPackageOnly(self, output=None):
...@@ -659,7 +687,7 @@ class PimpPackage_binary(PimpPackage): ...@@ -659,7 +687,7 @@ class PimpPackage_binary(PimpPackage):
install_renames.append((oldloc, newloc)) install_renames.append((oldloc, newloc))
unpacker = unpackerClass(arg, dir="/", renames=install_renames) unpacker = unpackerClass(arg, dir="/", renames=install_renames)
rv = unpacker.unpack(self.archiveFilename, output=output) rv = unpacker.unpack(self.archiveFilename, output=output, package=self)
if rv: if rv:
return rv return rv
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment