Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions packages/rsync/build.ncl
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
let { BuildSpec, Local, OutputBin, OutputData, Source, .. } = import "minimal.ncl" in

let version = "3.4.4" in

let base = import "../base/build.ncl" in
let gcc = import "../gcc/build.ncl" in
let make = import "../make/build.ncl" in
let toolchain = import "../toolchain/build.ncl" in
let glibc = import "../glibc/build.ncl" in
let xxhash = import "../xxhash/build.ncl" in
let openssl = import "../openssl/build.ncl" in
let acl = import "../acl/build.ncl" in
let coreutils = import "../coreutils/build.ncl" in

{
name = "rsync",

build_deps = [
{ file = "build.sh" } | Local,
{
url = "https://github.com/RsyncProject/rsync/releases/download/v%{version}/rsync-%{version}.tar.gz",
sha256 = "bd88cf82fa653da32314fb229136407c5c90f80d1758d8f4b091767877d8fa96",
extract = true,
strip_prefix = "rsync-%{version}",
} | Source,
base,
toolchain,
make,
gcc,
xxhash,
openssl
],

runtime_deps = [
glibc,
acl,
openssl,
coreutils
],

cmd = "./build.sh",
build_args = {
include version,
},

outputs = {
rsync = { glob = "usr/bin/rsync" } | OutputBin,
"rsync-ssl" = { glob = "usr/bin/rsync-ssl" } | OutputBin,
mans = { glob = "usr/share/man/**" } | OutputData,
},

attrs = {
upstream_version = version,
source_provenance = {
category = 'GithubRepo,
owner = "RsyncProject",
repo = "rsync",
},
},
} | BuildSpec
19 changes: 19 additions & 0 deletions packages/rsync/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
set -euo pipefail


export CC=gcc
export CFLAGS="-O3 -pipe -ffile-prefix-map=$(pwd)=/builddir -gno-record-gcc-switches"
export CXXFLAGS="$CFLAGS"
export LDFLAGS="-Wl,--build-id=none"
export ARFLAGS=Drc

# Patch configure.sh to remove the broken expanding here-doc block
sed -i '/^cat >>\$CONFIG_STATUS <<_ACEOF || ac_write_fail=1$/{
N
/\n_ACEOF$/d
}' configure.sh
Comment thread
lrishi marked this conversation as resolved.

./configure

make -j$(nproc) DESTDIR=$OUTPUT_DIR prefix=/usr install
57 changes: 57 additions & 0 deletions packages/xxhash/build.ncl
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
let { BuildSpec, Local, OutputBin, OutputData, OutputLib, Source, .. } = import "minimal.ncl" in

let version = "0.8.3" in

let base = import "../base/build.ncl" in
let gcc = import "../gcc/build.ncl" in
let make = import "../make/build.ncl" in
let toolchain = import "../toolchain/build.ncl" in
let glibc = import "../glibc/build.ncl" in

{
name = "xxhash",

build_deps = [
{ file = "build.sh" } | Local,
{
url = "https://github.com/Cyan4973/xxHash/archive/refs/tags/v%{version}.tar.gz",
sha256 = "aae608dfe8213dfd05d909a57718ef82f30722c392344583d3f39050c7f29a80",
extract = true,
strip_prefix = "xxHash-%{version}",
} | Source,
base,
toolchain,
make,
gcc
],

runtime_deps = [
glibc
],

cmd = "./build.sh",
build_args = {
include version,
},

outputs = {
xxhsum = { glob = "usr/bin/xxhsum" } | OutputBin,
xxh3sum = { glob = "usr/bin/xxh3sum" } | OutputBin,
xxh64sum = { glob = "usr/bin/xxh64sum" } | OutputBin,
xxh32sum = { glob = "usr/bin/xxh32sum" } | OutputBin,
xxh128sum = { glob = "usr/bin/xxh128sum" } | OutputBin,
libs = { glob = "usr/lib/{*.so*,*.a*}" } | OutputLib,
headers = { glob = "usr/include/**" } | OutputData,
pkgconfigs = { glob = "usr/lib/pkgconfig/**" } | OutputData,
mans = { glob = "usr/share/man/**" } | OutputData,
},

attrs = {
upstream_version = version,
source_provenance = {
category = 'GithubRepo,
owner = "Cyan4973",
repo = "xxHash",
},
},
} | BuildSpec
11 changes: 11 additions & 0 deletions packages/xxhash/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
set -euo pipefail


export CC=gcc
export CFLAGS="-O3 -pipe -ffile-prefix-map=$(pwd)=/builddir -gno-record-gcc-switches"
export CXXFLAGS="$CFLAGS"
export LDFLAGS="-Wl,--build-id=none"
Comment thread
lrishi marked this conversation as resolved.
export ARFLAGS=Drc

make -j$(nproc) DESTDIR=$OUTPUT_DIR PREFIX=/usr install
Comment on lines +9 to +11

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/sh
set -eu
curl -fsSL 'https://raw.githubusercontent.com/Cyan4973/xxHash/v0.8.3/Makefile' |
  grep -n -A3 '^libxxhash\.a:'

Repository: gominimal/pkgs

Length of output: 276


🏁 Script executed:

#!/bin/sh
set -eu
printf '--- packages/xxhash/build.sh ---\n'
cat -n packages/xxhash/build.sh
printf '\n--- make documentation for ARFLAGS override ---\n'
make --version 2>/dev/null | head -n 1 || true
make --help 2>/dev/null | sed -n '/override/,+3p' || true
printf '\n--- Make behavior probe with Makefile from raw v0.8.3 ---\n'
tmp="$(mktemp -d)"
cd "$tmp"
printf 'AR = echo-ar\nlibxxhash.a: ARFLAGS = rcs\n\t$(AR) $(ARFLAGS) $@\n\n' > Makefile
export ARFLAGS=Drc
printf '-- with explicit ARFLAGS on make command line --\n'
make -f Makefile ARFLAGS=rcsD
printf '-- without explicit ARFLAGS on make command line --\n'
make -f Makefile

Repository: gominimal/pkgs

Length of output: 243


🏁 Script executed:

#!/bin/sh
set -eu
printf '%s\n' '--- packages/xxhash/build.sh ---'
cat -n packages/xxhash/build.sh
printf '%s\n' ''
printf '%s\n' '--- make documentation for override/directives ---'
make --version 2>/dev/null | head -n 1 || true
make --help 2>/dev/null | sed -n '/override/,+4p' || true
printf '%s\n' ''
printf '%s\n' '--- Make behavior probe with Makefile from raw v0.8.3 ---'
tmp="$(mktemp -d)"
printf '%s\n' 'AR = echo-ar' > "$tmp/Makefile"
printf '%s\n' 'libxxhash.a: ARFLAGS = rcs' >> "$tmp/Makefile"
printf '%s\n' '	$(AR) $(ARFLAGS) $@' >> "$tmp/Makefile"
printf '%s\n' '' >> "$tmp/Makefile"
printf '%s\n' '-- exported ARFLAGS only --'
ARFLAGS=Drc make -f "$tmp/Makefile"
printf '%s\n' '-- explicit ARFLAGS passed to make command line --'
make -f "$tmp/Makefile" ARFLAGS=rcsD
printf '%s\n' '-- patch the target --'
sed -i 's/^libxxhash\.a: ARFLAGS = rcs/libxxhash.a: ARFLAGS = rcsD/' "$tmp/Makefile"
ARFLAGS=Drc make -f "$tmp/Makefile"

Repository: gominimal/pkgs

Length of output: 715


🏁 Script executed:

#!/bin/sh
set -eu
printf '%s\n' '--- upstream targets around archive and install ---'
curl -fsSL 'https://raw.githubusercontent.com/Cyan4973/xxHash/v0.8.3/Makefile' | sed -n '135,185p'
printf '%s\n' ''
printf '%s\n' '--- deterministic archive behavior for GNU ar flags ---'
python3 - <<'PY'
flags = "rcsD"
print("libxxhash.a target ARFLAGS rcs assignment will replace exported ARFLAGS=Drc in GNU make")
print("rcsD preserves the index and adds the --deterministic flag for GNU ar")
print("Drc only would override rcs and replace the current order with deterministic+create+replace, dropping index")
PY

Repository: gominimal/pkgs

Length of output: 1834


Preserve the static archive index while enforcing deterministic archives.

The xxHash v0.8.3 libxxhash.a target assigns ARFLAGS = rcs, so the exported ARFLAGS=Drc is replaced and the archive index is dropped. Pass ARFLAGS=rcsD on the make command line, or patch the archive target, so libxxhash.a keeps its symbol index and uses a deterministic archive.

Proposed fix
-export ARFLAGS=Drc
+export ARFLAGS=rcsD

-make -j$(nproc) DESTDIR=$OUTPUT_DIR PREFIX=/usr install
+make -j"$(nproc)" ARFLAGS="$ARFLAGS" DESTDIR="$OUTPUT_DIR" PREFIX=/usr install
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export ARFLAGS=Drc
make -j$(nproc) DESTDIR=$OUTPUT_DIR PREFIX=/usr install
export ARFLAGS=rcsD
make -j"$(nproc)" ARFLAGS="$ARFLAGS" DESTDIR="$OUTPUT_DIR" PREFIX=/usr install
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/xxhash/build.sh` around lines 9 - 11, Update the make invocation in
the build script to pass ARFLAGS=rcsD explicitly, ensuring libxxhash.a retains
its symbol index while using deterministic archive timestamps; remove or
override the ineffective exported ARFLAGS setting as needed.

Source: Coding guidelines

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Repository files matching build.sh:"
git ls-files 'packages/*/build.sh' | sed -n '1,80p'

echo
echo "packages/xxhash/build.sh:"
if [ -f packages/xxhash/build.sh ]; then
  cat -n packages/xxhash/build.sh
else
  echo "missing packages/xxhash/build.sh"
fi

echo
echo "Build script occurrences of OUTPUT_DIR / DESTDIR:"
rg -n 'OUTPUT_DIR|DESTDIR|PREFIX|make -j|nproc' packages/*/build.sh packages/xxhash/build.sh || true

Repository: gominimal/pkgs

Length of output: 50370


🌐 Web query:

xxHash v0.8.3 Makefile DESTDIR install install_bin install_lib install_inc install_man

💡 Result:

In the xxHash v0.8.3 Makefile, the DESTDIR variable is supported and acts as a standard prefix for installation paths, enabling staged installations (e.g., for package building) [1][2]. The project provides modular install targets, which allow users to selectively install components [3]. The primary install target invokes these individual targets sequentially [4][5]. Key installation targets include: - install_libxxhash.a: Installs the static library (libxxhash.a) to the LIBDIR [4][1]. - install_libxxhash: Installs the shared library (libxxhash.so or equivalent) and its symbolic links to the LIBDIR [4][1]. - install_libxxhash.includes: Installs the header files (xxhash.h, xxh3.h, etc.) to the INCLUDEDIR [4][1]. - install_xxhsum: Installs the xxhsum CLI utility and creates symbolic links for associated commands (xxh32sum, xxh64sum, xxh128sum, xxh3sum) in the BINDIR [4][1]. - install_man: Installs the man pages to the MANDIR [4][1]. - install_libxxhash.pc: Installs the pkg-config file to the PKGCONFIGDIR [4][5]. These targets rely on directory variables such as BINDIR, LIBDIR, INCLUDEDIR, and MANDIR, which default to standard locations (e.g., /usr/local/bin) but can be overridden [1]. Directories are created as needed during the install process using the MAKE_DIR variable [4][6]. To install the entire suite, you can run: make install To install specific components, you can call their respective targets directly, for example: make install_xxhsum DESTDIR=/tmp/staging

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
import subprocess
import tempfile

def exec_sh(script, env=None):
    if env is None:
        env = {"PATH": subprocess.os.environ.get("PATH", "/usr/bin:/bin"), "HOME": subprocess.os.path.expanduser("~")}
    p = subprocess.Popen(['sh', '-e'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env, text=True)
    stdout, stderr = p.communicate(script, timeout=10)
    return p.returncode, stdout.splitlines(), stderr.splitlines()

cases = [
    ("unset", {}),
    ("empty", {"OUTPUT_DIR": ""}),
    ("space", {"OUTPUT_DIR": "/tmp/staging space"}),
    ("glob", {"OUTPUT_DIR": "/tmp/staging-[a-z]"}),
]

for name, env in cases:
    # Minimal shell script that mirrors the script options and the make command argument construction.
    # It uses printf -v so the exact unquoted substitution can be inspected without starting make.
    script = """\
set -euo pipefail
export CC=gcc
export CFLAGS="-O3 -pipe -ffile-prefix-map=$(pwd)=/builddir -gno-record-gcc-switches"
export CXXFLAGS="$CFLAGS"
export LDFLAGS="-Wl,--build-id=none"
export ARFLAGS=Drc
printf -v cmd 'make -j%%s DESTDIR=%s PREFIX=/usr install' "$(nproc)" "%s"
printf '%s\n' "$cmd"
exit 0
"""
    code, stdout, stderr = exec_sh(script, env)
    print(f"\nCASE: {name}")
    if code != 0:
        print("exit", code)
        for line in stderr:
            print(line)
    else:
        print("\n".join(stdout))

print("\nBash shellcheck behavior for double-quote glob expansion would be read-only, but no shellcheck availability check needed.")
PY

Repository: gominimal/pkgs

Length of output: 642


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Check bash printf -v unquoted substitution around spaces/globs:"
bash -c '
set -euo pipefail
prefix=/usr
dest=""
printf -v cmd "make -j%s DESTDIR=%s PREFIX=/usr install" "$(nproc)" "$dest"
printf "cmd=%s\n" "$cmd"
if [ "$dest" = "" ]; then
  printf "empty case: DESTDIR becomes empty\n"
fi
'
bash -c '
set -euo pipefail
prefix=/usr
dest="/tmp/staging space"
printf -v cmd "make -j%s DESTDIR=%s PREFIX=/usr install" "$(nproc)" "$dest"
printf "cmd=%s\n" "$cmd"
if printf "%s" "$cmd" | grep -qF "DESTDIR=/tmp/staging space"; then
  printf "space case: quoted expansion preserves space\n"
fi
'

Repository: gominimal/pkgs

Length of output: 473


Validate and quote $OUTPUT_DIR before staging.

set -euo pipefail does not reject an empty OUTPUT_DIR; DESTDIR=PREFIX=/usr then leaves DESTDIR unset and installs under PREFIX=/usr. Unquoted expansion also breaks paths containing spaces or glob characters. Fail closed and quote both $OUTPUT_DIR and $(nproc).

Proposed fix
+: "${OUTPUT_DIR:?OUTPUT_DIR must be non-empty}"
-make -j$(nproc) DESTDIR=$OUTPUT_DIR PREFIX=/usr install
+make -j"$(nproc)" DESTDIR="$OUTPUT_DIR" PREFIX=/usr install
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
make -j$(nproc) DESTDIR=$OUTPUT_DIR PREFIX=/usr install
: "${OUTPUT_DIR:?OUTPUT_DIR must be non-empty}"
make -j"$(nproc)" DESTDIR="$OUTPUT_DIR" PREFIX=/usr install
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/xxhash/build.sh` at line 11, Update the staging command in build.sh
to validate that OUTPUT_DIR is non-empty before invoking make, then quote the
OUTPUT_DIR expansion and the nproc job-count substitution so empty,
whitespace-containing, or glob-containing paths cannot alter the install
destination.

Source: Coding guidelines