You are not logged in.

#1 2025-01-24 18:16:43

Neurofibromin
Member
Registered: 2023-12-16
Posts: 6

[solved] binary gets smaller when package()-d

I'm trying to package my dotnet program. The build part works fine, but package somehow takes the wrong binary? I'm not sure how it happens, but instead of 24MB it is 72kB and obviously does not work.

build() {
    cd "${srcdir}/${_sourceName}" 
    MSBUILDDISABLENODEREUSE=1 dotnet publish bookmark-dlp/bookmark-dlp.csproj \
    --configuration Release \
    --no-self-contained \
    --runtime linux-x64 \
    --framework net${_dotnet_version} \
    -p:PublishSingleFile=true
}

package() {
    echo "pkgdir: $pkgdir"
    echo "srcdir: $srcdir"
    echo "pkgname: $pkgname"
    echo "_sourceName: ${_sourceName}"
    # Ensure the directories exist
    install -d "$pkgdir/usr/bin"
    install -d "$pkgdir/usr/lib"
    # Copy the package files to the appropriate directory
    cp -r "${srcdir}/bookmark-dlp/bookmark-dlp/bin/Release/net8.0/linux-x64/publish/" "$pkgdir/usr/lib/"
    # Create the symbolic link
    ln -s "/usr/lib/$pkgname/${_sourceName}" "$pkgdir/usr/bin/$pkgname"
}

After running makepkg the

${srcdir}/bookmark-dlp/bookmark-dlp/bin/Release/net8.0/linux-x64/publish

directory contains 4 files, and the binary is the good one, but in $pkgdir/usr/lib/ there are 4 files and the binary is the wrong one.

repo has the PKGBUILD as well as all the source. When testing I just put the PKGBUILD in an empty dir and run makepkg. namcap suggested nothing regarding this issue.
Thanks for the help!

Last edited by Neurofibromin (2025-01-24 18:35:10)

Offline

#2 2025-01-24 18:22:32

WorMzy
Administrator
From: Scotland
Registered: 2010-06-16
Posts: 12,583
Website

Re: [solved] binary gets smaller when package()-d

Please post the full PKGBUILD and makepkg output.

https://bbs.archlinux.org/viewtopic.php?id=57855

My guess is you need to disable the strip option for your package (see `man PKGBUILD | less -p "options \(array\)"`)


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#3 2025-01-24 18:22:32

mackin_cheese
Member
Registered: 2025-01-07
Posts: 171

Re: [solved] binary gets smaller when package()-d

we can't help you much if you don't post the whole pkgbuild.

Offline

#4 2025-01-24 18:25:33

Neurofibromin
Member
Registered: 2023-12-16
Posts: 6

Re: [solved] binary gets smaller when package()-d

The whole packagebuild:

# Maintainer: Neurofibromin <125222560+Neurofibromin@users.noreply.github.com>
# Contributor: Neurofibromin <125222560+Neurofibromin@users.noreply.github.com>
_tag=0.4.0
_sourceName="bookmark-dlp"
_dotnet_version=8.0

pkgname="bookmark-dlp-git"
pkgver=0.4.0
pkgrel=1
pkgdesc="Small utility program for downloading bookmarked YouTube links using yt-dlp."
arch=("x86_64")
url="https://github.com/Neurofibromin/bookmark-dlp"
license=('GPL-3.0-only')
depends=(
    "dotnet-runtime-$_dotnet_version" 
    gcc-libs
    glibc
)
makedepends=(
    git
    "dotnet-sdk-$_dotnet_version"
)
optdepends=()
options=(staticlibs)
source=("git+${url}.git#tag=${_tag}?signed")
md5sums=("SKIP")
validpgpkeys=('9F9BFE94618AD26667BD28214F671AFAD8D4428B')

pkgver() {
  cd "${_sourceName}"
  # git describe --tags --match "[0-9]*.[0-9]*.[0-9]*"
  git tag --list '[0-9]*.[0-9]*.[0-9]*' | sort -V | tail -n 1
}

prepare() {
  cd "${srcdir}/${_sourceName}"
  export NUGET_PACKAGES="$PWD/nuget"
  export DOTNET_NOLOGO=true
  export DOTNET_CLI_TELEMETRY_OPTOUT=true
  dotnet restore --locked-mode bookmark-dlp.sln
  git remote set-url origin "$url"
}

build() {
    cd "${srcdir}/${_sourceName}" 
    MSBUILDDISABLENODEREUSE=1 dotnet publish bookmark-dlp/bookmark-dlp.csproj \
    --configuration Release \
    --no-self-contained \
    --runtime linux-x64 \
    --framework net${_dotnet_version} \
    -p:PublishSingleFile=true
    # --output "${srcdir}/${pkgname}"
    # cd "$pkgname"
    # export NUGET_PACKAGES="$PWD/nuget"
    # export DOTNET_NOLOGO=true
    # export DOTNET_CLI_TELEMETRY_OPTOUT=true
    # dotnet publish \
    # --no-restore \
    # --framework "net$_dotnet_version" \
    # --runtime linux-x64 \
    # --no-self-contained \
    # --configuration release \
    # --output lib \
    # src/Some.Program.Cli
}

check() {
  cd "${srcdir}/${_sourceName}"
  ls
  export NUGET_PACKAGES="$PWD/nuget"
  export DOTNET_NOLOGO=true
  export DOTNET_CLI_TELEMETRY_OPTOUT=true
  dotnet test ./Tests/bookmark-dlp.Tests/ \
    --no-restore \
    --framework "net$_dotnet_version"
}

package() {
    echo "pkgdir: $pkgdir"
    echo "srcdir: $srcdir"
    echo "pkgname: $pkgname"
    echo "_sourceName: ${_sourceName}"
    # Ensure the directories exist
    install -d "$pkgdir/usr/bin"
    install -d "$pkgdir/usr/lib"
    # Copy the package files to the appropriate directory
    cp -r "${srcdir}/bookmark-dlp/bookmark-dlp/bin/Release/net8.0/linux-x64/publish/" "$pkgdir/usr/lib/"
    # Create the symbolic link
    ln -s "/usr/lib/$pkgname/${_sourceName}" "$pkgdir/usr/bin/$pkgname"         
    # cd "$pkgname"
    # local pkgnum=${pkgver:0:1}
    # install -dm755 "$pkgdir/usr/lib/$pkgname-$pkgnum"
    # cp --archive -t "$pkgdir/usr/lib/$pkgname-$pkgnum" lib/*
    # install -dm755 "$pkgdir/usr/bin"
    # ln -s "/usr/lib/$pkgname-$pkgnum/$pkgname" "$pkgdir/usr/bin/$pkgname"
}

Offline

#5 2025-01-24 18:29:35

Neurofibromin
Member
Registered: 2023-12-16
Posts: 6

Re: [solved] binary gets smaller when package()-d

makepkg output:
makepkg > logs.txt

Last edited by Neurofibromin (2025-01-24 18:35:50)

Offline

#6 2025-01-24 18:34:36

Neurofibromin
Member
Registered: 2023-12-16
Posts: 6

Re: [solved] binary gets smaller when package()-d

WorMzy wrote:

Please post the full PKGBUILD and makepkg output.

https://bbs.archlinux.org/viewtopic.php?id=57855

My guess is you need to disable the strip option for your package (see `man PKGBUILD | less -p "options \(array\)"`)

that worked, thanks

Offline

Board footer

Powered by FluxBB