f50f9e8d7e
The problem is building bindgen as part of our single run locks serde to way old versions, and I want to use newer versions. Since Fedora will now again ship a `cbindgen` package, let's also support using it if we find it, saving ourselves the cost of building it. For distros that don't ship it (e.g. CentOS) for CI purposes we build it. For downstream builds that are offline, rather than vendor the cbindgen sources like we do with our main Rust, let's just vendor the `rpmostree-rust.h` file as was suggested in https://bugzilla.redhat.com/show_bug.cgi?id=1608670 Closes: https://github.com/projectatomic/rpm-ostree/issues/1557 Closes: #1573 Approved by: jlebon
62 lines
1.9 KiB
Bash
Executable File
62 lines
1.9 KiB
Bash
Executable File
#!/bin/sh
|
|
set -xeuo pipefail
|
|
|
|
srcdir=$1
|
|
shift
|
|
PKG_VER=$1
|
|
shift
|
|
GITREV=$1
|
|
shift
|
|
|
|
TARFILE=${PKG_VER}.tar
|
|
TARFILE_TMP=$(pwd)/${TARFILE}.tmp
|
|
|
|
test -n "${srcdir}"
|
|
test -n "${PKG_VER}"
|
|
test -n "${GITREV}"
|
|
|
|
TOP=$(git rev-parse --show-toplevel)
|
|
|
|
echo "Archiving ${PKG_VER} at ${GITREV} to ${TARFILE_TMP}"
|
|
(cd ${TOP}; git archive --format=tar --prefix=${PKG_VER}/ ${GITREV}) > ${TARFILE_TMP}
|
|
ls -al ${TARFILE_TMP}
|
|
(cd ${TOP}; git submodule status) | while read line; do
|
|
rev=$(echo ${line} | cut -f 1 -d ' '); path=$(echo ${line} | cut -f 2 -d ' ')
|
|
echo "Archiving ${path} at ${rev}"
|
|
(cd ${srcdir}/${path}; git archive --format=tar --prefix=${PKG_VER}/${path}/ ${rev}) > submodule.tar
|
|
tar -A -f ${TARFILE_TMP} submodule.tar
|
|
rm submodule.tar
|
|
done
|
|
tmpd=${TOP}/.dist-tmp
|
|
trap cleanup EXIT
|
|
function cleanup () {
|
|
if test -f ${tmpd}/.tmp; then
|
|
rm "${tmpd}" -rf
|
|
fi
|
|
}
|
|
# Run it now
|
|
cleanup
|
|
mkdir ${tmpd} && touch ${tmpd}/.tmp
|
|
|
|
(cd ${tmpd}
|
|
mkdir -p .cargo vendor
|
|
cargo vendor -q --sync ${TOP}/rust/Cargo.toml vendor
|
|
cp ${TOP}/rust/Cargo.lock .
|
|
cp ${TOP}/rust/cargo-vendor-config .cargo/config
|
|
# Filter out bundled libcurl from curl-sys; we always want the system libcurl
|
|
rm -rf vendor/curl-sys/curl/
|
|
python -c '
|
|
import json, sys; j = json.load(open(sys.argv[1]))
|
|
j["files"] = {f:c for f, c in j["files"].items() if not f.startswith("curl/")}
|
|
open(sys.argv[1], "w").write(json.dumps(j))' vendor/curl-sys/.cargo-checksum.json
|
|
tar --transform="s,^,${PKG_VER}/rust/," -rf ${TARFILE_TMP} * .cargo/
|
|
)
|
|
|
|
# And finally, vendor rpmostree-rust.h; it's generated by cbindgen,
|
|
# and it's easier than vendoring all of the source for that too.
|
|
# This is currently the *only* generated file we treat this way. See also
|
|
# https://github.com/projectatomic/rpm-ostree/pull/1573
|
|
(cd ${srcdir} && tar --transform "s,^,${PKG_VER}/," -rf ${TARFILE_TMP} rpmostree-rust.h)
|
|
|
|
mv ${TARFILE_TMP} ${TARFILE}
|