You are not logged in.

#1 2024-11-20 09:56:20

gao66
Member
Registered: 2024-11-20
Posts: 4

PKGBUILD Issue: build always failed

I tried to write a pkgbuild for a rust software today, but it kept failing to compile. I tried many methods, including explicitly specifying the library path, but it still failed to compile. However, I was able to build successfully by running

cargo build -r

directly in the project folder.

I hope someone can help me, thank you again

The following is the PKGBUILD

# Maintainer: gao <gao66 at sdf dot org>

pkgname=iptv-checker-rs-git
_pkgname=iptv-checker-rs
pkgver=3.2.1.r10.g0a1e1c9
pkgrel=1
pkgdesc="Checking links in IPTV playlists written in Rust"
arch=('x86_64' 'aarch64')
url="https://github.com/zhimin-dev/iptv-checker-rs"
license=('unknown')
depends=('ffmpeg')
makedepends=('rust' 'cargo' 'git' 'base-devel')
source=("git+$url.git")
sha256sums=('SKIP')
backup=("usr/share/${pkgname}/tasks.json")

pkgver() {
    cd "$srcdir/$_pkgname"
    git describe --long --tags --abbrev=7 | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
}

prepare() {
    cd "$srcdir/$_pkgname"
    git submodule update --init --recursive
}

build() {
    cd "$srcdir/$_pkgname"
    cargo build --release --verbose
}

package() {
  cd "$srcdir/$_pkgname"
  install -Dm755 "target/release/$_pkgname" "$pkgdir/usr/share/$_pkgname/$_pkgname"

  install -d "$pkgdir/usr/share/$_pkgname/web"
  cp -r web/* "$pkgdir/usr/share/$_pkgname/web"
  
  ln -s "/usr/share/$_pkgname/$_pkgname" "$pkgdir/usr/bin/$_pkgname"
}

Last edited by gao66 (2024-11-20 10:05:54)

Offline

#2 2024-11-20 10:20:33

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

Re: PKGBUILD Issue: build always failed

source=("git+$url.git")

prepare() {
    cd "$srcdir/$_pkgname"
    git submodule update --init --recursive
}

Using git submodules in a PKGBUILD requires more then that.

You should also read https://wiki.archlinux.org/title/Rust_p … 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-11-20 10:53:40

gao66
Member
Registered: 2024-11-20
Posts: 4

Re: PKGBUILD Issue: build always failed

Sad. Still can't build

Modified according to wiki requirements

# Maintainer: gao <gao66 at sdf dot org>

pkgname=iptv-checker-rs-git
_pkgname=iptv-checker-rs
pkgver=3.2.1.r10.g0a1e1c9
pkgrel=1
pkgdesc="Checking links in IPTV playlists written in Rust"
arch=('x86_64' 'aarch64')
url="https://github.com/zhimin-dev/iptv-checker-rs"
license=('unknown')
depends=('ffmpeg')
makedepends=('cargo' 'git')
source=("git+$url.git")
sha256sums=('SKIP')
backup=("usr/share/${pkgname}/tasks.json")

pkgver() {
    cd "$srcdir/$_pkgname"
    git describe --long --tags --abbrev=7 | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
}

prepare() {
    cd "$srcdir/$_pkgname"
    export RUSTUP_TOOLCHAIN=stable
    cargo fetch --offline --target "$CARCH-unknown-linux-gnu"
}

build() {
    cd "$srcdir/$_pkgname"
    export RUSTUP_TOOLCHAIN=stable
    export CARGO_TARGET_DIR=target
    cargo build --frozen --release --all-features
}

package() {
  cd "$srcdir/$_pkgname"
  install -Dm755 "target/release/$_pkgname" "$pkgdir/usr/share/$_pkgname/$_pkgname"

  install -d "$pkgdir/usr/share/$_pkgname/web"
  cp -r web/* "$pkgdir/usr/share/$_pkgname/web"
  
  ln -s "/usr/share/$_pkgname/$_pkgname" "$pkgdir/usr/bin/$_pkgname"
}

And there are errors

<The above omitted>
...
          /home/john/.cargo/registry/src/index.crates.io-6f17d22bba15001f/openssl-sys-0.9.104/src/./ssl.rs:468:(.text._ZN11openssl_sys7openssl3ssl29SSL_CTX_set_max_proto_version17hcb326ccf4a2ca007E+0x11): undefined reference to `SSL_CTX_ctrl'
          /usr/bin/ld: /home/john/git/aur/iptv-checker-rs/src/iptv-checker-rs/target/release/deps/iptv_checker_rs-d37e696246cab059: hidden symbol `OPENSSL_cpuid_setup' isn't defined
          /usr/bin/ld: final link failed: bad value
          collect2: error: ld returned 1 exit status
          
  = note: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
  = note: use the `-l` flag to specify native libraries to link
  = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#rustc-link-lib)

warning: `iptv-checker-rs` (bin "iptv-checker-rs") generated 29 warnings
error: could not compile `iptv-checker-rs` (bin "iptv-checker-rs") due to 1 previous error; 29 warnings emitted

Although it can be compiled directly in the project folder, it cannot be compiled with pkgbuild

And If anyone can solve this problem, I will pay them 10 us dollers.

Last edited by gao66 (2024-11-20 11:04:38)

Offline

#4 2024-11-20 11:04:49

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

Re: PKGBUILD Issue: build always failed

Your cargo fetch command in prepare is not the same as in wiki, you are also no longer using git submodules .

The error itself looks like it may be caused by  a missing dep or version mismatch .

Please link to the upstream build instructions you follow .


Added :

And If anyone can solve this problem, I will pay them 10 us dollers.

Every user of archlinux (including staff) volunteers their time and effort without asking anything in return.
Offers like that make people wonder if someone will fit in the community and increase the chance people won't help.

Last edited by Lone_Wolf (2024-11-20 11:10:32)


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-11-20 12:19:28

gao66
Member
Registered: 2024-11-20
Posts: 4

Re: PKGBUILD Issue: build always failed

Your cargo fetch command in prepare is not the same as in wiki, you are also no longer using git submodules .

Because the upstream project does not contain the cargo.lock file, an error will be reported if  following the wiki command, so replace it with this command. This project also does not contain submodules.

Please link to the upstream build instructions you follow .

The upstream requires the use of the

make build

to build,

the makefile is as follows

.PHONY: build

all: build

build:
	make init-cargo && \
	cargo build -r --target x86_64-unknown-linux-musl && \
    cargo build -r --target x86_64-apple-darwin && \
    cargo build -r --target x86_64-pc-windows-gnu && \
    cargo build -r --target aarch64-unknown-linux-gnu && \
    make migrate

init-cargo:
	mkdir .cargo && cp cargo_config.toml .cargo/config.toml

migrate-mac:
	cp target/x86_64-apple-darwin/release/iptv-checker-rs ./iptv-checker-rs-x86_64-apple-darwin

migrate-win:
	cp target/x86_64-pc-windows-gnu/release/iptv-checker-rs.exe ./iptv-checker-rs-x86_64-pc-windows-gnu.exe

migrate-linux:
	cp target/x86_64-unknown-linux-musl/release/iptv-checker-rs ./iptv-checker-rs-x86_64-unknown-linux-musl

migrate-linux-arm:
	cp target/aarch64-unknown-linux-gnu/release/iptv-checker-rs ./iptv-checker-rs-aarch64-unknown-linux-gnu

migrate:
	make migrate-mac && make migrate-win && make migrate-linux && make migrate-linux-arm

And the following is cargo_config.toml

[target.x86_64-unknown-linux-musl]
linker = "x86_64-linux-musl-gcc"

[target.x86_64-pc-windows-gnu]
linker = "x86_64-w64-mingw32-gcc"
ar = "x86_64-w64-mingw32-gcc-ar"

[target.x86_64-apple-darwin]
linker = "rust-lld"

Of course, pkgbuild here does not need to use musl instead of gnu

And in the "Cargo.toml", the openssl dependency as following

[dependencies]
...
openssl = { version = "0.10.61", features = ["vendored"] }
...

The "vendored" feature tells the openssl crate to bundle and compile the OpenSSL source code during the build process, instead of relying on the OpenSSL library installed on the system.

Last edited by gao66 (2024-11-20 12:30:07)

Offline

#6 2024-11-21 09:37:08

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

Re: PKGBUILD Issue: build always failed

And in the "Cargo.toml", the openssl dependency as following

[dependencies]
...
openssl = { version = "0.10.61", features = ["vendored"] }
...

The "vendored" feature tells the openssl crate to bundle and compile the OpenSSL source code during the build process, instead of relying on the OpenSSL library installed on the system.

https://docs.rs/openssl/latest/openssl/ indicates those are bindings to allow rust to use OpenSSL libraries.

Try changing the version to 0.10  instead of 0.10.61 .

Last edited by Lone_Wolf (2024-11-21 09:37:48)


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

#7 2024-11-21 14:00:39

gao66
Member
Registered: 2024-11-20
Posts: 4

Re: PKGBUILD Issue: build always failed

Lone_Wolf wrote:

Try changing the version to 0.10  instead of 0.10.61 .

This is the same error, the error message is a link error

...
          /usr/bin/ld: /home/john/git/aur/iptv-checker-rs-test/src/iptv-checker-rs/target/release/deps/libopenssl_sys-89321b7f8ed59aad.rlib(openssl_sys-89321b7f8ed59aad.openssl_sys.710465a3274dafef-cgu.0.rcgu.o): in function `openssl_sys::openssl::ssl::SSL_CTX_set_max_proto_version':
          /home/john/.cargo/registry/src/index.crates.io-6f17d22bba15001f/openssl-sys-0.9.104/src/./ssl.rs:468:(.text._ZN11openssl_sys7openssl3ssl29SSL_CTX_set_max_proto_version17hcb326ccf4a2ca007E+0x11): undefined reference to `SSL_CTX_ctrl'
          /usr/bin/ld: /home/john/git/aur/iptv-checker-rs-test/src/iptv-checker-rs/target/release/deps/iptv_checker_rs-d37e696246cab059: hidden symbol `OPENSSL_cpuid_setup' isn't defined
          /usr/bin/ld: final link failed: bad value
          collect2: error: ld returned 1 exit status

And the compilation parameters are the same as those of the successful compilation, except for the three parameters added by makepkg. (Of course I tried to remove the parameters added by makepkg and got the same error)

I get the same error using "devtools" in a chroot environment.

So I'm almost certain it's a makepkg issue.

Although I can remove the "vendored" feature and use the system's openssl, it can compile successfully, but it may affects the functionality of the program.

Last edited by gao66 (2024-11-21 15:34:24)

Offline

#8 2024-11-23 15:04:19

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

Re: PKGBUILD Issue: build always failed

Using the PKGBUILD posted in #3 with extra-x86_64-build from devtools gives this error .

==> Starting prepare()...
error: no matching package named `actix-files` found
location searched: registry `crates-io`
required by package `iptv-checker-rs v4.0.1 (/build/iptv-checker-rs-git/src/iptv-checker-rs)`
As a reminder, you're using offline mode (--offline) which can sometimes cause surprising resolution failures, if this error is too confusing you may wish to retry without the offline flag.

Building the latest release tag (3.2.1) gives the same error .
That suggests actix-files is a missing dependency and upstream code may not be suitable for a systemwide install.


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

Board footer

Powered by FluxBB