Skip to content

Commit

Permalink
Merge pull request #71 from bnavigator/default-provider
Browse files Browse the repository at this point in the history
Define a default provider for python3-foo
  • Loading branch information
mcepl committed Nov 12, 2020
2 parents 1f71d50 + 028fc2d commit a4c80dc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
4 changes: 4 additions & 0 deletions compile-macros.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ BUILDSET="python2 python3 python36 python38"
### flavor-specific: generate from flavor.in
for flavor in $FLAVORS; do
sed 's/#FLAVOR#/'$flavor'/g' flavor.in > macros/020-flavor-$flavor
if [ "$flavor" = "python2" ]; then
# special old-style package provides and obsoletes for python2
echo "%${flavor}_provides python" >> macros/020-flavor-$flavor
fi
done


Expand Down
12 changes: 11 additions & 1 deletion flavor.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

%#FLAVOR#_shbang_opts %py_shbang_opts

%__#FLAVOR# /usr/bin/%{lua: print((string.gsub("#FLAVOR#", "(%w+%d)(%d)", "%1.%2")))}
%__#FLAVOR# %{_bindir}/%{lua: print((string.gsub("#FLAVOR#", "(%w+%d)(%d)", "%1.%2")))}

%#FLAVOR#_prefix #FLAVOR#
%#FLAVOR#_sitelib %{_python_sysconfig_path %__#FLAVOR# purelib}
Expand All @@ -15,6 +15,16 @@
%#FLAVOR#_sysconfig_path() %{_rec_macro_helper}%{lua:call_sysconfig("path", rpm.expand("%__#FLAVOR#"))}
%#FLAVOR#_sysconfig_var() %{_rec_macro_helper}%{lua:call_sysconfig("var", rpm.expand("%__#FLAVOR#"))}

# Check if there is a major version symlink to our flavor in the current build system. If so, we are the primary provider.
%#FLAVOR#_provides %(provides=""; \
for flavorbin in %{_bindir}/python?; do \
if [ $flavorbin != %__#FLAVOR# -a $(realpath $flavorbin) = %__#FLAVOR# ]; then \
provides+=" $(basename $flavorbin)"; \
fi; \
done; \
echo ${provides# }; \
)

%if#FLAVOR# %if "%{python_flavor}" == "#FLAVOR#"

%#FLAVOR#_only() %if "%{python_flavor}" == "#FLAVOR#" \
Expand Down
13 changes: 7 additions & 6 deletions macros.lua
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,11 @@ function python_subpackages()
end
-- end line processing functions

local function print_obsoletes(modname)
if current_flavor == "python2" then
print(rpm.expand("Obsoletes: python-" .. modname .. " < %{?epoch:%{epoch}:}%{version}-%{release}\n"))
print(rpm.expand("Provides: python-" .. modname .. " = %{?epoch:%{epoch}:}%{version}-%{release}\n"))
local function print_provided_flavor(modname)
for provided_flavor in string.gmatch(rpm.expand("%{?" .. current_flavor .. "_provides}"), "%S+" ) do
local pkg = provided_flavor .. "-" .. modname
print(rpm.expand("Obsoletes: " .. pkg .. " < %{?epoch:%{epoch}:}%{version}-%{release}\n"))
print(rpm.expand("Provides: " .. pkg .. " = %{?epoch:%{epoch}:}%{version}-%{release}\n"))
end
end

Expand Down Expand Up @@ -319,7 +320,7 @@ function python_subpackages()
else
section_function = process_package_line
print(section_headline("package", current_flavor, nil))
print_obsoletes(modname)
print_provided_flavor(modname)
end

while true do
Expand Down Expand Up @@ -366,7 +367,7 @@ function python_subpackages()
section_function = ignore_line
elseif newsection == "package" then
print(section_headline("package", current_flavor, param))
print_obsoletes(modname .. "-" .. param)
print_provided_flavor(modname .. "-" .. param)
section_function = process_package_line
elseif newsection == "files" and current_flavor == flavor then
section_function = ignore_line
Expand Down

0 comments on commit a4c80dc

Please sign in to comment.