1
0
mirror of https://github.com/arsenetar/dupeguru.git synced 2024-12-21 10:59:03 +00:00

Added --arch-pkg option to package.py

Otherwise, AUR packages don't work with Arch lookalikes like Manjaro.
This commit is contained in:
Virgil Dupras 2014-10-17 15:58:45 -04:00
parent 6e7b95b2cf
commit 79800bc6ed
2 changed files with 42 additions and 28 deletions

View File

@ -2,8 +2,8 @@
# Created On: 2009-03-03 # Created On: 2009-03-03
# Copyright 2014 Hardcoded Software (http://www.hardcoded.net) # Copyright 2014 Hardcoded Software (http://www.hardcoded.net)
# This software is licensed under the "BSD" License as described in the "LICENSE" file, # This software is licensed under the "BSD" License as described in the "LICENSE" file,
# which should be included with this package. The terms are also available at # which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license # http://www.hardcoded.net/licenses/bsd_license
"""This module is a collection of function to help in HS apps build process. """This module is a collection of function to help in HS apps build process.
@ -96,7 +96,7 @@ def filereplace(filename, outfilename=None, **kwargs):
fp.close() fp.close()
# We can't use str.format() because in some files, there might be {} characters that mess with it. # We can't use str.format() because in some files, there might be {} characters that mess with it.
for key, item in kwargs.items(): for key, item in kwargs.items():
contents = contents.replace('{{{}}}'.format(key), item) contents = contents.replace('{{{}}}'.format(key), item)
fp = open(outfilename, 'wt', encoding='utf-8') fp = open(outfilename, 'wt', encoding='utf-8')
fp.write(contents) fp.write(contents)
fp.close() fp.close()
@ -106,12 +106,22 @@ def get_module_version(modulename):
return mod.__version__ return mod.__version__
def setup_package_argparser(parser): def setup_package_argparser(parser):
parser.add_argument('--sign', dest='sign_identity', parser.add_argument(
help="Sign app under specified identity before packaging (OS X only)") '--sign', dest='sign_identity',
parser.add_argument('--nosign', action='store_true', dest='nosign', help="Sign app under specified identity before packaging (OS X only)"
help="Don't sign the packaged app (OS X only)") )
parser.add_argument('--src-pkg', action='store_true', dest='src_pkg', parser.add_argument(
help="Build a tar.gz of the current source.") '--nosign', action='store_true', dest='nosign',
help="Don't sign the packaged app (OS X only)"
)
parser.add_argument(
'--src-pkg', action='store_true', dest='src_pkg',
help="Build a tar.gz of the current source."
)
parser.add_argument(
'--arch-pkg', action='store_true', dest='arch_pkg',
help="Force Arch Linux packaging type, regardless of distro name."
)
# `args` come from an ArgumentParser updated with setup_package_argparser() # `args` come from an ArgumentParser updated with setup_package_argparser()
def package_cocoa_app_in_dmg(app_path, destfolder, args): def package_cocoa_app_in_dmg(app_path, destfolder, args):
@ -131,7 +141,7 @@ def package_cocoa_app_in_dmg(app_path, destfolder, args):
def build_dmg(app_path, destfolder): def build_dmg(app_path, destfolder):
"""Builds a DMG volume with application at ``app_path`` and puts it in ``dest_path``. """Builds a DMG volume with application at ``app_path`` and puts it in ``dest_path``.
The name of the resulting DMG volume is determined by the app's name and version. The name of the resulting DMG volume is determined by the app's name and version.
""" """
print(repr(op.join(app_path, 'Contents', 'Info.plist'))) print(repr(op.join(app_path, 'Contents', 'Info.plist')))
@ -176,7 +186,7 @@ def add_to_pythonpath(path):
# from there. # from there.
def copy_packages(packages_names, dest, create_links=False, extra_ignores=None): def copy_packages(packages_names, dest, create_links=False, extra_ignores=None):
"""Copy python packages ``packages_names`` to ``dest``, spurious data. """Copy python packages ``packages_names`` to ``dest``, spurious data.
Copy will happen without tests, testdata, mercurial data or C extension module source with it. Copy will happen without tests, testdata, mercurial data or C extension module source with it.
``py2app`` include and exclude rules are **quite** funky, and doing this is the only reliable ``py2app`` include and exclude rules are **quite** funky, and doing this is the only reliable
way to make sure we don't end up with useless stuff in our app. way to make sure we don't end up with useless stuff in our app.
@ -223,7 +233,7 @@ def copy_qt_plugins(folder_names, dest): # This is only for Windows
def build_debian_changelog(changelogpath, destfile, pkgname, from_version=None, def build_debian_changelog(changelogpath, destfile, pkgname, from_version=None,
distribution='precise', fix_version=None): distribution='precise', fix_version=None):
"""Builds a debian changelog out of a YAML changelog. """Builds a debian changelog out of a YAML changelog.
Use fix_version to patch the top changelog to that version (if, for example, there was a Use fix_version to patch the top changelog to that version (if, for example, there was a
packaging error and you need to quickly fix it) packaging error and you need to quickly fix it)
""" """
@ -233,7 +243,7 @@ def build_debian_changelog(changelogpath, destfile, pkgname, from_version=None,
desc = desc.replace(' ', ' ') desc = desc.replace(' ', ' ')
result = desc.split('*') result = desc.split('*')
return [s.strip() for s in result if s.strip()] return [s.strip() for s in result if s.strip()]
ENTRY_MODEL = "{pkg} ({version}~{distribution}) {distribution}; urgency=low\n\n{changes}\n -- Virgil Dupras <hsoft@hardcoded.net> {date}\n\n" ENTRY_MODEL = "{pkg} ({version}~{distribution}) {distribution}; urgency=low\n\n{changes}\n -- Virgil Dupras <hsoft@hardcoded.net> {date}\n\n"
CHANGE_MODEL = " * {description}\n" CHANGE_MODEL = " * {description}\n"
changelogs = read_changelog_file(changelogpath) changelogs = read_changelog_file(changelogpath)
@ -269,7 +279,7 @@ def read_changelog_file(filename):
date = next(it) date = next(it)
description = next(it) description = next(it)
yield version, date, description yield version, date, description
with open(filename, 'rt', encoding='utf-8') as fp: with open(filename, 'rt', encoding='utf-8') as fp:
contents = fp.read() contents = fp.read()
splitted = re_changelog_header.split(contents)[1:] # the first item is empty splitted = re_changelog_header.split(contents)[1:] # the first item is empty
@ -289,7 +299,7 @@ class OSXAppStructure:
self.resources = op.join(self.contents, 'Resources') self.resources = op.join(self.contents, 'Resources')
self.frameworks = op.join(self.contents, 'Frameworks') self.frameworks = op.join(self.contents, 'Frameworks')
self.infoplist = op.join(self.contents, 'Info.plist') self.infoplist = op.join(self.contents, 'Info.plist')
def create(self, infoplist): def create(self, infoplist):
ensure_empty_folder(self.dest) ensure_empty_folder(self.dest)
os.makedirs(self.macos) os.makedirs(self.macos)
@ -297,24 +307,24 @@ class OSXAppStructure:
os.mkdir(self.frameworks) os.mkdir(self.frameworks)
copy(infoplist, self.infoplist) copy(infoplist, self.infoplist)
open(op.join(self.contents, 'PkgInfo'), 'wt').write("APPLxxxx") open(op.join(self.contents, 'PkgInfo'), 'wt').write("APPLxxxx")
def copy_executable(self, executable): def copy_executable(self, executable):
info = plistlib.readPlist(self.infoplist) info = plistlib.readPlist(self.infoplist)
self.executablename = info['CFBundleExecutable'] self.executablename = info['CFBundleExecutable']
self.executablepath = op.join(self.macos, self.executablename) self.executablepath = op.join(self.macos, self.executablename)
copy(executable, self.executablepath) copy(executable, self.executablepath)
def copy_resources(self, *resources, use_symlinks=False): def copy_resources(self, *resources, use_symlinks=False):
for path in resources: for path in resources:
resource_dest = op.join(self.resources, op.basename(path)) resource_dest = op.join(self.resources, op.basename(path))
action = symlink if use_symlinks else copy action = symlink if use_symlinks else copy
action(op.abspath(path), resource_dest) action(op.abspath(path), resource_dest)
def copy_frameworks(self, *frameworks): def copy_frameworks(self, *frameworks):
for path in frameworks: for path in frameworks:
framework_dest = op.join(self.frameworks, op.basename(path)) framework_dest = op.join(self.frameworks, op.basename(path))
copy(path, framework_dest) copy(path, framework_dest)
def create_osx_app_structure(dest, executable, infoplist, resources=None, frameworks=None, def create_osx_app_structure(dest, executable, infoplist, resources=None, frameworks=None,
symlink_resources=False): symlink_resources=False):
@ -338,7 +348,7 @@ class OSXFrameworkStructure:
self.headers = op.join(self.contents, 'Headers') self.headers = op.join(self.contents, 'Headers')
self.infoplist = op.join(self.resources, 'Info.plist') self.infoplist = op.join(self.resources, 'Info.plist')
self._update_executable_path() self._update_executable_path()
def _update_executable_path(self): def _update_executable_path(self):
if not op.exists(self.infoplist): if not op.exists(self.infoplist):
self.executablename = self.executablepath = None self.executablename = self.executablepath = None
@ -346,7 +356,7 @@ class OSXFrameworkStructure:
info = plistlib.readPlist(self.infoplist) info = plistlib.readPlist(self.infoplist)
self.executablename = info['CFBundleExecutable'] self.executablename = info['CFBundleExecutable']
self.executablepath = op.join(self.contents, self.executablename) self.executablepath = op.join(self.contents, self.executablename)
def create(self, infoplist): def create(self, infoplist):
ensure_empty_folder(self.dest) ensure_empty_folder(self.dest)
os.makedirs(self.contents) os.makedirs(self.contents)
@ -354,7 +364,7 @@ class OSXFrameworkStructure:
os.mkdir(self.headers) os.mkdir(self.headers)
copy(infoplist, self.infoplist) copy(infoplist, self.infoplist)
self._update_executable_path() self._update_executable_path()
def create_symlinks(self): def create_symlinks(self):
# Only call this after create() and copy_executable() # Only call this after create() and copy_executable()
rel = lambda path: op.relpath(path, self.dest) rel = lambda path: op.relpath(path, self.dest)
@ -362,22 +372,22 @@ class OSXFrameworkStructure:
os.symlink(rel(self.executablepath), op.join(self.dest, self.executablename)) os.symlink(rel(self.executablepath), op.join(self.dest, self.executablename))
os.symlink(rel(self.headers), op.join(self.dest, 'Headers')) os.symlink(rel(self.headers), op.join(self.dest, 'Headers'))
os.symlink(rel(self.resources), op.join(self.dest, 'Resources')) os.symlink(rel(self.resources), op.join(self.dest, 'Resources'))
def copy_executable(self, executable): def copy_executable(self, executable):
copy(executable, self.executablepath) copy(executable, self.executablepath)
def copy_resources(self, *resources, use_symlinks=False): def copy_resources(self, *resources, use_symlinks=False):
for path in resources: for path in resources:
resource_dest = op.join(self.resources, op.basename(path)) resource_dest = op.join(self.resources, op.basename(path))
action = symlink if use_symlinks else copy action = symlink if use_symlinks else copy
action(op.abspath(path), resource_dest) action(op.abspath(path), resource_dest)
def copy_headers(self, *headers, use_symlinks=False): def copy_headers(self, *headers, use_symlinks=False):
for path in headers: for path in headers:
header_dest = op.join(self.headers, op.basename(path)) header_dest = op.join(self.headers, op.basename(path))
action = symlink if use_symlinks else copy action = symlink if use_symlinks else copy
action(op.abspath(path), header_dest) action(op.abspath(path), header_dest)
def build_cocoalib_xibless(dest='cocoa/autogen'): def build_cocoalib_xibless(dest='cocoa/autogen'):
import xibless import xibless
@ -415,7 +425,7 @@ def collect_stdlib_dependencies(script, dest_folder, extra_deps=None):
if not (path.startswith(sysprefix) or path.startswith(real_lib_prefix)): if not (path.startswith(sysprefix) or path.startswith(real_lib_prefix)):
return False return False
return True return True
ensure_folder(dest_folder) ensure_folder(dest_folder)
mf = modulefinder.ModuleFinder() mf = modulefinder.ModuleFinder()
mf.run_script(script) mf.run_script(script)

View File

@ -214,7 +214,10 @@ def main():
if ISWINDOWS: if ISWINDOWS:
package_windows(edition, dev) package_windows(edition, dev)
elif ISLINUX: elif ISLINUX:
distname, _, _ = platform.dist() if not args.arch_pkg:
distname, _, _ = platform.dist()
else:
distname = 'arch'
if distname == 'arch': if distname == 'arch':
package_arch(edition) package_arch(edition)
else: else:
@ -224,3 +227,4 @@ def main():
if __name__ == '__main__': if __name__ == '__main__':
main() main()