Blame SOURCES/macros.ansible-srpm

rdobuilder 6b0be9
# Note(gotmax23): I'm trying to get rid of the need for control macros in favor
rdobuilder 6b0be9
# of a metadata based approach. %%ansible_collection_url is the only macro that
rdobuilder 6b0be9
# requires manually specifying the collection namespace and name, as it is used
rdobuilder 6b0be9
# at the SRPM build stage.
rdobuilder 6b0be9
#
rdobuilder 6b0be9
# Currently, this macro supports either passing this information as arguments
rdobuilder 6b0be9
# or defining the control macros. In order to reduce confusion, this is not an
rdobuilder 6b0be9
# either or approach. Both arguments must be passed OR both control macros must
rdobuilder 6b0be9
# be defined.
rdobuilder 6b0be9
rdobuilder 6b0be9
%ansible_collection_url() %{lua:
rdobuilder 6b0be9
    local namespace_name = nil
rdobuilder 6b0be9
    if rpm.expand("%collection_namespace") ~= "%collection_namespace"
rdobuilder 6b0be9
            and rpm.expand("%collection_name") ~= "%collection_name" then
rdobuilder 6b0be9
        namespace_name = rpm.expand("%collection_namespace") .. "/" .. rpm.expand("%collection_name")
rdobuilder 6b0be9
    end
rdobuilder 6b0be9
    if rpm.expand("%1") ~= "%1" and rpm.expand("%2") ~= "%2" then
rdobuilder 6b0be9
        namespace_name = rpm.expand("%1") .. "/" .. rpm.expand("%2")
rdobuilder 6b0be9
    end
rdobuilder 6b0be9
    if not namespace_name then
rdobuilder 6b0be9
        rpm.expand("%{error:%%ansible_collection_url: You must pass the collection " ..
rdobuilder 6b0be9
            "namespace as the first arg and the collection name as the second}")
rdobuilder 6b0be9
    end
rdobuilder 6b0be9
    print("https://galaxy.ansible.com/" .. namespace_name)
rdobuilder 6b0be9
}