You are not logged in.

#1 2019-05-28 12:55:01

j1simon
Member
From: Denmark
Registered: 2016-01-28
Posts: 189

[SOLVED] PKGBUILD for Go program: problem to clean Go dependencies

I've done this PKGBUILD:

pkgname=gosearch-git
_pkgname=gosearch
pkgver=r44.71829c9
pkgrel=1
pkgdesc="A fast, real-time file searching program for linux"
url="https://github.com/ozeidan/gosearch"
arch=('x86_64')
license=('GPL3')
makedepends=(go-pie git dep)
depends=('linux>=5.1')
provides=("${pkgname%-git}")
conflicts=("${provides[@]}")
source=("${pkgname}::git+${url}")
sha256sums=('SKIP')
_srcgo=go/src/github.com/ozeidan

install="gosearch.install"

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

	printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

prepare(){
	cd "$srcdir"/$pkgname
	
	install -m755 -d ""$srcdir"/$_srcgo"
	ln -sf "$srcdir"/$pkgname "$srcdir"/$_srcgo/$_pkgname
	
	cd "$srcdir"/$_srcgo/$_pkgname
	export GOPATH="$srcdir"/go	
	export GO111MODULE=on
	go get -v ./...
}

build() {
	export GOPATH="$srcdir"/go
	
	local _sourcego="$srcdir"/$_srcgo/$_pkgname

	cd $_sourcego/cmd/server

	go build \
	-gcflags "all=-trimpath=$srcdir" \
	-asmflags "all=-trimpath=$srcdir" \
	-ldflags "-extldflags ${LDFLAGS}" \
	-o gosearchServer

	cd $_sourcego/cmd/client

	go build \
	-gcflags "all=-trimpath=$srcdir" \
	-asmflags "all=-trimpath=$srcdir" \
	-ldflags "-extldflags ${LDFLAGS}" \
	-o gosearch
}

package() {
	cd "$srcdir"/$pkgname
	install -Dm755 cmd/server/gosearchServer "${pkgdir}"/usr/bin/gosearchServer
	install -Dm755 cmd/client/gosearch "${pkgdir}"/usr/bin/gosearch
	install -Dm644 init/gosearch.service "${pkgdir}"/usr/lib/systemd/system/gosearch.service   
}

(Creation of PKGBUILD for a Go program is a headache)

The problem is when I execute the clean option:

$ makepkg -sc
==> Making package: gosearch-git r44.71829c9-1 (mar 28 may 2019 14:47:32 CEST)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
  -> Updating gosearch-git git repo...
Fetching origin
==> Validating source files with sha256sums...
    gosearch-git ... Skipped
==> Extracting sources...
  -> Creating working copy of gosearch-git git repo...
Switched to a new branch 'makepkg'
==> Starting prepare()...
==> Starting pkgver()...
==> Removing existing $pkgdir/ directory...
==> Starting build()...
==> Entering fakeroot environment...
==> Starting package()...
==> Tidying install...
  -> Removing doc files...
  -> Removing libtool files...
  -> Purging unwanted files...
  -> Removing static library files...
  -> Stripping unneeded symbols from binaries and libraries...
  -> Compressing man and info pages...
==> Checking for packaging issues...
==> Creating package "gosearch-git"...
  -> Generating .PKGINFO file...
  -> Generating .BUILDINFO file...
  -> Adding install file...
  -> Generating .MTREE file...
  -> Compressing package...
==> Leaving fakeroot environment.
==> Finished making: gosearch-git r44.71829c9-1 (mar 28 may 2019 14:47:35 CEST)
==> Cleaning up...
rm: cannot remove '/tmp/makepkg/gosearch-git/src/go/pkg/mod/golang.org/x/sys@v0.0.0-20190502175342-a43fa875dd82/windows/zsyscall_windows.go': Permission denied
rm: cannot remove '/tmp/makepkg/gosearch-git/src/go/pkg/mod/golang.org/x/sys@v0.0.0-20190502175342-a43fa875dd82/windows/zerrors_windows.go': Permission denied
rm: cannot remove '/tmp/makepkg/gosearch-git/src/go/pkg/mod/golang.org/x/sys@v0.0.0-20190502175342-a43fa875dd82/windows/types_windows_arm.go': Permission denied
rm: cannot remove '/tmp/makepkg/gosearch-git/src/go/pkg/mod/golang.org/x/sys@v0.0.0-20190502175342-a43fa875dd82/windows/types_windows_amd64.go': Permission denied
rm: cannot remove '/tmp/makepkg/gosearch-git/src/go/pkg/mod/golang.org/x/sys@v0.0.0-20190502175342-a43fa875dd82/windows/types_windows_386.go': Permission denied
rm: cannot remove '/tmp/makepkg/gosearch-git/src/go/pkg/mod/golang.org/x/sys@v0.0.0-20190502175342-a43fa875dd82/windows/types_windows.go': Permission denied
rm: cannot remove '/tmp/makepkg/gosearch-git/src/go/pkg/mod/golang.org/x/sys@v0.0.0-20190502175342-a43fa875dd82/windows/syscall_windows_test.go': Permission denied
....

"go get" downloads all dependencies with read only permissions. How can I change this? What am I doing wrong?

Last edited by j1simon (2019-05-28 15:10:16)

Offline

#2 2019-05-28 13:01:24

arijitd
Member
Registered: 2019-05-28
Posts: 3

Re: [SOLVED] PKGBUILD for Go program: problem to clean Go dependencies

Ask the question in Creating & modifying Packages section of the forums. Someone might help you. This section is for Arch Linux installation.

Last edited by arijitd (2019-05-28 13:02:57)

Offline

#3 2019-05-28 13:09:43

2ManyDogs
Forum Fellow
Registered: 2012-01-15
Posts: 4,645

Re: [SOLVED] PKGBUILD for Go program: problem to clean Go dependencies

Not an Installation issue. Moving to Creating & Modifying Packages.

Offline

#4 2019-05-28 15:09:58

j1simon
Member
From: Denmark
Registered: 2016-01-28
Posts: 189

Re: [SOLVED] PKGBUILD for Go program: problem to clean Go dependencies

Solved, it's a Go "issue": https://github.com/golang/go/issues/27455
I've solved it like this:

...
prepare(){
...	
	cd "$srcdir"/$pkgname	
	sed -i -e 's/clean$/clean -modcache/1' -e '/rm -f \$./d' Makefile	
}

build() {
...
	make clean
}
....

Offline

Board footer

Powered by FluxBB