You are not logged in.

#1 2018-10-10 05:59:49

zerf
Member
Registered: 2018-10-10
Posts: 1

PKGBUILD Review Request for SSVOpenHexagon

Hello! I just created my first PKGBUILD for Vittorio Romeo's OpenHexagon / SSVOpenHexagon and was looking for some feedback.

Upstream is a bit weird because all of the game's files need to be next to the binary at runtime. It seems like in this situation most people just dump everything in /opt/$pkgname and either symlink the binary or create a launcher script. I did the latter.
It's even worse because some of said files are expected to be mutable at runtime. Rather than patch upstream (which I'd like to do later), I made those particular files world writable.
Lastly, upstream is hardcoded to throw the compiled binary in a subdirectory of the source, which is alright since I'm copying assets out of there anyway.

Aside from those funky issues, I'd like to know if I'm handling git/submodules/cmake correctly, and if my hacks are documented to the point where they're understandable.

Thanks!

GitHub gist: https://gist.github.com/bmwalters/45069 … 69dffab67e

PKGBUILD contents reposted for convenience:

# Maintainer: Bradley Walters <oss@walters.app>

pkgname=openhexagon-git
pkgver=r1733.4791b23
pkgrel=1
pkgdesc='C++14 FOSS clone of "Super Hexagon"'
arch=('i686' 'x86_64' 'armv6h') # TODO: check these
url="https://vittorioromeo.info/projects.html"
license=('custom:AFL-3.0')
depends=('sfml' 'lua')
makedepends=('git' 'cmake>=3.0' 'zlib') # TODO: is zlib a depends or makedepends?
provides=("openhexagon-git")
conflicts=("openhexagon-git")
source=("$pkgname::git+https://github.com/SuperV1234/SSVOpenHexagon.git"
		'git+https://github.com/SuperV1234/SSVOpenHexagonAssets.git'
		'git+https://github.com/SuperV1234/SSVMenuSystem.git'
		'git+https://github.com/SuperV1234/SSVStart.git'
		'git+https://github.com/SuperV1234/SSVUtils.git'
		'git+https://github.com/SuperV1234/SSVLuaWrapper.git'
		'git+https://github.com/SuperV1234/vrm_pp.git'
		'git+https://github.com/SuperV1234/vrm_cmake.git'
		'git+https://github.com/LaurentGomila/SFML.git'
		'git+https://github.com/meganz/mingw-std-threads.git')
md5sums=('SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP')

pkgver() {
	cd "$srcdir/$pkgname"
	printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

prepare() {
	cd "$srcdir/$pkgname"

	# update submodules
	git submodule init
	git config submodule.extlibs/SSVMenuSystem.url "$srcdir/SSVMenuSystem"
	git config submodule.extlibs/SSVStart.url "$srcdir/SSVStart"
	git config submodule.extlibs/SSVUtils.url "$srcdir/SSVUtils"
	git config submodule.extlibs/SSVLuaWrapper.url "$srcdir/SSVLuaWrapper"
	git config submodule.extlibs/vrm_pp.url "$srcdir/vrm_pp"
	git config submodule.extlibs/vrm_cmake.url "$srcdir/vrm_cmake"
	git config submodule.extlibs/SFML.url "$srcdir/SFML" # TODO: FROM REPO?
	git config submodule.extlibs/mingw-std-threads.url "$srcdir/mingw-std-threads" # TODO: necessary?
	git submodule update
}

build() {
	cd "$srcdir/$pkgname"
	mkdir -p build
	cd build
	cmake .. -DCMAKE_BUILD_TYPE=Release
	make
}

package() {
	cd "$srcdir/$pkgname/build"
	echo $pkgdir
	make install

	# files are now installed to $srcdir/$pkgname/_RELEASE (upstream build dir is not configurable)
	# TODO: patch upstream to allow configuring build dir in CMakeLists
	# HACK: throw everything in /opt (upstream expects them to be next to binary)
	# TODO: patch upstream to use sane directory configuration (with XDG)
	install -Dm644 "$srcdir/$pkgname"/_RELEASE/ConfigOverrides/* -t "$pkgdir/opt/$pkgname/ConfigOverrides"
	install -Dm644 "$srcdir/$pkgname"/_RELEASE/_DOCUMENTATION/* -t "$pkgdir/opt/$pkgname/_DOCUMENTATION"
	install -Dm644 "$srcdir/$pkgname"/_RELEASE/*.json -t "$pkgdir/opt/$pkgname"
	install -Dm755 "$srcdir/$pkgname"/_RELEASE/SSVOpenHexagon -t "$pkgdir/opt/$pkgname"
	cp -r "$srcdir/$pkgname"/_RELEASE/Assets "$pkgdir/opt/$pkgname"
	cp -r "$srcdir/$pkgname"/_RELEASE/Packs "$pkgdir/opt/$pkgname"

	# copy over additional assets from separate repo
	cp -r "$srcdir"/SSVOpenHexagonAssets/_RELEASE/Packs/* "$pkgdir/opt/$pkgname/Packs"

	# create launcher script in /usr/bin
	mkdir -p $pkgdir/usr/bin
	cat << EOF > "$pkgdir/usr/bin/open-hexagon"
#!/usr/bin/sh
cd "/opt/$pkgname"
./SSVOpenHexagon
EOF
	chmod 755 "$pkgdir/usr/bin/open-hexagon"

	# HACK: create runtime files and set permissions
	# see above TODO
	touch $pkgdir/opt/$pkgname/log.txt
	chmod 666 $pkgdir/opt/$pkgname/log.txt
	mkdir -p $pkgdir/opt/$pkgname/Profiles
	chmod 777 $pkgdir/opt/$pkgname/Profiles
	chmod 666 $pkgdir/opt/$pkgname/config.json
	chmod 666 $pkgdir/opt/$pkgname/scores.json
	chmod 666 $pkgdir/opt/$pkgname/users.json

	# copy license
	install -Dm644 "$srcdir/$pkgname"/LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

namcap output:

$ namcap openhexagon-git-r1733.4791b23-1-x86_64.pkg.tar.xz 
openhexagon-git E: ELF files outside of a valid path ('opt/').
openhexagon-git W: Directory (opt/openhexagon-git/Profiles) is empty
openhexagon-git W: File (opt/openhexagon-git/Profiles) has the world writable bit set.
openhexagon-git W: File (opt/openhexagon-git/config.json) has the world writable bit set.
openhexagon-git W: File (opt/openhexagon-git/log.txt) has the world writable bit set.
openhexagon-git W: File (opt/openhexagon-git/scores.json) has the world writable bit set.
openhexagon-git W: File (opt/openhexagon-git/users.json) has the world writable bit set.

file list:

$ pacman -Qlp openhexagon-git-r1733.4791b23-1-x86_64.pkg.tar.xz
openhexagon-git /opt/
openhexagon-git /opt/openhexagon-git/
openhexagon-git /opt/openhexagon-git/Assets/
openhexagon-git /opt/openhexagon-git/Assets/<snipped for brevity>
openhexagon-git /opt/openhexagon-git/ConfigOverrides/
openhexagon-git /opt/openhexagon-git/ConfigOverrides/<snipped for brevity>
openhexagon-git /opt/openhexagon-git/Packs/
openhexagon-git /opt/openhexagon-git/Packs/<snipped for brevity>
openhexagon-git /opt/openhexagon-git/Profiles/
openhexagon-git /opt/openhexagon-git/SSVOpenHexagon
openhexagon-git /opt/openhexagon-git/_DOCUMENTATION/
openhexagon-git /opt/openhexagon-git/_DOCUMENTATION/<snipped for brevity>
openhexagon-git /opt/openhexagon-git/config.json
openhexagon-git /opt/openhexagon-git/log.txt
openhexagon-git /opt/openhexagon-git/scores.json
openhexagon-git /opt/openhexagon-git/users.json
openhexagon-git /usr/
openhexagon-git /usr/bin/
openhexagon-git /usr/bin/open-hexagon
openhexagon-git /usr/share/
openhexagon-git /usr/share/licenses/
openhexagon-git /usr/share/licenses/openhexagon-git/
openhexagon-git /usr/share/licenses/openhexagon-git/LICENSE

Last edited by zerf (2018-10-10 06:01:03)

Offline

#2 2018-10-10 08:46:19

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 11,868

Re: PKGBUILD Review Request for SSVOpenHexagon

pkgname=openhexagon-git

provides=("openhexagon-git")
conflicts=("openhexagon-git")

Doesn't make sense, but maybe you wanted to provide & conflict openhexagon ?

-------------------------------------------------------------------------

	cat << EOF > "$pkgdir/usr/bin/open-hexagon"
#!/usr/bin/sh
cd "/opt/$pkgname"
./SSVOpenHexagon
EOF

creating a separate file that's listed in source array with a checksum is preferred way to add  a launcher script.
You may want to call that file open-hexagon-git.sh to avoid confusion with other versions

Last edited by Lone_Wolf (2018-10-10 08:46:39)


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

#3 2018-10-10 16:46:42

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: PKGBUILD Review Request for SSVOpenHexagon

zerf wrote:

Hello! I just created my first PKGBUILD for Vittorio Romeo's OpenHexagon / SSVOpenHexagon and was looking for some feedback.

Upstream is a bit weird because all of the game's files need to be next to the binary at runtime. It seems like in this situation most people just dump everything in /opt/$pkgname and either symlink the binary or create a launcher script. I did the latter.
It's even worse because some of said files are expected to be mutable at runtime. Rather than patch upstream (which I'd like to do later), I made those particular files world writable.
Lastly, upstream is hardcoded to throw the compiled binary in a subdirectory of the source, which is alright since I'm copying assets out of there anyway.

Well, that's certainly unfortunate. Have you tried opening an issue to discuss making this XDG directories in $HOME/ instead of the installation directory?

If I were trying to make this work I'd actually be seriously inclined to patch the source code in order to fix these issues, then submit a pull request.

Aside from those funky issues, I'd like to know if I'm handling git/submodules/cmake correctly, and if my hacks are documented to the point where they're understandable.

Thanks!

GitHub gist: https://gist.github.com/bmwalters/45069 … 69dffab67e

PKGBUILD contents reposted for convenience:

# Maintainer: Bradley Walters <oss@walters.app>

pkgname=openhexagon-git
pkgver=r1733.4791b23
pkgrel=1
pkgdesc='C++14 FOSS clone of "Super Hexagon"'
arch=('i686' 'x86_64' 'armv6h') # TODO: check these
url="https://vittorioromeo.info/projects.html"
license=('custom:AFL-3.0')
depends=('sfml' 'lua')
makedepends=('git' 'cmake>=3.0' 'zlib') # TODO: is zlib a depends or makedepends?
provides=("openhexagon-git")
conflicts=("openhexagon-git")

It makes no sense to provide or conflict itself, since it already is itself.

However, providing and conflicting the non-git variant would probably make sense.

pkgver() {
	cd "$srcdir/$pkgname"
	printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

The repository does have tags, git describe is 1.92b-1207-g4791b23 (annotated tags) or 2.0-preview-1045-g4791b23 (unannotated tag).

I'd suggest you use that instead, keeping in mind they added 1.92b *after* 1.92 which is wrong and should be sed'ed out to 1.92.b

build() {
	cd "$srcdir/$pkgname"
	mkdir -p build
	cd build
	cmake .. -DCMAKE_BUILD_TYPE=Release

Why are you manually specifying the build type? What if someone specifies in their makepkg.conf that they wish to use OPTIONS=(debug)

Unless the CMakeLists.txt tries to randomly enforce a build type, this should probably be left unspecified, so that cmake doesn't try adding any flags at all.

	make
}

package() {
	cd "$srcdir/$pkgname/build"
	echo $pkgdir
	make install

What does this echo do? Why isn't it quoted?

	# create launcher script in /usr/bin
	mkdir -p $pkgdir/usr/bin
	cat << EOF > "$pkgdir/usr/bin/open-hexagon"
#!/usr/bin/sh
cd "/opt/$pkgname"
./SSVOpenHexagon
EOF

Can it take arguments? If so, it should run ./SSVOpenHexagon "$@"

	chmod 755 "$pkgdir/usr/bin/open-hexagon"

	# HACK: create runtime files and set permissions
	# see above TODO
	touch $pkgdir/opt/$pkgname/log.txt
	chmod 666 $pkgdir/opt/$pkgname/log.txt
	mkdir -p $pkgdir/opt/$pkgname/Profiles
	chmod 777 $pkgdir/opt/$pkgname/Profiles
	chmod 666 $pkgdir/opt/$pkgname/config.json
	chmod 666 $pkgdir/opt/$pkgname/scores.json
	chmod 666 $pkgdir/opt/$pkgname/users.json

You forgot to quote all these $pkgdir.

Also you can combine modes by using install.

	# HACK: create runtime files and set permissions
	# see above TODO
	install -Dm666 /dev/null "$pkgdir"/opt/$pkgname/log.txt
	install -dm777 "$pkgdir"/opt/$pkgname/Profiles
	install -Dm666 "$srcdir/$pkgname"/_RELEASE/*.json -t "$pkgdir/opt/$pkgname"

namcap output:

$ namcap openhexagon-git-r1733.4791b23-1-x86_64.pkg.tar.xz 
openhexagon-git E: ELF files outside of a valid path ('opt/').

This is namcap being wrong.

openhexagon-git W: Directory (opt/openhexagon-git/Profiles) is empty

If you explicitly need this directory, you should also specify options=('emptydirs')
See https://wiki.archlinux.org/index.php/PKGBUILD#options

openhexagon-git W: File (opt/openhexagon-git/Profiles) has the world writable bit set.
openhexagon-git W: File (opt/openhexagon-git/config.json) has the world writable bit set.
openhexagon-git W: File (opt/openhexagon-git/log.txt) has the world writable bit set.
openhexagon-git W: File (opt/openhexagon-git/scores.json) has the world writable bit set.
openhexagon-git W: File (opt/openhexagon-git/users.json) has the world writable bit set.

Yeah, I guess you know this already...


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#4 2018-10-10 17:51:38

progandy
Member
Registered: 2012-05-17
Posts: 5,184

Re: PKGBUILD Review Request for SSVOpenHexagon

cat << EOF > "$pkgdir/usr/bin/open-hexagon"
#!/usr/bin/sh
cd "/opt/$pkgname"
./SSVOpenHexagon
EOF

You should probably use exec to replace the wrapper script instead of forking a new process.

exec ./SSVOpenHexagon

| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

Board footer

Powered by FluxBB