From 09f08705dcccee689fc1b364ba9989e2a3fc0b59 Mon Sep 17 00:00:00 2001 From: madomado Date: Sat, 17 Aug 2024 02:52:22 +0800 Subject: [PATCH] feat(srpm-macros): move sources outside of this repo (#1905) (cherry picked from commit f179d855bf648fca376d06a2be9df900530edf40) --- anda/terra/srpm-macros/anda-srpm-macros.spec | 26 ++--- anda/terra/srpm-macros/macros.anda | 17 --- anda/terra/srpm-macros/macros.caching | 45 -------- anda/terra/srpm-macros/macros.cargo_extra | 115 ------------------- anda/terra/srpm-macros/macros.go_extra | 6 - anda/terra/srpm-macros/macros.nim_extra | 5 - anda/terra/srpm-macros/update.rhai | 1 + 7 files changed, 13 insertions(+), 202 deletions(-) delete mode 100644 anda/terra/srpm-macros/macros.anda delete mode 100644 anda/terra/srpm-macros/macros.caching delete mode 100644 anda/terra/srpm-macros/macros.cargo_extra delete mode 100644 anda/terra/srpm-macros/macros.go_extra delete mode 100644 anda/terra/srpm-macros/macros.nim_extra create mode 100644 anda/terra/srpm-macros/update.rhai diff --git a/anda/terra/srpm-macros/anda-srpm-macros.spec b/anda/terra/srpm-macros/anda-srpm-macros.spec index c5f338c01c..62a8ee3158 100644 --- a/anda/terra/srpm-macros/anda-srpm-macros.spec +++ b/anda/terra/srpm-macros/anda-srpm-macros.spec @@ -1,15 +1,11 @@ Name: anda-srpm-macros Version: 0.1.7 -Release: 1%{?dist} +Release: 2%{?dist} Summary: SRPM macros for extra Fedora packages License: MIT -# URL: -Source0: macros.cargo_extra -Source1: macros.caching -Source2: macros.anda -Source3: macros.go_extra -Source4: macros.nim_extra +URL: https://github.com/terrapkg/srpm-macros +Source0: %url/archive/refs/tags/v%{version}.tar.gz Recommends: rust-packaging Requires: git-core @@ -21,25 +17,27 @@ BuildArch: noarch %{summary} %prep +%autosetup -n srpm-macros-%version %build %install -install -D -p -m 0644 -t %{buildroot}%{_rpmmacrodir} %{SOURCE0} -install -D -p -m 0644 -t %{buildroot}%{_rpmmacrodir} %{SOURCE1} -install -D -p -m 0644 -t %{buildroot}%{_rpmmacrodir} %{SOURCE2} -install -D -p -m 0644 -t %{buildroot}%{_rpmmacrodir} %{SOURCE3} -install -D -p -m 0644 -t %{buildroot}%{_rpmmacrodir} %{SOURCE4} +for file in ./macros.*; do + install -Dpm644 -t %buildroot%_rpmmacrodir $file +done %files -%{_rpmmacrodir}/macros.cargo_extra -%{_rpmmacrodir}/macros.caching %{_rpmmacrodir}/macros.anda +%{_rpmmacrodir}/macros.caching +%{_rpmmacrodir}/macros.cargo_extra %{_rpmmacrodir}/macros.go_extra %{_rpmmacrodir}/macros.nim_extra %changelog +* Wed Aug 14 2024 madonuko - 0.1.7-2 +- Move sources outside of packages repo + * Wed Mar 13 2024 madonuko - 0.1.6-1 - Add nim_c, nim_tflags and nim_lflags diff --git a/anda/terra/srpm-macros/macros.anda b/anda/terra/srpm-macros/macros.anda deleted file mode 100644 index 62a6ba908e..0000000000 --- a/anda/terra/srpm-macros/macros.anda +++ /dev/null @@ -1,17 +0,0 @@ -%git_clone(Rc) %{lua: - local dir = rpm.expand("%{_builddir}/%{name}-%{version}") - -- if dir exists, remove it - os.execute("rm -rf " .. dir) - os.execute(rpm.expand("%{__git} clone %{-R:--recursive} %{1} " .. dir)) - posix.chdir(dir) - if rpm.expand("-c") ~= "" then - os.execute(rpm.expand("%{__git} checkout %{2}")) - end - - -- tarball the folder - local tarball = rpm.expand("%{_sourcedir}/%{name}-%{version}.tar.gz") - os.execute("tar -C ".. dir .. "/../ " .. " -czvf " .. tarball .. " " .. rpm.expand("%{name}-%{version}")) - - - print(rpm.expand("%{name}-%{version}.tar.gz")) - } \ No newline at end of file diff --git a/anda/terra/srpm-macros/macros.caching b/anda/terra/srpm-macros/macros.caching deleted file mode 100644 index 2b9bbbd375..0000000000 --- a/anda/terra/srpm-macros/macros.caching +++ /dev/null @@ -1,45 +0,0 @@ - - -%_sccache %{_bindir}/sccache - -%sccache_prep (\ -export CC="%{_sccache} $CC" \ -export CXX="%{_sccache} $CXX" \ -export RUSTC_WRAPPER="sccache" \ -\ -export SCCACHE_BUCKET=%{?sccache_bucket}\ -export SCCACHE_ENDPOINT=%{?sccache_endpoint}\ -export AWS_SECRET_ACCESS_KEY=%{?sccache_secret}\ -export AWS_ACCESS_KEY_ID=%{?sccache_accesskey}\ -export SCCACHE_S3_USE_SSL=true\ -) - -%cargo_prep_online_sccache (\ -set -eu \ -%{__mkdir} -p .cargo \ -cat > .cargo/config << EOF \ -[build]\ -rustc = "%{__rustc}"\ -rustc-wrapper = "%{_sccache}"\ -rustdoc = "%{__rustdoc}"\ -\ -[env]\ -CFLAGS = "%{build_cflags}"\ -CXXFLAGS = "%{build_cxxflags}"\ -LDFLAGS = "%{build_ldflags}"\ -\ -[install]\ -root = "%{buildroot}%{_prefix}"\ -\ -[term]\ -verbose = true\ -\ -[source]\ -\ -[source.local-registry]\ -directory = "%{cargo_registry}"\ -\ -EOF\ -%{__rm} -f Cargo.lock \ -%{__rm} -f Cargo.toml.orig \ -) \ No newline at end of file diff --git a/anda/terra/srpm-macros/macros.cargo_extra b/anda/terra/srpm-macros/macros.cargo_extra deleted file mode 100644 index de6d21fc76..0000000000 --- a/anda/terra/srpm-macros/macros.cargo_extra +++ /dev/null @@ -1,115 +0,0 @@ -%cargo_prep_online (\ -set -eu \ -%{__mkdir} -p .cargo \ -cat > .cargo/config << EOF \ -[profile.rpm]\ -inherits = "release"\ -opt-level = 3\ -codegen-units = 1\ -debug = 2\ -strip = "none"\ -\ -[build]\ -rustc = "%{__rustc}"\ -rustdoc = "%{__rustdoc}"\ -\ -[env]\ -CFLAGS = "%{build_cflags}"\ -CXXFLAGS = "%{build_cxxflags}"\ -LDFLAGS = "%{build_ldflags}"\ -\ -[install]\ -root = "%{buildroot}%{_prefix}"\ -\ -[term]\ -verbose = true\ -\ -[source]\ -\ -[source.local-registry]\ -directory = "%{cargo_registry}"\ -\ -EOF\ -%{__rm} -f Cargo.toml.orig \ -) - - - -# cargo_license: print license information for all crate dependencies -# -# The "no-build,no-dev,no-proc-macro" argument results in only crates which are -# linked into the final binary to be considered. -# -# Additionally, deprecated SPDX syntax ("/" instead of "OR") is normalized -# before sorting the results to ensure reproducible output of this macro. -# -# This macro must be called with the same feature flags as other cargo macros, -# in particular, "cargo_build", otherwise its output will be incomplete. -# -# The "cargo tree" command called by this macro will fail if there are missing -# (optional) dependencies. -%cargo_license_online(naf:)\ -(\ -set -euo pipefail\ -%{shrink: \ - %{__cargo} tree \ - -Z avoid-dev-deps \ - --workspace \ - --edges no-build,no-dev,no-proc-macro \ - --no-dedupe \ - --target all \ - %{__cargo_parse_opts %{-n} %{-a} %{-f:-f%{-f*}}} \ - --prefix none \ - --format "{l}: {p}" \ - | sed -e "s: ($(pwd)[^)]*)::g" -e "s: / :/:g" -e "s:/: OR :g" \ - | sort -u \ -}\ -) - -# cargo_license_summary: print license summary for all crate dependencies -# -# This macro works in the same way as cargo_license, except that it only prints -# a list of licenses, and not the complete license information for every crate -# in the dependency tree. This is useful for determining the correct License -# tag for packages that contain compiled Rust binaries. -%cargo_license_summary_online(naf:)\ -(\ -set -euo pipefail\ -%{shrink: \ - %{__cargo} tree \ - -Z avoid-dev-deps \ - --workspace \ - --edges no-build,no-dev,no-proc-macro \ - --no-dedupe \ - --target all \ - %{__cargo_parse_opts %{-n} %{-a} %{-f:-f%{-f*}}} \ - --prefix none \ - --format "# {l}" \ - | sed -e "s: / :/:g" -e "s:/: OR :g" \ - | sort -u \ -}\ -) - -# cargo_vendor_manifest: write list of vendored crates and their versions -# -# The arguments for the internal "cargo tree" call emulate the logic -# that determines which crates are included when running "cargo vendor". -# The results are written to "cargo-vendor.txt". -%cargo_vendor_manifest_online()\ -(\ -set -euo pipefail\ -%{shrink: \ - %{__cargo} tree \ - --workspace \ - --edges normal,build,dev \ - --no-dedupe \ - --target all \ - --all-features \ - --prefix none \ - --format "{p}" \ - | grep -v "$(pwd)" \ - | sed -e "s: (proc-macro)::" \ - | sort -u \ - > cargo-vendor.txt \ -}\ -) diff --git a/anda/terra/srpm-macros/macros.go_extra b/anda/terra/srpm-macros/macros.go_extra deleted file mode 100644 index c873627f08..0000000000 --- a/anda/terra/srpm-macros/macros.go_extra +++ /dev/null @@ -1,6 +0,0 @@ -%go_prep_online() (cd %{?1}%{!?1:.} && go mod download) - -%go_build_online() mkdir -p build/bin && \ - go build -ldflags "-B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \n') -s -w" -buildmode=pie \ - -o %{?2}%{!?2:build/bin/%{?1}%{!?1:%name}} \ - %{?1}%{!?1:.} diff --git a/anda/terra/srpm-macros/macros.nim_extra b/anda/terra/srpm-macros/macros.nim_extra deleted file mode 100644 index 69a43becb7..0000000000 --- a/anda/terra/srpm-macros/macros.nim_extra +++ /dev/null @@ -1,5 +0,0 @@ -%nim_tflags %(echo "%?build_cflags -fPIE" | sed "s/-O2/-Ofast/g" | sed "s/-Wall//g") - -%nim_lflags %?build_ldflags -pie - -%nim_c -d:release -t:"%nim_tflags" -l:"%nim_lflags" diff --git a/anda/terra/srpm-macros/update.rhai b/anda/terra/srpm-macros/update.rhai new file mode 100644 index 0000000000..4edb8f15f6 --- /dev/null +++ b/anda/terra/srpm-macros/update.rhai @@ -0,0 +1 @@ +rpm.version(gh("terrapkg/srpm-macros"));