[game-data-packager] 01/01: port to Arch Linux
Alexandre Detiste
detiste-guest at moszumanska.debian.org
Thu Nov 19 10:44:55 UTC 2015
This is an automated email from the git hooks/post-receive script.
detiste-guest pushed a commit to branch master
in repository game-data-packager.
commit 1ddf4f51ceb85d66a7918e19ec3333dfc6dc4399
Author: Alexandre Detiste <alexandre.detiste at gmail.com>
Date: Thu Nov 19 11:41:57 2015 +0100
port to Arch Linux
---
Makefile | 5 ++-
debian/rules | 1 +
game_data_packager/build.py | 96 +++++++++++++++++++++++++++++++++++++++--
game_data_packager/util.py | 5 +++
game_data_packager/util_arch.py | 58 +++++++++++++++++++++++++
game_data_packager/version.py | 8 ++++
6 files changed, 168 insertions(+), 5 deletions(-)
diff --git a/Makefile b/Makefile
index f4c0043..5e39183 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,9 @@
DIRS := ./out
GDP_MIRROR ?= localhost
-PYFLAKES3 := $(shell test -x /usr/bin/pyflakes3 && echo pyflakes3 || echo python3-pyflakes)
+PYFLAKES3 := $(shell if [ -x /usr/bin/pyflakes3 ] ; then echo pyflakes3 ; \
+ elif [ -x /usr/bin/pyflakes3k ] ; then echo pyflakes3k ; \
+ else echo python3-pyflakes ; \
+ fi)
# some cherry picked games that:
# - are freely downloadable (either demo or full version)
diff --git a/debian/rules b/debian/rules
index d1336a6..1582b6b 100755
--- a/debian/rules
+++ b/debian/rules
@@ -36,6 +36,7 @@ override_dh_install:
touch debian/game-data-packager/usr/share/games/game-data-packager/is-ubuntu-derived; \
fi
install -D -m755 runtime/doom2-masterlevels.py debian/game-data-packager/usr/games/doom2-masterlevels
+ rm -f debian/game-data-packager/usr/share/games/game-data-packager/game_data_packager/util_arch.py
rm -f debian/game-data-packager/usr/share/games/game-data-packager/game_data_packager/util_rpm.py
override_dh_installdocs:
diff --git a/game_data_packager/build.py b/game_data_packager/build.py
index c165f3c..dd18f01 100644
--- a/game_data_packager/build.py
+++ b/game_data_packager/build.py
@@ -1429,6 +1429,44 @@ class PackagingTask(object):
def fill_extra_files(self, package, destdir):
pass
+ def fill_dest_dir_arch(self, package, destdir, compress):
+ files = set()
+ for dirpath, dirnames, filenames in os.walk(destdir):
+ for fn in filenames:
+ full = os.path.join(dirpath, fn)
+ full = full[len(destdir)+1:]
+ files.add(full)
+
+ PKGINFO = os.path.join(destdir, '.PKGINFO')
+ short_desc, _ = self.generate_description(package)
+ size = check_output(['du','-bs','.'], cwd=destdir)
+ size = int(size.split()[0])
+ with open(PKGINFO, 'w', encoding='utf-8') as pkginfo:
+ pkginfo.write('# Generated by game-data-packager %s\n' % package.version.split('+')[-1])
+ pkginfo.write('# using fakeroot version %s\n' % PACKAGE_CACHE.current_version('fakeroot'))
+ pkginfo.write('# %s\n' % time.strftime("%a %b %d %H:%M:%S UTC %Y", time.gmtime()))
+ pkginfo.write('pkgname = %s\n' % package.name)
+ pkginfo.write('pkgver = %s\n' % package.version)
+ pkginfo.write('pkgdesc = %s\n' % short_desc)
+ pkginfo.write('url = https://wiki.debian.org/Games/GameDataPackager\n')
+ pkginfo.write('builddate = %i\n' % int(time.time()))
+ pkginfo.write('packager = Alexandre Detiste <alexandre at detiste.be>\n')
+ pkginfo.write('size = %i\n' % size)
+ pkginfo.write('arch = any\n')
+ pkginfo.write('license = Commercial\n')
+ pkginfo.write('group = games\n')
+ if package.expansion_for:
+ pkginfo.write('depend = %s\n' % package.expansion_for)
+ else:
+ engine = package.engine or self.game.engine
+ if engine and len(engine.split()) == 1:
+ pkginfo.write('depend = %s\n' % engine)
+
+ MTREE = os.path.join(destdir, '.MTREE')
+ subprocess.check_call(['bsdtar', '-czf', MTREE, '--format=mtree',
+ '--options=!all,use-set,type,uid,gid,mode,time,size,md5,sha256,link']
+ + sorted(files), env={'LANG':'C'}, cwd=destdir)
+
def fill_dest_dir_rpm(self, package, destdir, compress):
specfile = os.path.join(self.get_workdir(), '%s.spec' % package.name)
short_desc, long_desc = self.generate_description(package)
@@ -2066,9 +2104,16 @@ class PackagingTask(object):
arch = check_output(['rpm', '-q', '--qf', '%{ARCH}\n',
'rpm']).strip().decode('ascii')
self._architecture = { 'armhfp': 'armhf',
+ 'i686': 'i386',
'x86_64': 'amd64',
}.get(arch, arch)
self._foreign_architectures = set()
+ elif FORMAT == 'arch':
+ arch = check_output(['uname', '-m']).strip().decode('ascii')
+ self._architecture = { 'x86_64': 'amd64',
+ 'i686': 'i386',
+ }.get(arch, arch)
+ self._foreign_architectures = set()
if archs:
# In theory this should deal with wildcards like linux-any,
@@ -2334,6 +2379,8 @@ class PackagingTask(object):
pkg = self.build_deb(package, destination, compress=compress)
elif FORMAT == 'rpm':
pkg = self.build_rpm(package, compress=compress)
+ elif FORMAT == 'arch':
+ pkg = self.build_arch(package, destination, compress=compress)
if pkg is None:
raise SystemExit(1)
@@ -2510,6 +2557,40 @@ class PackagingTask(object):
rm_rf(destdir)
return outfile
+
+ def build_arch(self, package, destination, compress=True):
+ destdir = os.path.join(self.get_workdir(), '%s.deb.d' % package.name)
+
+ if not self.fill_dest_dir(package, destdir):
+ return None
+
+ self.fill_dest_dir_arch(package, destdir, compress)
+ self.our_dh_fixperms(destdir)
+
+ assert os.path.isdir(os.path.join(destdir, 'usr')), destdir
+ assert os.path.isfile(os.path.join(destdir, '.PKGINFO')), destdir
+ assert os.path.isfile(os.path.join(destdir, '.MTREE')), destdir
+
+ arch = package.architecture
+ if arch != 'all':
+ arch = self.get_architecture(arch)
+ if arch == 'all':
+ arch = 'any'
+
+ pkg_basename = '%s-%s-%s.pkg.tar.xz' % (package.name, package.version, arch)
+ outfile = os.path.join(os.path.abspath(destination), pkg_basename)
+
+ try:
+ logger.info('generating package %s', package.name)
+ check_output(['fakeroot', 'tar', 'cfJv', outfile, '.'],
+ cwd=destdir)
+ except subprocess.CalledProcessError as cpe:
+ print(cpe.output)
+ raise
+
+ rm_rf(destdir)
+ return outfile
+
def build_rpm(self, package, compress=True):
destdir = os.path.join(self.get_workdir(), '%s.deb.d' % package.name)
@@ -2574,7 +2655,7 @@ class PackagingTask(object):
return False
if FORMAT == 'deb':
- command = 'apt-get'
+ command = 'apt-get install'
package_map = {
'id-shr-extract': 'dynamite',
'lha': 'lhasa',
@@ -2582,13 +2663,20 @@ class PackagingTask(object):
'unrar-nonfree': 'unrar',
}
elif FORMAT == 'rpm':
- command = 'dnf'
+ command = 'dnf install'
package_map = {
'dpkg-deb': 'dpkg',
- 'id-shr-extract': 'dynamite',
+ 'id-shr-extract': None,
'7z': 'p7zip-plugins',
'unrar-nonfree': 'unrar',
}
+ elif FORMAT == 'arch':
+ command = 'pacman -S'
+ package_map = {
+ 'id-shr-extract': None,
+ '7z': 'p7zip',
+ # XXX
+ }
packages = set()
@@ -2598,4 +2686,4 @@ class PackagingTask(object):
packages.add(p)
logger.warning('installing these packages might help:\n' +
- '%s install %s', command, ' '.join(sorted(packages)))
+ '%s %s', command, ' '.join(sorted(packages)))
diff --git a/game_data_packager/util.py b/game_data_packager/util.py
index 03f6208..eb23090 100644
--- a/game_data_packager/util.py
+++ b/game_data_packager/util.py
@@ -213,6 +213,7 @@ def recursive_utime(directory, orig_time):
full = os.path.join(dirpath, fn)
os.utime(full, orig_time)
+# https://wiki.archlinux.org/index.php/Pacman/Rosetta
# loaded at the end to avoid failed cyclic loads
if FORMAT == 'deb':
@@ -220,6 +221,10 @@ if FORMAT == 'deb':
install_packages,
lintian_license,
lintian_desktop)
+elif FORMAT == 'arch':
+ from .util_arch import (PACKAGE_CACHE, install_packages)
+ lintian_license = lambda a,b,c: None
+ lintian_desktop = lambda a,b,c: None
else:
from .util_rpm import (PACKAGE_CACHE, install_packages)
lintian_license = lambda a,b,c: None
diff --git a/game_data_packager/util_arch.py b/game_data_packager/util_arch.py
new file mode 100644
index 0000000..33438f3
--- /dev/null
+++ b/game_data_packager/util_arch.py
@@ -0,0 +1,58 @@
+#!/usr/bin/python3
+# encoding=utf-8
+#
+# Copyright © 2015 Alexandre Detiste <alexandre at detiste.be>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+import logging
+import subprocess
+
+from .util import (run_as_root, check_output)
+
+logger = logging.getLogger('game-data-packager.util_arch')
+
+class PackageCache:
+ def is_installed(self, package):
+ return subprocess.call(['pacman', '-Q', package],
+ stdout=subprocess.DEVNULL,
+ stderr=subprocess.DEVNULL) == 0
+
+ def is_available(self, package):
+ return subprocess.call(['pacman', '-Si', package],
+ stdout=subprocess.DEVNULL,
+ stderr=subprocess.DEVNULL) == 0
+
+ def current_version(self, package):
+ try:
+ return check_output(['pacman', '-Q', package],
+ stderr=subprocess.DEVNULL,
+ universal_newlines=True).split()[1]
+ except subprocess.CalledProcessError:
+ return
+
+ def available_version(self, package):
+ try:
+ remote_info = check_output(['pacman', '-Si', package],
+ universal_newlines=True,
+ env={'LANG':'C'})
+ for line in remote_info.splitlines():
+ k, _, v = line.split(maxsplit=2)
+ if k == 'Version':
+ return v
+
+ except subprocess.CalledProcessError:
+ return
+
+PACKAGE_CACHE = PackageCache()
+
+def install_packages(pkgs, method, gain_root='su'):
+ """Install one or more packages (a list of filenames)."""
+ run_as_root(['pacman', '-U'] + list(pkgs), gain_root)
diff --git a/game_data_packager/version.py b/game_data_packager/version.py
index e9bc759..d7c86cd 100644
--- a/game_data_packager/version.py
+++ b/game_data_packager/version.py
@@ -21,3 +21,11 @@ elif os.path.isfile('/etc/redhat-release'):
cl = open('debian/changelog', encoding='utf-8').readline()
GAME_PACKAGE_VERSION = cl.split('(')[1].split(')')[0]
+
+elif os.path.isfile('/etc/arch-release'):
+ FORMAT = 'arch'
+ BINDIR = 'usr/bin'
+ ASSETS = 'usr/share'
+
+ cl = open('debian/changelog', encoding='utf-8').readline()
+ GAME_PACKAGE_VERSION = cl.split('(')[1].split(')')[0]
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/game-data-packager.git
More information about the Pkg-games-commits
mailing list