Bug 278710 - devel/gitlab-shell 14.35.0 build fails at extract phase
Summary: devel/gitlab-shell 14.35.0 build fails at extract phase
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Only Me
Assignee: Matthias Fechner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-05-03 07:28 UTC by Marko Cupać
Modified: 2024-05-21 13:49 UTC (History)
5 users (show)

See Also:
bugzilla: maintainer-feedback? (mfechner)


Attachments
build log (670.33 KB, text/plain)
2024-05-06 08:18 UTC, Marko Cupać
no flags Details
Build log (670.10 KB, text/plain)
2024-05-15 07:01 UTC, Anton Evel
no flags Details
an ugly patch to allow to build gitlab-shell as non-root user (1.49 KB, patch)
2024-05-15 11:01 UTC, Yasuhito FUTATSUKI
no flags Details | Diff
an ugly patch to allow to build gitlab-shell as non-root user (1.49 KB, patch)
2024-05-15 18:58 UTC, Yasuhito FUTATSUKI
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Marko Cupać 2024-05-03 07:28:06 UTC
Hi,

I can't build devel/gitlab-shell 14.35.0 in 14_0:x86:64 poudriere jail. I guess it's due to building as non-root. Previous versions were fine with this.

Here's log excerpt:

=======================<phase: extract-depends>============================
===== env: USE_PACKAGE_DEPENDS_ONLY=1 USER=root UID=0 GID=0
===========================================================================
=======================<phase: extract        >============================
===== env: NO_DEPENDS=yes USER=nobody UID=65534 GID=65534
===>  License MIT accepted by the user
===> Fetching all distfiles required by gitlab-shell-14.35.0 for building
Copy go.mod as go mod download will modify it, which breaks checksum check
cp: go.mod.orig: Permission denied
*** Error code 1
Comment 1 Matthias Fechner freebsd_committer freebsd_triage 2024-05-04 16:08:54 UTC
The last fix was necessary as go is modifing the go.mod file while downloadig packages and therefor I make a copy of the go.mod file and restore it, after go finished the download of all modules, to not break the checksum of the file.

It seems that this is impossible while running as user.

I do not plan to find a workaround for this case. Building as root is fine and that is also how the FreeBSD build system is creating the packages.

But if you would like to provide with a patch that fixes the problem, I will merge it.

Make sure you remove all distfiles, before you test your patch.
Comment 2 Marko Cupać 2024-05-06 08:18:37 UTC
Created attachment 250487 [details]
build log

Any idea why copying and restoring occurs in checksum and extract phases as well, besides fetch phase? If I understand correctly, copying should occur at the start of fetch phase, and restoring at the end of fetch phase, no need to repeat it in later phases.

I am attaching full log.
Comment 3 Anton Evel 2024-05-15 07:01:58 UTC
Created attachment 250665 [details]
Build log

Dear Matthias,

as I can see, the user 'nobody' is something belongs to build and installation process and I can't influence it. My poudriere runs as root and I don't have any other users on my server, that's why I can't agree that building as root has no problems. My log is the same as Marko's (see full log attached).

Tell me, please, if I'm doing something wrong and there's the best way to build this port.

Best wishes, Anton.

# get https://proxy.golang.org/sigs.k8s.io/yaml/@v/v1.3.0.zip
# get https://proxy.golang.org/rsc.io/sampler/@v/v1.3.0.zip: 200 OK (1.235s)
# get https://proxy.golang.org/sigs.k8s.io/json/@v/v0.0.0-20221116044647-bc3834ca7abd.zip: 200 OK (1.481s)
# get https://proxy.golang.org/sigs.k8s.io/yaml/@v/v1.3.0.zip: 200 OK (1.225s)
# get https://proxy.golang.org/sigs.k8s.io/structured-merge-diff/v4/@v/v4.3.0.zip: 200 OK (1.622s)
Restore previous go.mod
===========================================================================
=======================<phase: checksum       >============================
===== env: NO_DEPENDS=yes USER=root UID=0 GID=0
===>  License MIT accepted by the user
===> Fetching all distfiles required by gitlab-shell-14.35.0_1 for building
Copy go.mod as go mod download will modify it, which breaks checksum check
===> Fetching  dependencies
Restore previous go.mod
=> SHA256 Checksum OK for go/devel_gitlab-shell/gitlab-shell-v14.35.0/go.mod.
=> SHA256 Checksum OK for go/devel_gitlab-shell/gitlab-shell-v14.35.0/gitlab-shell-v14.35.0.tar.bz2.
===========================================================================
=======================<phase: extract-depends>============================
===== env: USE_PACKAGE_DEPENDS_ONLY=1 USER=root UID=0 GID=0
===========================================================================
=======================<phase: extract        >============================
===== env: NO_DEPENDS=yes USER=nobody UID=65534 GID=65534
===>  License MIT accepted by the user
===> Fetching all distfiles required by gitlab-shell-14.35.0_1 for building
Copy go.mod as go mod download will modify it, which breaks checksum check
cp: go.mod.orig: Permission denied
*** Error code 1

Stop.
make: stopped in /usr/ports/devel/gitlab-shell
=>> Cleaning up wrkdir
===>  Cleaning for gitlab-shell-14.35.0_1
build of devel/gitlab-shell | gitlab-shell-14.35.0_1 ended at Wed May 15 00:11:25 MSK 2024
build time: 00:03:08
!!! build failure encountered !!!
Comment 4 johannes.kunde 2024-05-15 07:52:52 UTC
Search for config option PORTBUILD_USER in /usr/local/etc/poudriere.conf and set PORTBUILD_USER=root. Does it build successfully with this option changed?
Comment 5 Anton Evel 2024-05-15 08:02:55 UTC
Dear Johannes,

thank you, that was made it built successfully!
Comment 6 Marko Cupać 2024-05-15 10:09:29 UTC
Hi,

of 1743 ports I am currently building in poudriere, devel/gitlab-shell is the only one that won't build as non-root.

Maintainting gitlab instance on FreeBSD has always been painful to me. I can only imagine what herculean effort Matthias needs to put in in order to maintain the port, officially unsupported by upstream, with few hundred rubygem dependencies that must be at exact versions, quite a number of them additionally patched.

For now, my newly set up www/forgejo instance seem to meet all my expectations, with much less hassle to set up and maintain.

I'll continue to try building gilab, hopefully one day it will build as non-root again, as all the other ports I know of do.
Comment 7 Yasuhito FUTATSUKI 2024-05-15 11:01:53 UTC
Created attachment 250677 [details]
an ugly patch to allow to build gitlab-shell as non-root user

This is an example patch to avoid executing the workaround repeatedly, although I don't know it is acceptable usage of DISTDIR or not.

With this patch, poudriere fetches distfiles as root and does not attempt to write to DISTDIR as non root user.
Comment 8 Yasuhito FUTATSUKI 2024-05-15 18:58:18 UTC
Created attachment 250685 [details]
an ugly patch to allow to build gitlab-shell as non-root user
Comment 9 Matthias Fechner freebsd_committer freebsd_triage 2024-05-16 05:32:52 UTC
(In reply to Yasuhito FUTATSUKI from comment #8)
Thanks a lot, I will test it and if it is fine, I will commit the patch.
Comment 10 Matthias Fechner freebsd_committer freebsd_triage 2024-05-16 11:14:29 UTC
I did some tests and the `.go-post-fetch-done` will not get removed with a `make distclean` which maybe can cause some other problems.

But I think I will commit it, so users that are building as non-root can create the package again.
Comment 11 Yasuhito FUTATSUKI 2024-05-16 20:20:42 UTC
(In reply to Matthias Fechner from comment #10)
We can insert extra target before delete-distfiles target to remove extra files like:

@@ -81,4 +84,13 @@ post-install:
                ${SED} -E -e '/sample$$/ s#^#@sample #; \
                s#${DATADIR_REL}/bin#@(,,555) ${DATADIR_REL}/bin#; ' >> ${TMPPLIST}
 
-.include <bsd.port.mk>
+go-pre-delete-distfiles:
+       @if [ -e ${DISTDIR}/${DIST_SUBDIR}/.go-post-fetch-done ]; then\
+               ${RM} ${DISTDIR}/${DIST_SUBDIR}/.go-post-fetch-done || ${TRUE};\
+       fi
+
+.include <bsd.port.pre.mk>
+
+delete-distfiles: go-pre-delete-distfiles
+
+.include <bsd.port.post.mk>
Comment 12 commit-hook freebsd_committer freebsd_triage 2024-05-17 06:44:31 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=3c8fd2ac242ab03120b5d7eb4a02f84d346a0475

commit 3c8fd2ac242ab03120b5d7eb4a02f84d346a0475
Author:     Yasuhito FUTATSUKI <freebsd-bug-report-yf@yf.bsdclub.org>
AuthorDate: 2024-05-16 11:19:29 +0000
Commit:     Matthias Fechner <mfechner@FreeBSD.org>
CommitDate: 2024-05-17 06:42:56 +0000

    devel/gitlab-shell: fix build as non-root user in poudriere

    PR:             278710

 devel/gitlab-shell/Makefile | 28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)
Comment 13 Matthias Fechner freebsd_committer freebsd_triage 2024-05-17 06:52:32 UTC
(In reply to Yasuhito FUTATSUKI from comment #11)
Thanks a lot.
I committed this fix.
Comment 14 commit-hook freebsd_committer freebsd_triage 2024-05-21 13:49:36 UTC
A commit in branch 2024Q2 references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=c0d940d81130b3847fb4a997b491c7542c4e4b62

commit c0d940d81130b3847fb4a997b491c7542c4e4b62
Author:     Yasuhito FUTATSUKI <freebsd-bug-report-yf@yf.bsdclub.org>
AuthorDate: 2024-05-16 11:19:29 +0000
Commit:     Matthias Fechner <mfechner@FreeBSD.org>
CommitDate: 2024-05-21 12:59:11 +0000

    devel/gitlab-shell: fix build as non-root user in poudriere

    PR:             278710
    (cherry picked from commit 3c8fd2ac242ab03120b5d7eb4a02f84d346a0475)

 devel/gitlab-shell/Makefile | 28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)