Skip to content

Commit

Permalink
fix: update gemini and gopher version + chezmoi post
Browse files Browse the repository at this point in the history
  • Loading branch information
theobori committed Mar 19, 2024
1 parent e15f527 commit af2df17
Show file tree
Hide file tree
Showing 7 changed files with 355 additions and 4 deletions.
14 changes: 13 additions & 1 deletion posts/chezmoi.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,29 @@ My configuration template looks like this (below) in the `.chezmoi.yaml.tmpl` fi
{% raw %}
```jinja2
{{ $has_age := false }}
{{ $sudo := "sudo" }}
{{ $font := "Comic Code" }}
{{ if stdinIsATTY }}
{{ $has_age = promptBool "do you have age " }}
{{ $sudo = promptString "sudo or doas " }}
{{ $font = promptString "font name " }}
{{ end }}
{{ if and (ne $sudo "sudo") (ne $sudo "doas") }}
{{ $sudo = "sudo" }}
{{ end }}
encryption: "age"
{{ if $has_age }}
encryption: "age"
age:
identity: "/home/nagi/.config/age/key.txt"
recipient: "age14m06fd3svs9neg2w97ccw3c8470hckl95qxr6jw8fgm4ex65352q6tun06"
{{ end }}
data:
sudo: {{ $sudo }}
font: {{ $font }}
```
{% endraw %}
 
Expand Down
14 changes: 13 additions & 1 deletion public_gemini/chezmoi.gmi
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,29 @@ My configuration template looks like this (below) in the .chezmoi.yaml.tmpl file

```jinja2
{{ $has_age := false }}
{{ $sudo := "sudo" }}
{{ $font := "Comic Code" }}

{{ if stdinIsATTY }}
{{ $has_age = promptBool "do you have age " }}
{{ $sudo = promptString "sudo or doas " }}
{{ $font = promptString "font name " }}
{{ end }}

{{ if and (ne $sudo "sudo") (ne $sudo "doas") }}
{{ $sudo = "sudo" }}
{{ end }}

encryption: "age"
{{ if $has_age }}
encryption: "age"
age:
identity: "/home/nagi/.config/age/key.txt"
recipient: "age14m06fd3svs9neg2w97ccw3c8470hckl95qxr6jw8fgm4ex65352q6tun06"
{{ end }}

data:
sudo: {{ $sudo }}
font: {{ $font }}
```

{% endraw %}
Expand Down
3 changes: 2 additions & 1 deletion public_gemini/index.gmi
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
`-__-'
```

Hello, I'm Théo,
Hi, I'm Théo,

I support FOSS, FLOSS and pubnix(es) values, I love Linux and UNIX systems.

Expand All @@ -31,6 +31,7 @@ I can be reached via Discord (b0th) or via nagi@cock.li.
=> gopher://tilde.pink:70/1/~nagi Gopher

## Posts
=> /~nagi/openbsd_ports.gmi Porting X11 apps to OpenBSD - mar 2024
=> /~nagi/chezmoi.gmi Manage dotfiles with chezmoi - mar 2024
=> /~nagi/ebpf.gmi eBPF essentials - jan 2024
=> /~nagi/pubnix.gmi Public access UNIX systems - oct 2023
Expand Down
149 changes: 149 additions & 0 deletions public_gemini/openbsd_ports.gmi
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# Porting X11 apps to OpenBSD
## 2024-03-15
I was getting interested in BSD systems, more specifically OpenBSD, its firewall (pf) and more generally its security. Then I wanted to use some programs with a graphical interface such as xclicker. But it doesn't exist on the distribution, so I wanted to integrate it.

*By the way, there's a site that explains why OpenBSD is great (
=> https://why-openbsd.rocks/fact why-openbsd.rocks
).*

I thought it could be interesting to port/package some games I've played during my childhood such as
=> http://smwstuff.net Super Mario War
or
=> https://thelettervsixtim.es/index.html VVVVVV
.

Before making the game compatible with the distribution, it's best to fetch the port tree (
=> https://www.openbsd.org/faq/ports/ports.html doc
) and read the official documentation (
=> https://www.openbsd.org/faq/ports/guide.html doc
) to get the essentials.

## OpenBSD environment

My test environment is just a virtual machine managed by VirtualBox on which
=> https://www.openbsd.org/74.html OpenBSD 7.4
has been installed, following the steps
=> https://www.openbsdhandbook.com/installation/ here
.

To manage X displays, I used xenodm which is installed by default on OpenBSD. You can activate its system service with the following command.

```bash
rcctl enable xenodm
```

And for the windows manager, there's a basic one (cwm) but I opted for i3wm anyway.

## Porting VVVVVV

Few years ago, VVVVVV has released an open source version (engine + levels). The game binary requires a **data.zip** file which must be in the same folder, luckily there are options to specify in which folders to look for the fonts and languages.

So that the user doesn't have to fill in all this information himself, I've created a shell script with the appropriate values.

```bash
#!/bin/sh

NAME=VVVVVV
GAMES_DIR=${TRUEPREFIX}/games/${NAME}
SHARE_DIR=${TRUEPREFIX}/share/${NAME}

cd ${GAMES_DIR}

exec ./${NAME} \
-fontsdir ${SHARE_DIR}/fonts \
-langdir ${SHARE_DIR}/lang \
${@}
```

Note that ${TRUEPREFIX} is not defined in the script, this is normal, it will be replaced by ${SUBST_CMD} defined in **/usr/ports/infrastructure/mk/bsd.port.mk**.

This is what the game's makefile looks like.

```makefile
COMMENT= puzzle-platform game

V= 2.4.1
NAME= VVVVVV
PKGNAME= ${NAME}-${V}

CATEGORIES= games

HOMEPAGE= http://thelettervsixtim.es

MAINTAINER= Theo Bori <nagi@tilde.team>

EXTRACT_SUFX= .zip

WRKSRC= ${WRKDIST}/${NAME}/desktop_version

SITES= https://github.com/terrycavanagh/${NAME}/releases/download/${V}/
SITES.a= ${HOMEPAGE}/makeandplay/

DISTFILES= ${PKGNAME}${EXTRACT_SUFX}
DISTFILES.a= vvvvvv-mp-linux-02132024${EXTRACT_SUFX}

# Bsd-like
PERMIT_PACKAGE= Yes

WANTLIB+= c SDL2 physfs tinyxml2 FAudio

LIB_DEPENDS= devel/sdl2 \
devel/physfs \
audio/faudio \
textproc/tinyxml2

CXXFLAGS+= -I${PREFIX}/include

MODULES= devel/cmake

CONFIGURE_ARGS= -DBUNDLE_DEPENDENCIES="OFF"

do-extract:
unzip ${FULLDISTDIR}/${PKGNAME}${EXTRACT_SUFX} -d ${WRKDIR}/
unzip ${FULLDISTDIR}/vvvvvv-mp-linux-02132024${EXTRACT_SUFX} -d ${WRKDIR}/${PKGNAME}-data

do-install:
${INSTALL_DATA_DIR} ${PREFIX}/games/${NAME}
${INSTALL_PROGRAM} ${WRKBUILD}/${NAME} ${PREFIX}/games/${NAME}/${NAME}

${SUBST_CMD} -c -m 755 ${FILESDIR}/${NAME} ${PREFIX}/bin/${NAME}

post-install:
${INSTALL_DATA} ${WRKDIR}/${PKGNAME}-data/data.zip ${PREFIX}/games/${NAME}

${INSTALL_DATA_DIR} ${PREFIX}/share/${NAME}

.for d in lang licenses fonts
cp -r ${WRKDIR}/${PKGNAME}-data/${d} ${PREFIX}/share/${NAME}
.endfor

.include <bsd.port.mk>
```

As you can see, I had to override some of the BSD port makefile targets, because, actually this ports is a little bit special. It must download multiple distfiles from different sites (see below).

```makefile
SITES= https://github.com/terrycavanagh/${NAME}/releases/download/${V}/
SITES.a= ${HOMEPAGE}/makeandplay/

DISTFILES= ${PKGNAME}${EXTRACT_SUFX}
DISTFILES.a= vvvvvv-mp-linux-02132024${EXTRACT_SUFX}
```

Moreover, there were conflicts with the extracted files names, so I had to rename the directory containing **data.zip**.

```makefile
do-extract:
unzip ${FULLDISTDIR}/${PKGNAME}${EXTRACT_SUFX} -d ${WRKDIR}/
unzip ${FULLDISTDIR}/vvvvvv-mp-linux-02132024${EXTRACT_SUFX} -d ${WRKDIR}/${PKGNAME}-data
```

Also, we didn't want to build the dependencies using the github modules, because obviously, the released zip file doesn't have a **.git** folder inside.

I've also patched a few source files, the full port is available
=> https://github.com/theobori/openbsd-ports/tree/main/games/VVVVVV here
.

## Links

=> https://github.com/theobori/openbsd-ports My OpenBSD ports
29 changes: 29 additions & 0 deletions public_gopher/chezmoi.gph
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,35 @@ Something interesting about

My configuration template looks like this (below) in the `.chezmoi.yaml.tmpl` file.

{% raw %}
```jinja2
{{ $has_age := false }}
{{ $sudo := "sudo" }}
{{ $font := "Comic Code" }}

{{ if stdinIsATTY }}
{{ $has_age = promptBool "do you have age " }}
{{ $sudo = promptString "sudo or doas " }}
{{ $font = promptString "font name " }}
{{ end }}

{{ if and (ne $sudo "sudo") (ne $sudo "doas") }}
{{ $sudo = "sudo" }}
{{ end }}

{{ if $has_age }}
encryption: "age"
age:
identity: "/home/nagi/.config/age/key.txt"
recipient: "age14m06fd3svs9neg2w97ccw3c8470hckl95qxr6jw8fgm4ex65352q6tun06"
{{ end }}

data:
sudo: {{ $sudo }}
font: {{ $font }}
```
{% endraw %}

For the moment the repository is only compatible with Fedora only, however it is easy to implement other distributions.

## Apply from a different machine
Expand Down
3 changes: 2 additions & 1 deletion public_gopher/index.gph
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
`| | | | |(/_(_) |_)(_) | |
`-__-'

Hello, I'm Théo,
Hi, I'm Théo,

I support FOSS, FLOSS and pubnix(es) values, I love Linux and UNIX systems.

Expand All @@ -29,6 +29,7 @@ I can be reached via Discord (b0th) or via nagi@cock.li.
gemini://tilde.pink/~nagi

## Posts
[1|Porting X11 apps to OpenBSD - mar 2024|/~nagi/openbsd_ports.gph|70]
[1|Manage dotfiles with chezmoi - mar 2024|/~nagi/chezmoi.gph|70]
[1|eBPF essentials - jan 2024|/~nagi/ebpf.gph|tilde.pink|70]
[1|Public access UNIX systems - oct 2023|/~nagi/pubnix.gph|tilde.pink|70]
Expand Down
Loading

0 comments on commit af2df17

Please sign in to comment.