forked from openRuyi/rust-rpm-macros
41 lines
1.5 KiB
Plaintext
41 lines
1.5 KiB
Plaintext
# Dynamic specpart generator for rust feature metapackage %files (build phase)
|
|
%rustcrates_gen_feature_specparts() %{expand:\
|
|
if [ ! -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 ; \
|
|
specpart="$RPM_SPECPARTS_DIR/50-feature-files.specpart" ; \
|
|
: > "$specpart" ; \
|
|
set -- %{_sourcedir}/*.spec ; \
|
|
spec_self="$1" ; \
|
|
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" || \
|
|
echo "warning: no feature subpackages parsed from $spec_self" >&2 ; \
|
|
}
|
|
|
|
# Example buildsystem for rust crates
|
|
%buildsystem_rustcrates_prep() %{expand:\
|
|
%autosetup -C -p1 %* \
|
|
}
|
|
%buildsystem_rustcrates_conf() %nil
|
|
%buildsystem_rustcrates_build() %{expand:\
|
|
%rustcrates_gen_feature_specparts \
|
|
}
|
|
%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
|