You are not logged in.
Hi all,
for my workflow i don't need the entire lxd package in aur (lxd daemon plus lxd client called "lxc"), so i prepare this pkgbuild for build only the cli tool (in ubuntu are splitted into different packages, only in snap version are the same packages).
But is my first time with golang, can you review?
I forgot something?
# Maintainer:
pkgname=lxd-client-git
pkgver=3.6
pkgrel=1
pkgdesc="Command line tool for LXD"
arch=('x86_64')
url="https://github.com/lxc/lxd"
license=('APACHE')
conflicts=('lxd-lts' 'lxd')
depends=()
makedepends=('go' 'git')
options=('!strip' '!emptydirs')
_gourl=('github.com/lxc/lxd/lxc')
build() {
GOPATH="$srcdir" go get -fix -v -x ${_gourl}
}
package() {
mkdir -p "$pkgdir/usr/bin"
install -p -m755 "$srcdir/bin/"* "$pkgdir/usr/bin"
mkdir -p "${pkgdir}/usr/share/bash-completion/completions"
cp --preserve=timestamps "${srcdir}/src/github.com/lxc/lxd/scripts/bash/lxd-client" \
"${pkgdir}/usr/share/bash-completion/completions/lxd-client"
}
# vim:set ts=2 sw=2 et:
Ty
Last edited by brokenpip3 (2018-10-22 19:33:11)
Offline
@Mods: my mistake, can you move to right forum section?
i think is https://bbs.archlinux.org/viewforum.php?id=4
Offline
after a quick glance I can see
depends=()
remove empty arrays
mkdir -p "$pkgdir/usr/bin"
install -p -m755 "$srcdir/bin/"* "$pkgdir/usr/bin"
Why do you need this? did you miss something? You could just do
install -Dpm755 "$srcdir/bin/lxc" "$pkgdir/usr/bin/lxc"
...
mkdir -p "${pkgdir}/usr/share/bash-completion/completions"
cp --preserve=timestamps "${srcdir}/src/github.com/lxc/lxd/scripts/bash/lxd-client" \
"${pkgdir}/usr/share/bash-completion/completions/lxd-client"
can be replaced with
install -Dpm644 "${srcdir}/src/github.com/lxc/lxd/scripts/bash/lxd-client" \
"${pkgdir}/usr/share/bash-completion/completions/lxd-client"
Edit: misread those lines...
Edit2: I forgot, this is a git package but you don't define a pkgver function. You could use the lxd pacakge in the AUR as reference.
Last edited by a821 (2018-10-23 17:52:01)
Offline
Hi all,
for my workflow i don't need the entire lxd package in aur (lxd daemon plus lxd client called "lxc"), so i prepare this pkgbuild for build only the cli tool (in ubuntu are splitted into different packages, only in snap version are the same packages).But is my first time with golang, can you review?
I forgot something?
# Maintainer: pkgname=lxd-client-git pkgver=3.6 pkgrel=1 pkgdesc="Command line tool for LXD" arch=('x86_64') url="https://github.com/lxc/lxd" license=('APACHE') conflicts=('lxd-lts' 'lxd')
It should not conflict the lts version, the lts version will conflict and provide lxd.
depends=() makedepends=('go' 'git') options=('!strip' '!emptydirs') _gourl=('github.com/lxc/lxd/lxc') build() { GOPATH="$srcdir" go get -fix -v -x ${_gourl} }
See https://wiki.archlinux.org/index.php/Us … guidelines
Don't download sources during build(), the current golang packaging guidelines are dreadful and you should use the pending rewrite instead.
package() { mkdir -p "$pkgdir/usr/bin" install -p -m755 "$srcdir/bin/"* "$pkgdir/usr/bin" mkdir -p "${pkgdir}/usr/share/bash-completion/completions" cp --preserve=timestamps "${srcdir}/src/github.com/lxc/lxd/scripts/bash/lxd-client" \ "${pkgdir}/usr/share/bash-completion/completions/lxd-client" }
As mentioned, you should just use install(1) for this.
Also note that makepkg will explicitly modify the timestamps of *all* files in the packaged archive, in accordance with https://reproducible-builds.org/specs/s … ate-epoch/
We're trying to be reproducible by default, so if SOURCE_DATE_EPOCH is not set, makepkg will set it based on the date that makepkg started running.
So preserving the timestamps seems sort of pointless...
Managing AUR repos The Right Way -- aurpublish (now a standalone tool)
Offline
after a quick glance I can see
depends=()
remove empty arrays
mkdir -p "$pkgdir/usr/bin" install -p -m755 "$srcdir/bin/"* "$pkgdir/usr/bin"
Why do you need this? did you miss something?You could just doinstall -Dpm755 "$srcdir/bin/lxc" "$pkgdir/usr/bin/lxc"
...
mkdir -p "${pkgdir}/usr/share/bash-completion/completions" cp --preserve=timestamps "${srcdir}/src/github.com/lxc/lxd/scripts/bash/lxd-client" \ "${pkgdir}/usr/share/bash-completion/completions/lxd-client"
can be replaced with
install -Dpm644 "${srcdir}/src/github.com/lxc/lxd/scripts/bash/lxd-client" \ "${pkgdir}/usr/share/bash-completion/completions/lxd-client"
Edit: misread those lines...
Edit2: I forgot, this is a git package but you don't define a pkgver function. You could use the lxd pacakge in the AUR as reference.
Thanks, i rewrite the entire pkgbuild to fit the "-git" version with pkgver.
# Maintainer:
pkgname=lxd-client-git
pkgver=3.6.r57.7af057b6
pkgrel=1
pkgdesc="Command line tool for LXD"
arch=('x86_64')
url="https://github.com/lxc/lxd"
license=('APACHE')
conflicts=('lxd')
makedepends=('go-pie' 'git')
options=('!strip' '!emptydirs')
_gourl=('github.com/lxc/lxd/lxc')
prepare() {
export GOPATH="${srcdir}/go"
mkdir -p "${GOPATH}"
go get -d -v ${_gourl}
}
pkgver() {
cd "${GOPATH}/src/${_gourl}"
printf "%s" "$(git describe --long | sed 's/^lxd-//;s/\([^-]*-\)g/r\1/;s/-/./g')"
}
build() {
cd "${GOPATH}/src/${_gourl}"
go build
go install
}
package() {
install -Dpm755 "$srcdir/go/bin/lxc" "$pkgdir/usr/bin/lxc"
install -Dpm644 "${srcdir}/go/src/github.com/lxc/lxd/scripts/bash/lxd-client" \
"${pkgdir}/usr/share/bash-completion/completions/lxd-client"
}
# vim:set ts=2 sw=2 et:
@eschwartz thanks for clarifying me the reproducible-build but i don't understand why i must remove lxd-lts (the package in aur build the cli client (lts version) but conflict with mine).
And how i can create the pkgvers without download the source?
thanks guys for your tip
Offline
@eschwartz thanks for clarifying me the reproducible-build but i don't understand why i must remove lxd-lts (the package in aur build the cli client (lts version) but conflict with mine).
Because your PKGBUILD conflicts with "lxd", and the other PKGBUILD conflicts+provides "lxd" as well. This means that your PKGBUILD, by extension, conflicts with *any* PKGBUILD that provides "lxd".
This is why your PKGBUILD should also
provides=('lxd')
And how i can create the pkgvers without download the source?
I don't know what you mean by that. Of course you have sources downloaded, you're supposed to do that by using https://wiki.archlinux.org/index.php/PKGBUILD#source
Managing AUR repos The Right Way -- aurpublish (now a standalone tool)
Offline
Because your PKGBUILD conflicts with "lxd", and the other PKGBUILD conflicts+provides "lxd" as well. This means that your PKGBUILD, by extension, conflicts with *any* PKGBUILD that provides "lxd".
This is why your PKGBUILD should also
provides=('lxd')
Thanks, so my last changes:
+ provides=('lxd')
+ GOFLAGS from go guidelines linked by eschwartz
# Maintainer:
pkgname=lxd-client-git
pkgver=3.6.r59.975a559f
pkgrel=1
pkgdesc="Command line tool for LXD"
arch=('x86_64')
url="https://github.com/lxc/lxd"
license=('APACHE')
conflicts=('lxd' 'lxd-git')
provides=('lxd')
makedepends=('go-pie' 'git')
options=('!strip' '!emptydirs')
_gourl=('github.com/lxc/lxd/lxc')
prepare() {
export GOPATH="${srcdir}/go"
mkdir -p "${GOPATH}"
go get -d -v ${_gourl}
}
pkgver() {
cd "${GOPATH}/src/${_gourl}"
printf "%s" "$(git describe --long | sed 's/^lxd-//;s/\([^-]*-\)g/r\1/;s/-/./g')"
}
build() {
cd "${GOPATH}/src/${_gourl}"
export GOFLAGS="-ldflags=-s -ldflags=-w -gcflags=all=-trimpath=${GOPATH} -asmflags=all=-trimpath=${GOPATH}"
go build
go install -v
}
package() {
install -Dpm755 "$srcdir/go/bin/lxc" "$pkgdir/usr/bin/lxc"
install -Dpm644 "${srcdir}/go/src/github.com/lxc/lxd/scripts/bash/lxd-client" \
"${pkgdir}/usr/share/bash-completion/completions/lxd-client"
}
# vim:set ts=2 sw=2 et:
Offline
But you still haven't fixed it to download the sources properly using source=()
Also, you still need to remove lxd-git from the conflicts array.
Managing AUR repos The Right Way -- aurpublish (now a standalone tool)
Offline
But you still haven't fixed it to download the sources properly using source=()
I'm sorry, maybe i miss something but from what I understood the command "go get" download the main repo and all dependencies needed. If I use only "source" to download sources how i get the same result? (download for all the dependencies too)
Or maybe i can use source to fill the pkgversion but after i must download recursive again using "go get".
please tell me if i wrong, i don't know golang stuff
Thanks
Offline
Follow the first link in #5, is "go get" used anywhere on that page ?
look at the 3 example packages that page mentions, do they use "go get" ?
Then goto lxd github site and check their releases page.
compare what's in a source code tarball with what "go get" downloads.
Last edited by Lone_Wolf (2018-10-27 12:56:24)
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