| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
import hashlib, sys, tomllib |
| 6 |
|
| 7 |
lock_path, version, archive = sys.argv[1], sys.argv[2], sys.argv[3] |
| 8 |
lock = tomllib.load(open(lock_path, "rb")) |
| 9 |
crates = sorted((p["name"], p["version"], p["checksum"]) for p in lock["package"] if p.get("source", "").startswith("registry+")) |
| 10 |
sha = hashlib.sha256(open(archive, "rb").read()).hexdigest() |
| 11 |
|
| 12 |
out = [] |
| 13 |
w = out.append |
| 14 |
w('SUMMARY="A version control system of signed, commuting changes, with Git interop"') |
| 15 |
w('DESCRIPTION="oxy is the command line of Oxygen, a version control system built on \\') |
| 16 |
w('patch theory: changes commute, conflicts are recorded rather than blocking, \\') |
| 17 |
w('every change can be signed, and a trust policy says who may move what. It \\') |
| 18 |
w('imports and exports Git history, clones from OxygenHub and other Oxygen \\') |
| 19 |
w('hosts, and keeps repositories on disk or in S3, GCS or Azure buckets."') |
| 20 |
w('HOMEPAGE="https://oxygenhub.io/andymccall/oxygen"') |
| 21 |
w('COPYRIGHT="2025-2026 Andy McCall"') |
| 22 |
w('LICENSE="MIT\n\tApache v2"') |
| 23 |
w('REVISION="1"') |
| 24 |
w(f'SOURCE_URI="$HOMEPAGE/archive?ref=v$portVersion&format=tar.zst"') |
| 25 |
w(f'SOURCE_FILENAME="oxygen-v$portVersion.tar.zst"') |
| 26 |
w(f'CHECKSUM_SHA256="{sha}"') |
| 27 |
w('SOURCE_DIR="oxygen-v$portVersion"') |
| 28 |
for i, (name, ver, ck) in enumerate(crates, start=2): |
| 29 |
w(f'SOURCE_URI_{i}="https://static.crates.io/crates/{name}/{name}-{ver}.crate"') |
| 30 |
w(f'CHECKSUM_SHA256_{i}="{ck}"') |
| 31 |
w(f'SOURCE_FILENAME_{i}="{name}-{ver}.tar.gz"') |
| 32 |
last = len(crates) + 1 |
| 33 |
w(''' |
| 34 |
ARCHITECTURES="!x86_gcc2 ?x86 x86_64" |
| 35 |
SECONDARY_ARCHITECTURES="x86" |
| 36 |
|
| 37 |
PROVIDES=" |
| 38 |
oxy$secondaryArchSuffix = $portVersion |
| 39 |
cmd:oxy |
| 40 |
" |
| 41 |
REQUIRES=" |
| 42 |
haiku$secondaryArchSuffix |
| 43 |
lib:libzstd$secondaryArchSuffix |
| 44 |
" |
| 45 |
|
| 46 |
BUILD_REQUIRES=" |
| 47 |
haiku${secondaryArchSuffix}_devel |
| 48 |
devel:libzstd$secondaryArchSuffix |
| 49 |
" |
| 50 |
BUILD_PREREQUIRES=" |
| 51 |
cmd:gcc$secondaryArchSuffix |
| 52 |
cmd:pkg_config$secondaryArchSuffix |
| 53 |
cmd:rustc$secondaryArchSuffix >= 1.88 |
| 54 |
" |
| 55 |
|
| 56 |
BUILD() |
| 57 |
{ |
| 58 |
export CARGO_HOME=$sourceDir/../cargo |
| 59 |
vendor=$CARGO_HOME/haiku |
| 60 |
mkdir -p "$vendor" |
| 61 |
for i in $(seq 2 ''' + str(last) + '''); do |
| 62 |
eval "srcDir=\\$sourceDir$i" |
| 63 |
eval "sha256sum=\\$CHECKSUM_SHA256_$i" |
| 64 |
set -- "$srcDir"/* |
| 65 |
ln -sf "$1" "$vendor" |
| 66 |
cat <<-EOF >"$vendor/${1##*/}/.cargo-checksum.json" |
| 67 |
{ |
| 68 |
"package": "$sha256sum", |
| 69 |
"files": {} |
| 70 |
} |
| 71 |
EOF |
| 72 |
done |
| 73 |
|
| 74 |
cat <<-EOF >"$CARGO_HOME"/config.toml |
| 75 |
[source.haiku] |
| 76 |
directory = "$vendor" |
| 77 |
|
| 78 |
[source.crates-io] |
| 79 |
replace-with = "haiku" |
| 80 |
EOF |
| 81 |
|
| 82 |
# The bundled zstd's hidden symbols break the link on Haiku: use the system's. |
| 83 |
export ZSTD_SYS_USE_PKG_CONFIG=1 |
| 84 |
export OXY_BUILD=v$portVersion |
| 85 |
cargo build --release --frozen -p oxy |
| 86 |
} |
| 87 |
|
| 88 |
INSTALL() |
| 89 |
{ |
| 90 |
install -v -m 755 -d "$prefix"/bin "$docDir" |
| 91 |
install -v -m 755 ./target/release/oxy "$prefix"/bin |
| 92 |
install -v -m 644 README.md LICENSE* "$docDir" |
| 93 |
} |
| 94 |
|
| 95 |
TEST() |
| 96 |
{ |
| 97 |
export CARGO_HOME=$sourceDir/../cargo |
| 98 |
export ZSTD_SYS_USE_PKG_CONFIG=1 |
| 99 |
cargo test --release --frozen -p oxy-core |
| 100 |
}''') |
| 101 |
print("\n".join(out)) |