You are not logged in.

#1 2024-08-18 10:11:42

gwpl
Member
From: Warsaw, Poland
Registered: 2010-07-10
Posts: 35

assemblyai-cli building golang from git repo

As per https://wiki.archlinux.org/title/AUR_su … guidelines , in case of doubt was recommended to post question here before posting to AUR.

I've made this PKGBUILD:

pkgname=assemblyai-cli-git
pkgver=r1.c8eb9bf
pkgrel=1
pkgdesc="CLI tool for interacting with AssemblyAI's API"
arch=('x86_64')
url="https://github.com/AssemblyAI/assemblyai-cli"
license=('Apache-2.0')
depends=('glibc')
makedepends=('go')
provides=('assemblyai-cli')
conflicts=('assemblyai-cli')

pkgver() {
  cd "$srcdir/assemblyai-cli"
  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

prepare() {
  git clone --depth 1 https://github.com/AssemblyAI/assemblyai-cli.git "$srcdir/assemblyai-cli"
}

build() {
  cd "$srcdir/assemblyai-cli"
  export CGO_CPPFLAGS="${CPPFLAGS}"
  export CGO_CFLAGS="${CFLAGS}"
  export CGO_CXXFLAGS="${CXXFLAGS}"
  export CGO_LDFLAGS="${LDFLAGS}"
  export GOFLAGS="-buildmode=pie -trimpath -ldflags=-linkmode=external -mod=readonly -modcacherw"
  go build -o build/assemblyai
}

check() {
  cd "$srcdir/assemblyai-cli"
  if [ ! -f build/assemblyai ]; then
    echo "Error: assemblyai binary not found"
    return 1
  fi
}

package() {
  cd "$srcdir/assemblyai-cli"
  install -Dm755 build/assemblyai "$pkgdir/usr/bin/assemblyai"
}

(also posted here : https://github.com/CLIAI/handy_scripts/ … D/PKGBUILD )

that makes generates packages :
* `assemblyai-cli-git-debug-r20240506.-1-x86_64.pkg.tar.zst`
* `assemblyai-cli-git-r20240506.-1-x86_64.pkg.tar.zst`

With following contents:

$ pacman -Ql assemblyai-cli-git{,-debug}
assemblyai-cli-git /usr/
assemblyai-cli-git /usr/bin/
assemblyai-cli-git /usr/bin/assemblyai
assemblyai-cli-git-debug /usr/
assemblyai-cli-git-debug /usr/lib/
assemblyai-cli-git-debug /usr/lib/debug/
assemblyai-cli-git-debug /usr/lib/debug/.build-id/
assemblyai-cli-git-debug /usr/lib/debug/.build-id/cd/
assemblyai-cli-git-debug /usr/lib/debug/.build-id/cd/a4f5f1e051a060336c08fd968c6ae0976e79a5
assemblyai-cli-git-debug /usr/lib/debug/.build-id/cd/a4f5f1e051a060336c08fd968c6ae0976e79a5.debug
assemblyai-cli-git-debug /usr/lib/debug/usr/
assemblyai-cli-git-debug /usr/lib/debug/usr/bin/
assemblyai-cli-git-debug /usr/lib/debug/usr/bin/assemblyai.debug
assemblyai-cli-git-debug /usr/src/
assemblyai-cli-git-debug /usr/src/debug/
assemblyai-cli-git-debug /usr/src/debug/assemblyai-cli-git/

Do you consider this PKGBUILD good to submit as `assemblyai-git` AUR package?

Last edited by gwpl (2024-08-25 19:15:49)

Offline

#2 2024-08-19 12:17:11

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 12,926

Re: assemblyai-cli building golang from git repo

makepkg automatically downloads everything in spource array.

If you are trying to reduce bandwidth (or diskspace used) by retrieving a shallow clone in prepare() , don't list the git repo in source array.

you should also check https://wiki.archlinux.org/title/Go_package_guidelines .


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#3 2024-08-19 15:33:52

gwpl
Member
From: Warsaw, Poland
Registered: 2010-07-10
Posts: 35

Re: assemblyai-cli building golang from git repo

Thank you for pointers! I applied Arch Package / AUR / GO guildelines and your advice about sources.

I updated first message with new version of PKGBULID, here are changes that I introduced: https://github.com/CLIAI/handy_scripts/ … 37e3daafd7 , could you please take another look?

Offline

#4 2024-08-20 10:10:33

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 12,926

Re: assemblyai-cli building golang from git repo

Please edit your first post to use code tags for the command output and the content of the PKGBUILD.
see https://bbs.archlinux.org/help.php#bbcode

pkgver() is run after prepare() so it should work ok for setting the version .

Empty fields are usually removed.

It's rare for a package to have no dependencies but the website doesn't list any .
Try building this in a clean chroot to verify if it really needs no dependencies .


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#5 2024-08-25 17:31:40

gwpl
Member
From: Warsaw, Poland
Registered: 2010-07-10
Posts: 35

Re: assemblyai-cli building golang from git repo

I've updated PKGBUILD (updated PKGBUILD bbcode code block in firs tmessage) and provided Makefile and Dockerfile to test with clean chroot, looks like `go` is only dependency:
https://github.com/CLIAI/handy_scripts/ … 94d3c69f99

```
$ make test_in_clean_chroot_using_docker
docker build -t assemblyai-cli-test . && \
docker run --rm assemblyai-cli-test && \
echo SUCCESS || echo FAILED
[+] Building 0.5s (12/12) FINISHED                                docker:default
=> [internal] load build definition from Dockerfile                        0.0s
=> => transferring dockerfile: 461B                                        0.0s
=> [internal] load metadata for docker.io/library/archlinux:base-devel     0.4s
=> [internal] load .dockerignore                                           0.0s
=> => transferring context: 2B                                             0.0s
=> [1/7] FROM docker.io/library/archlinux:base-devel@sha256:b212ba57dea42  0.0s
=> [internal] load build context                                           0.0s
=> => transferring context: 30B                                            0.0s
=> CACHED [2/7] RUN pacman -Syu --noconfirm git go                         0.0s
=> CACHED [3/7] RUN useradd -m -G wheel builder &&     echo "builder ALL=  0.0s
=> CACHED [4/7] WORKDIR /home/builder                                      0.0s
=> CACHED [5/7] COPY PKGBUILD .                                            0.0s
=> CACHED [6/7] RUN makepkg -s --noconfirm                                 0.0s
=> CACHED [7/7] RUN ls -lha *.pkg.*                                        0.0s
=> exporting to image                                                      0.0s
=> => exporting layers                                                     0.0s
=> => writing image sha256:b31d8dcd362ef7c1c0a025f5503f36b473ea25d9a7158a  0.0s
=> => naming to docker.io/library/assemblyai-cli-test                      0.0s
SUCCESS
SUCCESS

$ make remove_docker_image
```

Offline

#6 2024-08-25 18:03:53

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,330
Website

Re: assemblyai-cli building golang from git repo

Building in a chroot does not determine that it needs no dependencies.  It means the chroot just has everything needed to build.  Check what any binaries actually link to.

EDIT: okay, confirmed it is quite minimal, but glibc should be listed as a dependency.

Last edited by Trilby (2024-08-25 18:06:52)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#7 2024-08-25 19:17:37

gwpl
Member
From: Warsaw, Poland
Registered: 2010-07-10
Posts: 35

Re: assemblyai-cli building golang from git repo

Thank you! Added glibc to PKGBUILD!

$ ldd /usr/bin/assemblyai 
        linux-vdso.so.1 (0x00007bdf861b5000)
        libc.so.6 => /usr/lib/libc.so.6 (0x00007bdf84e0f000)
        /lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007bdf861b7000)

Offline

Board footer

Powered by FluxBB