-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
macros.anda
25 lines (24 loc) · 988 Bytes
/
macros.anda
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# by default, add a bcond_without for a mold linker
# https://rpm-software-management.github.io/rpm/manual/conditionalbuilds.html
# only enable this on fedora
%with_mold 0%{?fedora:1}
# git_clone [<repo_url>] [<ref>]
%git_clone() %{lua:
local url = rpm.expand("%?1%{!?1:%url}")
if (url == '%url') or (url == '') then
error("%url is not defined")
end
local ref = rpm.expand("%?2%{!?2:%?commit%{!?commit:%version}}")
if (ref == '%version') or (branch == '') then
error("%version is not defined")
end
local command = 'git clone --recurse-submodules -q -j$(nproc) ' .. url
if (ref:len() == 40 or ref:len() == 7) and not(ref:find("%X")) then
command = command .. ' && git checkout -q ' .. ref
else
command = command .. ' --depth 1 -b ' .. ref
end
-- BUG: rpm.define() takes only 1 arg…???
rpm.define("buildsubdir " .. ((url:gsub("/(%.git)?$", "")):gsub("^.+/", "")))
print(command .. " && cd " .. ((url:gsub("/(%.git)?$", "")):gsub("^.+/", "")))
}