DEV Community

nabbisen
nabbisen

Posted on β€’ Edited on

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 )
Enter fullscreen mode Exit fullscreen mode

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 ...]
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Thus ggrep became used as grep.
Ready for make:

$ env TAGS="bindata" make -f BSDmakefile generate build
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Do your career a big favor. Join DEV. (The website you're on right now)

It takes one minute, it's free, and is worth it for your career.

Get started

Community matters

Top comments (0)

πŸ‘‹ Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay