Skip to content
Snippets Groups Projects
Commit 9c836f27 authored by Simon McVittie's avatar Simon McVittie
Browse files

Remove flatdeb common files

parent 2a31ce85
No related branches found
No related tags found
No related merge requests found
all:
if ! [ -d /var/lib/dpkg ]; then \
cp -a /usr/var /; \
fi
set -e; \
if test -d src; then \
cd src && \
dpkg-buildpackage -b -nc -d \
--build-profiles=pkg.flatpak.app,nocheck,nodoc; \
fi; \
done
# This assumes we don't need to run maintainer scripts.
install:
set -e; \
for deb in *.deb; do \
dpkg-deb --fsys-tarfile "$$deb" | \
tar -xf- -C /app \
--transform='s,^(\.?/)?(app|usr)/,,x'; \
done
#!/bin/sh
if [ ! -e Makefile ]; then
cp "$(dirname "$0")/Makefile" Makefile
fi
exit 0
# Copyright © 2017 Collabora Ltd.
#
# Partially derived from vectis, copyright © 2015-2017 Simon McVittie
#
# SPDX-License-Identifier: MIT
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import os
import shlex
import subprocess
import sys
from abc import abstractmethod, ABCMeta
from contextlib import ExitStack, contextmanager
from tempfile import TemporaryDirectory
class Worker(metaclass=ABCMeta):
"""
A (possibly remote) machine to which we have shell access.
It is a context manager.
"""
def __init__(self):
super().__init__()
self.__depth = 0
self.stack = ExitStack()
def __enter__(self):
self.__depth += 1
if self.__depth == 1:
self._open()
return self
def __exit__(self, et, ev, tb):
self.__depth -= 1
if self.__depth:
return False
else:
return self.stack.__exit__(et, ev, tb)
@abstractmethod
def _open(self):
pass
@abstractmethod
def call(self, argv, **kwargs):
pass
@abstractmethod
def check_call(self, argv, **kwargs):
pass
@abstractmethod
def check_output(self, argv, **kwargs):
pass
@abstractmethod
def install_file(self, source, destination, permissions=0o644):
pass
@abstractmethod
def remote_dir_context(self, path):
"""
Return a context manager. Entering the context manager makes path
available as a filesystem directory for the caller, returning
the transformed path (possibly a sshfs or similar). Leaving the
context manager cleans up.
"""
class NspawnWorker(Worker):
def __init__(self, worker, path, env=()):
super().__init__()
self.worker = worker
self.path = path
self.env = list(env)
def _open(self):
pass
def call(self, argv, **kwargs):
return self.worker.check_call(
[
'systemd-nspawn',
'--directory={}'.format(self.path),
'--as-pid2',
'env',
] + self.env + list(argv),
**kwargs,
)
def check_call(self, argv, **kwargs):
self.worker.check_call(
[
'systemd-nspawn',
'--directory={}'.format(self.path),
'--as-pid2',
'env',
] + self.env + list(argv),
**kwargs,
)
def check_output(self, argv, **kwargs):
return self.worker.check_output(
[
'systemd-nspawn',
'--directory={}'.format(self.path),
'--as-pid2',
'env',
] + self.env + list(argv),
**kwargs,
)
def install_file(self, source, destination, permissions=0o644):
self.worker.install_file(
source,
'{}/{}'.format(self.path, destination),
permissions,
)
def write_manifest(self):
with TemporaryDirectory(prefix='flatdeb-manifest.') as t:
manifest = os.path.join(t, 'manifest')
with open(manifest, 'w') as writer:
self.check_call([
'dpkg-query', '-W',
'-f', (
r'${binary:Package}\t${Version}\t'
r'${source:Package}\t${source:Version}\t'
r'${Installed-Size}\t${Status}\n'
),
], stdout=writer)
self.install_file(manifest, '/usr/manifest.dpkg')
@contextmanager
def remote_dir_context(self, path):
yield os.path.normpath(os.path.join(self.path, './' + path))
class SudoWorker(Worker):
"""
Adapter to get root using sudo.
"""
def __init__(self, worker):
super().__init__()
self.__scratch = None
self.__worker = worker
def _open(self):
self.stack.enter_context(self.__worker)
self.stack.callback(
lambda:
self.check_call([
'rm', '-fr', '--one-file-system',
os.path.join(self.scratch),
]),
)
self.__worker.check_call([
'mkdir', '-p', os.path.join(self.__worker.scratch, 'root')
])
@property
def scratch(self):
return os.path.join(self.__worker.scratch, 'root')
def call(self, argv, **kwargs):
return self.__worker.call(
['env', '-', '/usr/bin/sudo', '-H'] + argv,
**kwargs,
)
def check_call(self, argv, **kwargs):
self.__worker.check_call(
['env', '-', '/usr/bin/sudo', '-H'] + argv,
**kwargs,
)
def check_output(self, argv, **kwargs):
return self.__worker.check_output(
['env', '-', '/usr/bin/sudo', '-H'] + argv,
**kwargs,
)
def install_file(self, source, destination, permissions=0o644):
permissions = oct(permissions)
if permissions.startswith('0o'):
permissions = permissions[2:]
self.check_call([
'sh', '-euc',
'exec cat > "$1"/install',
'sh',
self.scratch,
], stdin=open(source, 'rb'))
self.check_call([
'install', '-m' + permissions,
'{}/install'.format(self.scratch),
destination,
])
@contextmanager
def remote_dir_context(self, path):
yield path
class HostWorker(Worker):
"""
The host machine, with unprivileged access.
"""
def __init__(self):
super().__init__()
self.__scratch = None
def _open(self):
self.__scratch = self.stack.enter_context(
TemporaryDirectory(prefix='flatdeb-host.')
)
@property
def scratch(self):
return self.__scratch
@staticmethod
def check_call(argv, **kwargs):
print('host:', repr(argv), file=sys.stderr)
subprocess.check_call(argv, **kwargs)
@staticmethod
def Popen(argv, **kwargs):
print('host:', repr(argv), file=sys.stderr)
return subprocess.Popen(argv, **kwargs)
@staticmethod
def call(argv, **kwargs):
print('host:', repr(argv), file=sys.stderr)
return subprocess.call(argv, **kwargs)
@staticmethod
def check_output(argv, **kwargs):
print('host:', repr(argv), file=sys.stderr)
return subprocess.check_output(argv, **kwargs)
def install_file(self, source, destination, permissions=0o644):
permissions = oct(permissions)
if permissions.startswith('0o'):
permissions = permissions[2:]
self.check_call([
'install', '-m' + permissions, source, destination,
])
@contextmanager
def remote_dir_context(self, path):
yield path
class SshWorker(Worker):
"""
A machine we can ssh to.
"""
def __init__(self, remote):
super().__init__()
self.remote = remote
self.__scratch = None
def _open(self):
self.__scratch = self.check_output(
['mktemp', '-d', '-p', '/tmp', 'flatdeb-ssh-worker.XXXXXX'],
universal_newlines=True,
).rstrip('\n')
self.stack.callback(
lambda:
self.check_call([
'rm', '-fr', '--one-file-system', self.__scratch,
]),
)
@property
def scratch(self):
return self.__scratch
def call(self, argv, **kwargs):
print('{}:'.format(self.remote), repr(argv), file=sys.stderr)
if isinstance(argv, str):
command_line = argv
else:
command_line = ' '.join(map(shlex.quote, argv))
return subprocess.call(
['ssh', self.remote, command_line],
**kwargs,
)
def check_call(self, argv, **kwargs):
print('{}:'.format(self.remote), repr(argv), file=sys.stderr)
if isinstance(argv, str):
command_line = argv
else:
command_line = ' '.join(map(shlex.quote, argv))
subprocess.check_call(
['ssh', self.remote, command_line],
**kwargs,
)
def check_output(self, argv, **kwargs):
print('{}:'.format(self.remote), repr(argv), file=sys.stderr)
command_line = ' '.join(map(shlex.quote, argv))
return subprocess.check_output(
['ssh', self.remote, command_line],
**kwargs,
)
def install_file(self, source, destination, permissions=0o644):
permissions = oct(permissions)
if permissions.startswith('0o'):
permissions = permissions[2:]
self.check_call(
'cat > {}/install'.format(shlex.quote(self.scratch)),
stdin=open(source, 'rb'),
)
self.check_call([
'install', '-m' + permissions,
'{}/install'.format(self.scratch),
destination,
])
@contextmanager
def remote_dir_context(self, path):
with TemporaryDirectory(prefix='flatdeb-mount.') as t:
subprocess.check_call([
'sshfs',
'{}:{}'.format(self.remote, path),
t,
])
try:
yield t
finally:
subprocess.check_call([
'fusermount',
'-u',
t,
])
---
sdk:
add_packages:
- build-essential
- ccache
- debhelper
- dpkg-dev
- fakeroot
...
---
add_packages:
# This package list is suspiciously similar to the dependencies of
# ioquake3 and openarena. There's a reason for that :-)
- libcurl3-gnutls
- libgl1-mesa-dri
- libgl1-mesa-glx
- libjpeg62-turbo
- libogg0
- libopenal1
- libopus0
- libopusfile0
- libsdl2-2.0-0
- libvorbis0a
- libvorbisfile3
- zlib1g
- x11-utils
platform:
null: null
sdk:
add_packages:
- build-essential
- ccache
- debhelper
- dh-exec
- dpkg-dev
- fakeroot
- libcurl4-gnutls-dev
- libgl1-mesa-dev
- libjpeg-dev
- libnss-extrausers
- libogg-dev
- libopenal-dev
- libopus-dev
- libopusfile-dev
- libsdl2-dev
- libvorbis-dev
- libz-dev
...
---
add_packages_multiarch:
- libgl1-mesa-dri
- libgl1-mesa-glx
- libgpg-error0
- libjpeg62-turbo
- libogg0
- libopenal1
- libopus0
- libopusfile0
- libsdl2-2.0-0
- libstdc++6
- libtxc-dxtn0
- libudev1
- libvorbis0a
- libvorbisfile3
- libx11-6
- libxinerama1
- libxss1
- zlib1g
debconf:
steam steam/license seen true
steam steam/question select I AGREE
add_packages:
- debconf
- fonts-liberation
- steam-launcher:i386
- x11-utils
- xterm
- xz-utils
- zenity
platform:
null: null
sdk:
add_packages:
- build-essential
- ccache
- debhelper
- dh-exec
- dpkg-dev
- libcurl4-gnutls-dev
- libgl1-mesa-dev
- libjpeg-dev
- libnss-extrausers
- libogg-dev
- libopenal-dev
- libopus-dev
- libopusfile-dev
- libsdl2-dev
- libvorbis-dev
- libz-dev
...
---
id: org.debian.packages.hello
branch: master
runtime: net.debian.flatpak.Base.Platform
runtime-version: stretch
sdk: net.debian.flatpak.Base.Sdk
command: hello
writable-sdk: true
modules:
- name: hello
x-flatdeb-apt-packages:
- hello
sources:
- type: file
path: deb-buildapi/configure
dest: '.'
- type: file
path: deb-buildapi/Makefile
...
---
id: org.debian.packages.openarena
branch: master
runtime: net.debian.flatpak.Games.Platform
sdk: net.debian.flatpak.Games.Sdk
#var: net.debian.flatpak.Games.Sdk.Var
command: openarena
writable-sdk: true
finish-args:
- --filesystem=~/.openarena:create
- --share=ipc
- --share=network
- --socket=pulseaudio
- --socket=wayland
- --socket=x11
- --device=dri
modules:
- name: ioquake3
sources:
- type: git
dest: src
path: /home/smcv/src/debian/ioquake3 # TODO: edit me
branch: wip/flatpak-app
- type: file
path: deb-buildapi/configure
- type: file
path: deb-buildapi/Makefile
cleanup:
- ioq3ded*
- qagame*.so
- name: openarena
sources:
- type: git
dest: src
path: /home/smcv/src/debian/openarena # TODO: edit me
branch: wip/flatpak-app
- type: file
path: deb-buildapi/configure
- type: file
path: deb-buildapi/Makefile
- name: openarena-data
x-flatdeb-apt-packages:
- openarena-088-data
- openarena-data
- openarena-oacmp1
sources:
- type: file
path: deb-buildapi/configure
- type: file
path: deb-buildapi/Makefile
rename-desktop-file: openarena.desktop
rename-icon: openarena128
desktop-file-name-prefix: "flatdeb "
...
This diff is collapsed.
---
apt_components:
- main
- contrib
debootstrap_script: 'stretch'
can_merge_usr: true
sources:
- apt_uri: 'http://deb.debian.org/debian'
- apt_uri: 'http://security.debian.org'
apt_suite: '*/updates'
...
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment