Skip to content

Commit

Permalink
Merge pull request #237 from arkane-systems/dev-2.2
Browse files Browse the repository at this point in the history
Dev 2.2 complete.
  • Loading branch information
cerebrate authored Mar 6, 2022
2 parents 1d73399 + e447807 commit 6d703ed
Show file tree
Hide file tree
Showing 23 changed files with 211 additions and 352 deletions.
17 changes: 8 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ out/

# Genie wrapper
binsrc/genie-wrapper/genie

# Genie python modules
binsrc/genie/*.dist-info
binsrc/genie/argparse.py
binsrc/genie/bin/
binsrc/genie/contextlib2/
binsrc/genie/nsenter/
binsrc/genie/pathlib.py
binsrc/genie/python_hosts/

# Built binaries
binsrc/out

# Debian build intermediates
Expand All @@ -23,12 +24,10 @@ debian/systemd-genie.debhelper.log
debian/systemd-genie.substvars
debian/genie-*

# Arch build intermediates

package/arch/src/
package/arch/pkg/

# Tar build intermediates
package/tar/tarball
tarball

# Arch build intermediates

genie/

1 change: 1 addition & 0 deletions CHANGELOG
113 changes: 96 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@
# This Makefile builds and packages genie by invoking relevant sub-makefiles.
#

# Genie version
GENIEVERSION = 2.2

# Determine this makefile's path.
# Be sure to place this BEFORE `include` directives, if any.
THIS_FILE := $(lastword $(MAKEFILE_LIST))

# The values of these variables depend upon DESTDIR, set in the recursive call to
# the internal-package target.
INSTALLDIR = $(DESTDIR)/usr/lib/genie
BINDIR = $(DESTDIR)/usr/bin
ETCDIR = $(DESTDIR)/etc
SVCDIR = $(DESTDIR)/usr/lib/systemd/system
USRLIBDIR = $(DESTDIR)/usr/lib

# used only by TAR installer
ENVGENDIR = $(DESTDIR)/usr/lib/systemd/system-environment-generators
USRENVGENDIR = $(DESTDIR)/usr/lib/systemd/user-environment-generators
MAN8DIR = $(DESTDIR)/usr/share/man/man8

#
# Default target: list options
#
Expand All @@ -13,23 +33,25 @@ default:
#
# make build-binaries
#
# Package (native)
# Package
#
# make package
# make package-debian
# ? make package-tar
# make package-tar
# make package-arch (requires Arch packaging environment)
#
# Clean up
#
# make clean (does not clean altpacking by default)
# make clean
# make clean-debian
# ? make clean-tar
# make clean-tar
# make clean-arch

#
# Targets: individual end-product build.
#

clean: clean-debian
clean: clean-debian clean-tar clean-arch
make -C binsrc clean
rm -rf out

Expand All @@ -39,16 +61,6 @@ package: package-debian
# Debian packaging
#

# Debian installation locations

DESTDIR=debian/systemd-genie

INSTALLDIR = $(DESTDIR)/usr/lib/genie
BINDIR = $(DESTDIR)/usr/bin
ETCDIR = $(DESTDIR)/etc
SVCDIR = $(DESTDIR)/usr/lib/systemd/system
USRLIBDIR = $(DESTDIR)/usr/lib

package-debian: make-output-directory
mkdir -p out/debian
debuild
Expand All @@ -57,10 +69,56 @@ package-debian: make-output-directory
clean-debian:
debuild -- clean

# Debian internal functions
package-tar: make-output-directory build-binaries
mkdir -p out/tar
mkdir -p tarball

fakeroot $(MAKE) -f $(THIS_FILE) DESTDIR=tarball internal-package

# Do the things that TAR needs that debuild would otherwise do
fakeroot $(MAKE) -f $(THIS_FILE) DESTDIR=tarball internal-supplement
fakeroot $(MAKE) -f $(THIS_FILE) DESTDIR=tarball internal-tar

mv genie-systemd-*.tar.gz out/tar

clean-tar:
rm -rf tarball

package-arch:
mkdir -p out/arch
updpkgsums
BUILDDIR=/tmp PKDEST=$(PWD)/out/arch makepkg
rm -rf $(PWD)/genie
mv *.zst out/arch

clean-arch:
rm -rf $(PWD)/genie
rm -rf out/arch

package-fedora: genie_version := $(shell rpmspec -q --qf %{Version} --srpm genie.spec)

package-fedora:
rpmdev-setuptree
tar zcvf $(shell rpm --eval '%{_sourcedir}')/genie-${genie_version}.tar.gz * --dereference --transform='s/^/genie-${genie_version}\//'
fakeroot rpmbuild -ba -v genie.spec
mkdir -p out/fedora
mv $(shell rpm --eval '%{_rpmdir}')/x86_64/genie* out/fedora

clean-fedora:
rpmdev-wipetree
rm -rf out/fedora

# Internal packaging functions

internal-debian-package:

mkdir -p debian/systemd-genie
@$(MAKE) -f $(THIS_FILE) DESTDIR=debian/systemd-genie internal-package

# We can assume DESTDIR is set, due to how the following are called.

internal-package:

# Binaries.
mkdir -p "$(BINDIR)"
install -Dm 6755 -o root "binsrc/genie-wrapper/genie" -t "$(BINDIR)"
Expand All @@ -86,9 +144,30 @@ internal-debian-package:
# binfmt.d
install -Dm 0644 -o root "othersrc/usr-lib/binfmt.d/WSLInterop.conf" -t "$(USRLIBDIR)/binfmt.d"

internal-debian-clean:
internal-clean:
make -C binsrc clean

internal-supplement:
# Fixup symbolic links
mkdir -p $(ENVGENDIR)
mkdir -p $(USRENVGENDIR)
ln -sr $(INSTALLDIR)/80-genie-envar.sh $(ENVGENDIR)/80-genie-envar.sh
ln -sr $(INSTALLDIR)/80-genie-envar.sh $(USRENVGENDIR)/80-genie-envar.sh
ln -sr $(SVCDIR)/wslg-xwayland.socket $(SVCDIR)/sockets.target.wants/wslg-xwayland.socket

# Man page.
# Make sure directory exists.
mkdir -p "$(MAN8DIR)"

# this bit would ordinarily be handed by debuild, etc.
cp "othersrc/docs/genie.8" /tmp/genie.8
gzip -9 "/tmp/genie.8"
install -Dm 0644 -o root "/tmp/genie.8.gz" -t "$(MAN8DIR)"

internal-tar:
# tar it up
tar zcvf genie-systemd-$(GENIEVERSION).tar.gz tarball/* --transform='s/^tarball//'

#
# Helpers: intermediate build stages.
#
Expand Down
33 changes: 33 additions & 0 deletions PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Maintainer: Ong Yong Xin <ongyongxin2020+github AT gmail DOT com>
# Contributor: Xuanrui Qi <me@xuanruiqi.com>
# Contributor: Rayfalling <Rayfalling@outlook.com>
# Contributor: facekapow, rayfalling, Ducksoft
_pkgname=genie
pkgname=${_pkgname}-systemd
pkgver=2.1.r15.g379869a
pkgrel=1
pkgdesc="A quick way into a systemd \"bottle\" for WSL"
arch=('x86_64')
url="https://github.com/arkane-systems/genie"
license=('Unlicense')
depends=('daemonize' 'python' 'python-psutil' 'systemd')
makedepends=('git' 'python-pip')
options=(!strip)
source=("git+https://github.com/arkane-systems/genie.git")
sha256sums=('SKIP')
backup=('etc/genie.ini')

# pkgver() {
# git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g;s/^v//g'
# }

build() {
cd genie
make build-binaries
}

package() {
cd genie
make DESTDIR=${pkgdir} internal-package
make DESTDIR=${pkgdir} internal-supplement
}
9 changes: 6 additions & 3 deletions binsrc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@
build: build-wrapper build-runinwsl build-genie

build-wrapper:
mkdir -p out
make -C genie-wrapper

build-runinwsl:
python -m zipapp -o out/runinwsl -p "/usr/bin/env python3" -c runinwsl
mkdir -p out
python3 -m zipapp -o out/runinwsl -p "/usr/bin/env python3" -c runinwsl

build-genie:
python -m pip install -r genie/requirements.txt --target genie
python -m zipapp -o out/genie -p "/usr/bin/env python3" -c genie
mkdir -p out
python3 -m pip install -r genie/requirements.txt --target genie --upgrade
python3 -m zipapp -o out/genie -p "/usr/bin/env python3" -c genie

#
# clean: clean up after a build/package
Expand Down
2 changes: 1 addition & 1 deletion binsrc/genie/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
nsenter>=0.2
git+https://github.com/zalando/python-nsenter@b7fd78fef24c456d88130c75fe734417728e97e8
python_hosts>=1.0.1
# psutil>=5.9.0 (should be handled by apt package)
2 changes: 2 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ systemd-genie (2.2) buster bullseye bookworm sid focal bionic; urgency=medium

* Single-file package python scripts.
* Man page fixes.
* Fixed building on Python 3.10.
* Dropped the "local" install option (little used; use tarball instead).

-- Alistair Young <avatar@arkane-systems.net> Mon, 28 Feb 2022 18:30:00 -0500

Expand Down
2 changes: 1 addition & 1 deletion debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ override_dh_auto_install:
make internal-debian-package

override_dh_auto_clean:
make internal-debian-clean
make internal-clean

# Allow our setuid executable to pass unfixed.
override_dh_fixperms:
Expand Down
1 change: 1 addition & 0 deletions debian/systemd-genie.links
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/usr/lib/genie/80-genie-envar.sh /usr/lib/systemd/system-environment-generators/80-genie-envar.sh
/usr/lib/genie/80-genie-envar.sh /usr/lib/systemd/user-environment-generators/80-genie-envar.sh
/usr/lib/systemd/system/wslg-xwayland.socket /usr/lib/systemd/system/sockets.target.wants/wslg-xwayland.socket
Loading

0 comments on commit 6d703ed

Please sign in to comment.