Skip to content

Commit

Permalink
Merge pull request #285 from arkane-systems/dev-2.4
Browse files Browse the repository at this point in the history
Dev 2.4
  • Loading branch information
cerebrate committed Jun 25, 2022
2 parents 9f0965b + 30e5378 commit 9225f28
Show file tree
Hide file tree
Showing 23 changed files with 738 additions and 533 deletions.
99 changes: 85 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,97 @@ on:
pull_request:

jobs:
build:
build-debian:
runs-on: ubuntu-20.04

steps:
- name: Update apt db
run: sudo apt update

- name: Install Packagers & Cross-Compiler
run: sudo apt install -y devscripts debhelper gcc-aarch64-linux-gnu

- name: Update apt db
run: sudo apt update
- name: Checkout
uses: actions/checkout@v2

- name: Install Packagers & Cross-Compiler
run: sudo apt install -y devscripts debhelper gcc-aarch64-linux-gnu
- name: Build & Make Debian Package
run: make package-debian

- name: Checkout
uses: actions/checkout@v2
- name: Upload Results
uses: actions/upload-artifact@v3
with:
name: debpkg
path: out/debian/*

- name: Build & Make Debian Package
run: make package-debian
build-tarball:
runs-on: ubuntu-20.04

steps:
- name: Update apt db
run: sudo apt update

- name: Checkout
uses: actions/checkout@v3

- name: Build & Make Tarball
run: make package-tar

- name: Upload Results
uses: actions/upload-artifact@v3
with:
name: tar
path: out/tar/*

build-arch:
runs-on: ubuntu-latest
container:
image: cerebrate/fuckarch:right-in-the-ear

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Permissions fixup
run: sudo chown -R build .

- name: Build Package
run: sudo -u build make package-arch

- name: Upload Results
uses: actions/upload-artifact@v3
with:
name: zst
path: out/arch/*

build-fedora:
strategy:
matrix:
fedora_version: [36] # [35, 36, 37]
runs-on: ubuntu-latest
container:
image: fedora:${{ matrix.fedora_version }}
steps:
- name: dnf update
run: sudo dnf update -y

- name: Install Packagers & Cross-Compiler
run: |
sudo dnf install -y \
@development-tools \
@rpm-development-tools \
python-pip \
gcc-aarch64-linux-gnu
- name: Checkout
uses: actions/checkout@v2

- name: Build RPMs
run: |
make package-fedora RPMBUILD_TARGET=x86_64
make package-fedora RPMBUILD_TARGET=aarch64
- name: Upload Results
uses: actions/upload-artifact@v3
with:
name: debpkg
path: out/debian/*
- name: Upload Results
uses: actions/upload-artifact@v3
with:
name: rpm
path: out/fedora/*
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ debian/.debhelper/
debian/debhelper-build-stamp
debian/files
debian/systemd-genie.debhelper.log
debian/systemd-genie.postinst.debhelper
debian/systemd-genie.substvars
debian/genie-*

# Tar build intermediates
tarball

# Arch build intermediates
/genie/

genie/

# Visual Studio code
.vscode
15 changes: 15 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,18 @@ If your update significantly changes the behavior of _genie_ , adds new configur
If you have or would like to create the pull request (for comment, for example) but it still requires more work before merging, please tag it _work-in-progess_ .

Thank you!


## Building

Builds are carried out automatically by GitHub Actions on pull-request or push to master. The only build I use
locally is the Debian one, as that's my build platform. If you change any of the others and they stop working on
GitHub Actions, the pull request will not be accepted even if they do work for you locally.

The Arch build makes use of the special container image `cerebrate/fuckarch:right-in-the-ear`, which exists to deal
with the pain-in-the-ass that is having to compile a second package manager to deal with getting packages from a
different repository, all for the sake of one lousy package.

If you need to know the gory details, the Dockerfile for the image is here:

https://gist.github.com/cerebrate/45daae1bf6ad82ecd041d347bd2b1173
27 changes: 14 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#

# Genie version
GENIEVERSION = 2.3
GENIEVERSION = 2.4

# Determine this makefile's path.
# Be sure to place this BEFORE `include` directives, if any.
Expand Down Expand Up @@ -64,14 +64,16 @@ package: package-debian
# Debian packaging
#

package-debian: make-output-directory
package-debian: package-debian-amd64 package-debian-arm64

package-debian-amd64: make-output-directory
mkdir -p out/debian
if [ "${CI}" = "true" ]; then debuild -us -uc; else debuild; fi
debuild -us -uc
mv ../systemd-genie_* out/debian

package-debian-arm64: make-output-directory
mkdir -p out/debian
debuild -aarm64
debuild -aarm64 -us -uc
mv ../systemd-genie_* out/debian

clean-debian:
Expand All @@ -87,7 +89,7 @@ package-tar: make-output-directory build-binaries
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
mv genie-systemd-*-amd64.tar.gz out/tar

clean-tar:
rm -rf tarball
Expand All @@ -105,12 +107,13 @@ clean-arch:

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

RPMBUILD_TARGET = $(shell uname --processor)
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
fakeroot rpmbuild --target $(RPMBUILD_TARGET) -ba -v genie.spec
mkdir -p out/fedora
mv $(shell rpm --eval '%{_rpmdir}')/x86_64/genie* out/fedora
mv $(shell rpm --eval '%{_rpmdir}')/*/genie* out/fedora

clean-fedora:
rpmdev-wipetree
Expand Down Expand Up @@ -143,14 +146,14 @@ internal-package:
install -Dm 0644 -o root "othersrc/etc/genie.ini" -t "$(ETCDIR)"

# Unit files.
install -Dm 0644 -o root "othersrc/lib-systemd-system/wslg-xwayland.service" -t "$(SVCDIR)"
install -Dm 0644 -o root "othersrc/lib-systemd-system/wslg-xwayland.socket" -t "$(SVCDIR)"

install -Dm 0644 -o root "othersrc/lib-systemd-system/user-runtime-dir@.service.d/override.conf" -t "$(SVCDIR)/user-runtime-dir@.service.d"

# binfmt.d
install -Dm 0644 -o root "othersrc/usr-lib/binfmt.d/WSLInterop.conf" -t "$(USRLIBDIR)/binfmt.d"

# tmpfiles.d
install -Dm 0644 -o root "othersrc/usr-lib/tmpfiles.d/wslg.conf" -t "$(USRLIBDIR)/tmpfiles.d"

internal-clean:
make -C binsrc clean

Expand All @@ -160,8 +163,6 @@ internal-supplement:
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
mkdir -p $(SVCDIR)/sockets.target.wants
ln -sr $(SVCDIR)/wslg-xwayland.socket $(SVCDIR)/sockets.target.wants/wslg-xwayland.socket

# Man page.
# Make sure directory exists.
Expand All @@ -174,7 +175,7 @@ internal-supplement:

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

#
# Helpers: intermediate build stages.
Expand Down
4 changes: 2 additions & 2 deletions PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
# Contributor: facekapow, rayfalling, Ducksoft
_pkgname=genie
pkgname=${_pkgname}-systemd
pkgver=2.3
pkgver=2.4
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')
depends=('daemonize' 'python>=3.7' 'python-psutil' 'systemd>=232.25' 'inetutils')
makedepends=('git' 'python-pip')
options=(!strip)
source=("git+https://github.com/arkane-systems/genie.git")
Expand Down
15 changes: 15 additions & 0 deletions binsrc/genie-wrapper/genie.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,29 @@
#include <stdio.h>
#include <unistd.h>

#include <sys/types.h>
#include <pwd.h>
#include <stdlib.h>

int main(int argc, char ** argv)
{
/* Set GENIE_LOGNAME environment variable. */
struct passwd * logname = getpwuid(getuid());
int result = setenv ("GENIE_LOGNAME", logname->pw_name, 1);

if (result != 0)
{
perror ("genie-wrapper-logname");
return 1;
}

/* Reset uid/gid */
setregid(getegid(), getegid());
setreuid(geteuid(), geteuid());

/* Attempt to execute script */
execv("/usr/lib/genie/genie", argv);
// execv("/bin/sh", argv);

/* Reach here if execv failed */
perror("genie-wrapper");
Expand Down
4 changes: 4 additions & 0 deletions binsrc/genie-wrapper/test-as-root
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#! /bin/sh
sudo chown root:root genie
sudo chmod 6755 genie

Loading

0 comments on commit 9225f28

Please sign in to comment.