packaging: Support vendoring the Rust sources
This ends up being different than what landed in librsvg (that was imported into ostree) because in rpm-ostree we've basically been using `git archive`-based tarball generation rather than `make dist` for a long time. And supporting `make dist` looks like it'd get into handling the `libdnf` bits and walking into `cmake` land so...yeah let's not do that. The canonical sources are in git (recursively via submodule), except for the Rust sources, which cargo can download dynamically, and with this patch we support glomming all of that together into a tarball. (And turn off `make dist` so people understand how we do it) Tested by `make -f Makefile.dist-packaging dist-snapshot`, then copying the resulting tarball into a container with `--net=none` and building there. Closes: #1391 Approved by: jlebon
This commit is contained in:
parent
98ed545e1e
commit
7b69294b8a
@ -57,3 +57,12 @@ install-data-hook: $(INSTALL_DATA_HOOKS)
|
||||
|
||||
ALL_LOCAL_HOOKS =
|
||||
all-local: $(ALL_LOCAL_HOOKS)
|
||||
|
||||
CHECK_LOCAL_HOOKS =
|
||||
check-local: $(CHECK_LOCAL_HOOKS)
|
||||
|
||||
CLEAN_LOCAL_HOOKS =
|
||||
clean-local: $(CLEAN_LOCAL_HOOKS)
|
||||
|
||||
DIST_HOOKS =
|
||||
dist-hook: $(DIST_HOOKS)
|
||||
|
25
Makefile.am
25
Makefile.am
@ -67,7 +67,10 @@ include $(INTROSPECTION_MAKEFILE)
|
||||
GIRS =
|
||||
TYPELIBS = $(GIRS:.gir=.typelib)
|
||||
|
||||
# These bits based on gnome:librsvg/Makefile.am
|
||||
# These bits were originally based on gnome:librsvg/Makefile.am
|
||||
# but have been adapted to non-recursive Automake, and additionally
|
||||
# the "cargo vendor" bits for us live in packaging/Makefile.dist-packaging.
|
||||
.PHONY: check-local-cargo clean-local-cargo use-git-not-dist-hook
|
||||
if ENABLE_RUST
|
||||
if RUST_DEBUG
|
||||
CARGO_RELEASE_ARGS=
|
||||
@ -75,24 +78,22 @@ else
|
||||
CARGO_RELEASE_ARGS=--release
|
||||
endif
|
||||
|
||||
.PHONY: check-local-cargo
|
||||
check-local-cargo:
|
||||
cd $(srcdir)/rust && CARGO_TARGET_DIR=$(abs_top_builddir)/target cargo test
|
||||
check-local: check-local-cargo
|
||||
CHECK_LOCAL_HOOKS += check-local-cargo
|
||||
|
||||
.PHONY: clean-local-cargo
|
||||
clean-local-cargo:
|
||||
cd $(srcdir)/rust && CARGO_TARGET_DIR=$(abs_top_builddir)/target cargo clean
|
||||
clean-local: clean-local-cargo
|
||||
CLEAN_LOCAL_HOOKS += clean-local-cargo
|
||||
|
||||
dist-hook:
|
||||
(cd $(distdir)/rust && \
|
||||
cp $(abs_top_srcdir)/rust/Cargo.lock . && \
|
||||
cargo vendor -q && \
|
||||
mkdir .cargo && \
|
||||
cp cargo-vendor-config .cargo/config)
|
||||
use-git-not-dist-hook:
|
||||
@echo
|
||||
@echo 'ERROR: rpm-ostree does not use/support "make dist"; see packaging/Makefile.dist-packaging' 1>&2
|
||||
@echo
|
||||
@exit 1
|
||||
|
||||
DIST_HOOKS += use-git-not-dist-hook
|
||||
|
||||
EXTRA_DIST += $(srcdir)/rust/Cargo.toml $(srcdir)/rust/cargo-vendor-config
|
||||
endif # end ENABLE_RUST
|
||||
|
||||
include libglnx/Makefile-libglnx.am.inc
|
||||
|
@ -8,7 +8,7 @@ GITREV=$1
|
||||
shift
|
||||
|
||||
TARFILE=${PKG_VER}.tar
|
||||
TARFILE_TMP=${TARFILE}.tmp
|
||||
TARFILE_TMP=$(pwd)/${TARFILE}.tmp
|
||||
|
||||
set -x
|
||||
set -e
|
||||
@ -29,4 +29,22 @@ ls -al ${TARFILE_TMP}
|
||||
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
|
||||
tar --transform="s,^,${PKG_VER}/rust/," -rf ${TARFILE_TMP} *
|
||||
)
|
||||
mv ${TARFILE_TMP} ${TARFILE}
|
||||
|
Loading…
Reference in New Issue
Block a user