forked from openRuyi/rust-rpm-macros
8
Makefile
Normal file
8
Makefile
Normal file
@@ -0,0 +1,8 @@
|
||||
PREFIX ?= /usr
|
||||
RPMMACRODIR ?= $(PREFIX)/lib/rpm/macros.d
|
||||
RPMSCRIPTDIR ?= $(PREFIX)/lib/rpm/rust-rpm-macros
|
||||
|
||||
.PHONY: install
|
||||
install:
|
||||
install -D -m644 macros.buildsystem.rustcrates $(DESTDIR)$(RPMMACRODIR)/macros.buildsystem.rustcrates
|
||||
install -D -m755 rustcrates-gen-feature-specparts.sh $(DESTDIR)$(RPMSCRIPTDIR)/rustcrates-gen-feature-specparts.sh
|
||||
@@ -1,13 +1,17 @@
|
||||
%rustcrates_dynspec_helper %{_rpmconfigdir}/rust-rpm-macros/rustcrates-gen-feature-specparts.sh
|
||||
|
||||
# Example buildsystem for rust crates
|
||||
%buildsystem_rustcrates_prep() %{expand:\\\
|
||||
%autosetup -C -p1 %* \\\
|
||||
%buildsystem_rustcrates_prep() %{expand:\
|
||||
%autosetup -C -p1 %* \
|
||||
}
|
||||
%buildsystem_rustcrates_conf() %nil
|
||||
%buildsystem_rustcrates_build() %nil
|
||||
%buildsystem_rustcrates_install() %{expand:\\\
|
||||
%__install -d %{buildroot}%{_datadir}/cargo/registry/%{crate_name}-%{version} ; \\\
|
||||
%__cp -a . %{buildroot}%{_datadir}/cargo/registry/%{crate_name}-%{version}/ ; \\\
|
||||
%__rm -f %{buildroot}%{_datadir}/cargo/registry/%{crate_name}-%{version}/*checksum.json ; \\\
|
||||
echo '{"files":{},"package":null}' > %{buildroot}%{_datadir}/cargo/registry/%{crate_name}-%{version}/.cargo-checksum.json \\\
|
||||
%buildsystem_rustcrates_build() %{expand:\
|
||||
%{rustcrates_dynspec_helper} "%{_sourcedir}" \
|
||||
}
|
||||
%buildsystem_rustcrates_check() %nil
|
||||
%buildsystem_rustcrates_install() %{expand:\
|
||||
%__install -d %{buildroot}%{_datadir}/cargo/registry/%{crate_name}-%{version} ; \
|
||||
%__cp -a . %{buildroot}%{_datadir}/cargo/registry/%{crate_name}-%{version}/ ; \
|
||||
%__rm -f %{buildroot}%{_datadir}/cargo/registry/%{crate_name}-%{version}/*checksum.json ; \
|
||||
echo '{"files":{},"package":null}' > %{buildroot}%{_datadir}/cargo/registry/%{crate_name}-%{version}/.cargo-checksum.json \
|
||||
}
|
||||
%buildsystem_rustcrates_check() %nil
|
||||
|
||||
40
rustcrates-gen-feature-specparts.sh
Normal file
40
rustcrates-gen-feature-specparts.sh
Normal file
@@ -0,0 +1,40 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SOURCEDIR="${1:-}"
|
||||
if [[ -z "$SOURCEDIR" ]]; then
|
||||
echo "usage: $0 SOURCEDIR" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [[ -z "${RPM_SPECPARTS_DIR:-}" || ! -d "$RPM_SPECPARTS_DIR" ]]; then
|
||||
echo "error: dynamic spec generation is not supported by this RPM version (missing RPM_SPECPARTS_DIR)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
set -- "$SOURCEDIR"/*.spec
|
||||
SPEC_SELF="$1"
|
||||
SPECPART="$RPM_SPECPARTS_DIR/50-feature-files.specpart"
|
||||
|
||||
: > "$SPECPART"
|
||||
|
||||
if [[ ! -f "$SPEC_SELF" ]]; then
|
||||
echo "warning: no spec file found in $SOURCEDIR" >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! awk '
|
||||
/^[[:space:]]*%package[[:space:]]+/ {
|
||||
if (match($0, /-n[[:space:]]+%\{name\}\+([A-Za-z0-9_.-]+)/, m) && !seen[m[1]]++) {
|
||||
print "%files -n %{name}+" m[1]
|
||||
print ""
|
||||
found = 1
|
||||
}
|
||||
}
|
||||
END {
|
||||
exit(found ? 0 : 2)
|
||||
}
|
||||
' "$SPEC_SELF" > "$SPECPART"; then
|
||||
echo "warning: no feature subpackages parsed from $SPEC_SELF" >&2
|
||||
fi
|
||||
Reference in New Issue
Block a user