Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
845 additions
and
261 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Who has contributed to the PGXN client? | ||
======================================= | ||
|
||
Daniele Varrazzo | ||
|
||
He rushed to implement a client before David could do it in Perl! | ||
|
||
David Wheeler | ||
|
||
He is the PGXN mastermind: a lot of helpful design discussions. | ||
|
||
Peter Eisentraut | ||
|
||
First implementation of tarball support. Auto-sudo is not a good idea, I | ||
got it. | ||
|
||
Hitoshi Harada | ||
|
||
Tricky installation corner cases. | ||
|
||
Andrey Popp | ||
|
||
Make selection. Helped the program not to suck on BSD! | ||
|
||
Also thank you everybody for the useful discussions on the PGXN mailing list, | ||
bug reports, proofreading the docs and the general support to the project. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
""" | ||
pgxnclient -- archives handling | ||
""" | ||
|
||
# Copyright (C) 2011-2012 Daniele Varrazzo | ||
|
||
# This file is part of the PGXN client | ||
|
||
import os | ||
|
||
from pgxnclient.i18n import _ | ||
from pgxnclient.utils import load_jsons | ||
from pgxnclient.errors import PgxnClientException | ||
|
||
def from_spec(spec): | ||
"""Return an `Archive` instance to handle the file requested by *spec* | ||
""" | ||
assert spec.is_file() | ||
return from_file(spec.filename) | ||
|
||
def from_file(filename): | ||
"""Return an `Archive` instance to handle the file *filename* | ||
""" | ||
from pgxnclient.zip import ZipArchive | ||
from pgxnclient.tar import TarArchive | ||
|
||
for cls in (ZipArchive, TarArchive): | ||
a = cls(filename) | ||
if a.can_open(): | ||
return a | ||
|
||
raise PgxnClientException( | ||
_("can't open archive '%s': file type not recognized") | ||
% filename) | ||
|
||
|
||
class Archive(object): | ||
"""Base class to handle archives.""" | ||
def __init__(self, filename): | ||
self.filename = filename | ||
|
||
def can_open(self): | ||
"""Return `!True` if the `!filename` can be opened by the obect.""" | ||
raise NotImplementedError | ||
|
||
def open(self): | ||
"""Open the archive for usage. | ||
Raise PgxnClientException if the archive can't be open. | ||
""" | ||
raise NotImplementedError | ||
|
||
def close(self): | ||
"""Close the archive after usage.""" | ||
raise NotImplementedError | ||
|
||
def list_files(self): | ||
"""Return an iterable with the list of file names in the archive.""" | ||
raise NotImplementedError | ||
|
||
def read(self, fn): | ||
"""Return a file's data from the archive.""" | ||
raise NotImplementedError | ||
|
||
def unpack(self, destdir): | ||
raise NotImplementedError | ||
|
||
def get_meta(self): | ||
filename = self.filename | ||
|
||
self.open() | ||
try: | ||
# Return the first file with the expected name | ||
for fn in self.list_files(): | ||
if fn.endswith('META.json'): | ||
return load_jsons(self.read(fn).decode('utf8')) | ||
else: | ||
raise PgxnClientException( | ||
_("file 'META.json' not found in archive '%s'") % filename) | ||
finally: | ||
self.close() | ||
|
||
def _find_work_directory(self, destdir): | ||
""" | ||
Choose the directory where to work. | ||
Because we are mostly a wrapper for pgxs, let's look for a makefile. | ||
The tar should contain a single base directory, so return the first | ||
dir we found containing a Makefile, alternatively just return the | ||
unpacked dir | ||
""" | ||
for dir in os.listdir(destdir): | ||
for fn in ('Makefile', 'makefile', 'GNUmakefile', 'configure'): | ||
if os.path.exists(os.path.join(destdir, dir, fn)): | ||
return os.path.join(destdir, dir) | ||
|
||
return destdir | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -122,3 +122,6 @@ def _get_exec(cmd): | |
|
||
return fn | ||
|
||
if __name__ == '__main__': | ||
script() | ||
|
Oops, something went wrong.