loading...

Gitea 1.11 on OpenBSD: Update Failure

nabbisen profile image Heddi Nabbisen Updated on ・2 min read

Gitea On OpenBSD (2 Part Series)

1) Gitea On OpenBSD: Using Official Package 2) Gitea 1.11 on OpenBSD: Update Failure

This post is about updating Gitea v1.11 in OpenBSD around 6.7.
Since v1.11, when making gitea with its BSDmakefile, I have met the error for some times like this:

$ env TAGS="bindata" make -f BSDmakefile generate build
...
writing bindata.go
...
grep: repetition-operator operand invalid
Gitea requires Node.js 10.0.0 or greater and npm to build. You can get it at https://nodejs.org/en/download/
gmake: *** [Makefile:143: node-check] Error 1
*** Error 2 in /.../gitea (BSDmakefile:46 'FRC': "gmake" "--no-print-directory" generate build )

It happened, for example, to update 1.11.1 -> 1.11.2 and 1.11.5 -> 1.11.6.
This is because of not Node.js but grep module in OS.
It's actually because of the difference in using options between GNU grep and OpenBSD's grep.

OpenBSD's default grep is like this:

$ /usr/bin/grep --help
usage: grep [-abcEFGHhIiLlnoqRsUVvwxZ] [-A num] [-B num] [-C[num]] [-e pattern]
    [-f file] [-m num] [--binary-files=value] [--context[=num]]
    [--label=name] [--line-buffered] [pattern] [file ...]

The current solution I have found after struggling is installing ggrep. It is GNU grep as ports package.
To install it, run:

# pkg_add ggrep

In the process of Gitea make, it's necessary to let running grep result in running /usr/local/bin/ggrep.
Therefore, I created the symbolic link and modified $PATH temporarily:

$ ln -s /usr/local/bin/ggrep /(somewhere)/grep
$ export PATH="/(somewhere):$PATH"

$ # verify
$ # (1) $PATH begins with /(somewhere)
$ echo $PATH
/(somewhere) ... /usr/bin /bin /usr/sbin /sbin ... /usr/local/bin /usr/local/sbin
$ # (2) `grep` is GNU grep
$ grep --help
Usage: grep [OPTION]... PATTERNS [FILE]...
Search for PATTERNS in each FILE.
Example: ggrep -i 'hello world' menu.h main.c

Thus ggrep became used as grep.
Ready for make:

$ env TAGS="bindata" make -f BSDmakefile generate build

It was successful 😃

To clean up temporary file and env, finally:

$ rm /(somewhere)/grep

$ # reset $PATH
$ # case fish:
$ fish ~/.config/fish/config.fish
$ # else:
$ . ~/.profile

Optionally, there is a similar but more dangerous way...
This is my first solution.
Then I tried not to change /usr/bin manually and got the solution above 😅
Please be careful because there is a risk of deleting /usr/bin files by mistake in the below way:

# # replace original `grep` with `ggrep`'s symbolic link
# mv /usr/bin/grep /usr/bin/grep_bk
# ln -s /usr/local/bin/ggrep /usr/bin/grep

$ env TAGS="bindata" make -f BSDmakefile generate build

# # recover original `grep`
# mv /usr/bin/grep_bk /usr/bin/grep

Gitea On OpenBSD (2 Part Series)

1) Gitea On OpenBSD: Using Official Package 2) Gitea 1.11 on OpenBSD: Update Failure

Posted on by:

nabbisen profile

Heddi Nabbisen

@nabbisen

An ICT designer/developer and a security monk. "With a cool brain and a warm heart", I am challenging unsolved problems in our society. I use OpenBSD/Rust/etc.

Discussion

markdown guide