|
|
838cdc |
# RDO macros
|
|
|
838cdc |
|
|
|
838cdc |
# Create given user with given group (to be used as %pre scriptlet for
|
|
|
838cdc |
# openstack related daemons). Also migrates away from openstack- prefixed
|
|
|
838cdc |
# users/group if it exists
|
|
|
838cdc |
# Optional:
|
|
|
838cdc |
# -u userid to pick
|
|
|
838cdc |
# -g groupid to pick
|
|
|
838cdc |
# -s shell to pick
|
|
|
838cdc |
# Example: openstack_pre_user_group_create keystone keystone
|
|
|
838cdc |
%openstack_pre_user_group_create(u:g:s:) \
|
|
|
838cdc |
getent group %2 >/dev/null || { \
|
|
|
838cdc |
groupadd -r %2 $oldg \
|
|
|
838cdc |
} \
|
|
|
838cdc |
getent passwd %1 >/dev/null || { \
|
|
|
838cdc |
useradd -r -g %2 %{-u:-u %{-u*}} -d %{_sharedstatedir}/%1 %{-s:-s %{-s*}}%{!-s: -s /sbin/nologin} -c "OpenStack %1 Daemon" %1 \
|
|
|
838cdc |
} \
|
|
|
838cdc |
%nil
|
|
|
838cdc |
|
|
|
838cdc |
|
|
|
838cdc |
%py_req_cleanup() \
|
|
|
838cdc |
sed -i 's/^warning-is-error.*/warning-is-error = 0/g' setup.cfg \
|
|
|
838cdc |
rm -rf *requirements.txt \
|
|
|
838cdc |
%nil
|
|
|
838cdc |
|
|
|
838cdc |
%sphinx_build /usr/bin/sphinx-build-3
|
|
|
838cdc |
|
|
|
838cdc |
#
|
|
|
838cdc |
# OpenStack Dashboard (horizon) macros
|
|
|
838cdc |
#
|
|
|
838cdc |
%http_dashboard_dir %{_datarootdir}/openstack-dashboard
|
|
|
838cdc |
|
|
|
838cdc |
# Create a fake tempest plugin entry point which will
|
|
|
838cdc |
# resides under %{python2_sitelib}/%{service}_tests.egg-info.
|
|
|
838cdc |
# The prefix is %py2_entrypoint %{modulename} %{service}
|
|
|
838cdc |
# where service is the name of the openstack-service or the modulename
|
|
|
838cdc |
# It should used under %install section
|
|
|
838cdc |
# the generated %{python2_sitelib}/%{service}_tests.egg-info
|
|
|
838cdc |
# will go under %files section of tempest plugin subpackage
|
|
|
838cdc |
# Example: %py2_entrypoint %{modulename} %{service}
|
|
|
838cdc |
# In most of the cases %{service} is same as %{modulename}
|
|
|
838cdc |
# but in case of neutron plugins it is different
|
|
|
838cdc |
# like servicename is neutron-lbaas and modulename is neutron_lbass
|
|
|
838cdc |
%py2_entrypoint() \
|
|
|
838cdc |
egg_path=%{buildroot}%{python2_sitelib}/%{1}-*.egg-info \
|
|
|
838cdc |
tempest_egg_path=%{buildroot}%{python2_sitelib}/%{1}_tests.egg-info \
|
|
|
838cdc |
mkdir $tempest_egg_path \
|
|
|
838cdc |
echo %{1} >$tempest_egg_path/top_level.txt \
|
|
|
838cdc |
grep "tempest\\|Tempest" %{1}.egg-info/entry_points.txt >$tempest_egg_path/entry_points.txt \
|
|
|
838cdc |
sed -i "/tempest\\|Tempest/d" $egg_path/entry_points.txt \
|
|
|
838cdc |
cp -r $egg_path/PKG-INFO $tempest_egg_path \
|
|
|
838cdc |
sed -i "s/%{2}/%{1}_tests/g" $tempest_egg_path/PKG-INFO \
|
|
|
838cdc |
%nil
|
|
|
838cdc |
|
|
|
838cdc |
|
|
|
838cdc |
# compat macros with Fedora
|
|
|
838cdc |
%python_provide() %{lua:\
|
|
|
838cdc |
function string.starts(String,Start)\
|
|
|
838cdc |
return string.sub(String,1,string.len(Start))==Start\
|
|
|
838cdc |
end\
|
|
|
838cdc |
str = rpm.expand("%{?1:%{1}}");\
|
|
|
838cdc |
vr = rpm.expand("%{?epoch:%{epoch}:}%{version}-%{release}")
|
|
|
838cdc |
if (string.starts(str, "python2-")) then\
|
|
|
838cdc |
print("Provides: python-");\
|
|
|
838cdc |
print(string.sub(str,9,string.len(str)));\
|
|
|
838cdc |
print(" = ");\
|
|
|
838cdc |
print(vr);\
|
|
|
838cdc |
--Obsoleting the previous default python package\
|
|
|
838cdc |
print("\\nObsoletes: python-");\
|
|
|
838cdc |
print(string.sub(str,9,string.len(str)));\
|
|
|
838cdc |
print(" < ");\
|
|
|
838cdc |
print(vr);\
|
|
|
838cdc |
elseif (string.starts(str, "python3-")) then\
|
|
|
838cdc |
--No unversioned provides as python3 is not default\
|
|
|
838cdc |
elseif (string.starts(str, "pypy-")) then\
|
|
|
838cdc |
--No unversioned provides as pypy is not default\
|
|
|
838cdc |
elseif (string.starts(str, "pypy3-")) then\
|
|
|
838cdc |
--No unversioned provides as pypy is not default\
|
|
|
838cdc |
elseif (string.starts(str, "python-")) then\
|
|
|
838cdc |
--Providing the current default python\
|
|
|
838cdc |
print("Provides: python2-");\
|
|
|
838cdc |
print(string.sub(str,8,string.len(str)));\
|
|
|
838cdc |
print(" = ");\
|
|
|
838cdc |
print(vr);\
|
|
|
838cdc |
else\
|
|
|
838cdc |
print("ERROR: ");\
|
|
|
838cdc |
print(str);\
|
|
|
838cdc |
print("not recognized.");\
|
|
|
838cdc |
end\
|
|
|
838cdc |
}
|
|
|
838cdc |
|
|
|
838cdc |
#
|
|
|
838cdc |
# Missing systemd macros in EL7 (taken from systemd under GPL 2.1+)
|
|
|
838cdc |
#
|
|
|
838cdc |
%sysctl_apply() \
|
|
|
838cdc |
/usr/lib/systemd/systemd-sysctl %{?*} >/dev/null 2>&1 || : \
|
|
|
838cdc |
%{nil}
|
|
|
838cdc |
|
|
|
838cdc |
%binfmt_apply() \
|
|
|
838cdc |
/usr/lib/systemd/systemd-binfmt %{?*} >/dev/null 2>&1 || : \
|
|
|
838cdc |
%{nil}
|
|
|
838cdc |
|
|
|
838cdc |
#
|
|
|
838cdc |
# Apache related macros
|
|
|
838cdc |
#
|
|
|
838cdc |
%apache_name httpd
|
|
|
838cdc |
%apache_site_dir %{_sysconfdir}/%{apache_name}/conf.d/
|
|
|
838cdc |
%apache_conf_dir %{_sysconfdir}/%{apache_name}/conf.d/
|
|
|
838cdc |
%apache_user apache
|
|
|
838cdc |
%apache_group apache
|
|
|
838cdc |
|
|
|
838cdc |
#
|
|
|
838cdc |
# ext_man is used by the singlespec macro but is not defined on Fedora
|
|
|
838cdc |
#
|
|
|
838cdc |
%ext_info .gz
|
|
|
838cdc |
%ext_man .gz
|
|
|
838cdc |
|
|
|
838cdc |
|
|
|
838cdc |
# This macro defines environment variables available during the build
|
|
|
838cdc |
# Currently sets:
|
|
|
838cdc |
# - RHEL_ALLOW_PYTHON2_FOR_BUILD=1
|
|
|
838cdc |
# (enable python2 in RHEL between 7 and 9 buildroot)
|
|
|
838cdc |
%__openstack_set_env %{lua:
|
|
|
838cdc |
rhel_version=tonumber(rpm.expand("0%{?rhel}"))
|
|
|
838cdc |
if rhel_version > 7 then posix.setenv("RHEL_ALLOW_PYTHON2_FOR_BUILD",1) end
|
|
|
838cdc |
}
|
|
|
838cdc |
|
|
|
838cdc |
# Compatibility with fedora in CentOS7
|
|
|
838cdc |
|
|
|
838cdc |
# Macro to replace overly complicated references to PyPI source files.
|
|
|
838cdc |
# Expands to the pythonhosted URL for a package
|
|
|
838cdc |
# Accepts zero to three arguments:
|
|
|
838cdc |
# 1: The PyPI project name, defaulting to %srcname if it is defined, then
|
|
|
838cdc |
# %pypi_name if it is defined, then just %name.
|
|
|
838cdc |
# 2: The PYPI version, defaulting to %version.
|
|
|
838cdc |
# 3: The file extension, defaulting to "tar.gz". (A period will be added
|
|
|
838cdc |
# automatically.)
|
|
|
838cdc |
# Requires %__pypi_url and %__pypi_default_extension to be defined.
|
|
|
838cdc |
%__pypi_url https://files.pythonhosted.org/packages/source/
|
|
|
838cdc |
%__pypi_default_extension tar.gz
|
|
|
838cdc |
|
|
|
838cdc |
%pypi_source() %{lua:
|
|
|
838cdc |
local src = rpm.expand('%1')
|
|
|
838cdc |
local ver = rpm.expand('%2')
|
|
|
838cdc |
local ext = rpm.expand('%3')
|
|
|
838cdc |
local url = rpm.expand('%__pypi_url')
|
|
|
838cdc |
\
|
|
|
838cdc |
-- If no first argument, try %srcname, then %pypi_name, then %name
|
|
|
838cdc |
-- Note that rpm leaves macros unchanged if they are not defined.
|
|
|
838cdc |
if src == '%1' then
|
|
|
838cdc |
src = rpm.expand('%srcname')
|
|
|
838cdc |
end
|
|
|
838cdc |
if src == '%srcname' then
|
|
|
838cdc |
src = rpm.expand('%pypi_name')
|
|
|
838cdc |
end
|
|
|
838cdc |
if src == '%pypi_name' then
|
|
|
838cdc |
src = rpm.expand('%name')
|
|
|
838cdc |
end
|
|
|
838cdc |
\
|
|
|
838cdc |
-- If no second argument, use %version
|
|
|
838cdc |
if ver == '%2' then
|
|
|
838cdc |
ver = rpm.expand('%version')
|
|
|
838cdc |
end
|
|
|
838cdc |
\
|
|
|
838cdc |
-- If no third argument, use the preset default extension
|
|
|
838cdc |
if ext == '%3' then
|
|
|
838cdc |
ext = rpm.expand('%__pypi_default_extension')
|
|
|
838cdc |
end
|
|
|
838cdc |
\
|
|
|
838cdc |
local first = string.sub(src, 1, 1)
|
|
|
838cdc |
\
|
|
|
838cdc |
print(url .. first .. '/' .. src .. '/' .. src .. '-' .. ver .. '.' .. ext)
|
|
|
838cdc |
}
|
|
|
838cdc |
|
|
|
838cdc |
# Compatibility with fedora in CentOS8
|
|
|
838cdc |
|
|
|
838cdc |
# - gpgverify
|
|
|
838cdc |
# - pytest
|
|
|
838cdc |
# - python3
|
|
|
838cdc |
# - pycached
|
|
|
838cdc |
|
|
|
838cdc |
# From https://src.fedoraproject.org/rpms/redhat-rpm-config/blob/master/f/macros.fedora-misc
|
|
|
838cdc |
# gpgverify verifies signed sources. There is documentation in the script.
|
|
|
838cdc |
%gpgverify(k:s:d:) %{lua:
|
|
|
838cdc |
local script = rpm.expand("%{_rpmconfigdir}/redhat/gpgverify ")
|
|
|
838cdc |
local keyring = rpm.expand("%{-k*}")
|
|
|
838cdc |
local signature = rpm.expand("%{-s*}")
|
|
|
838cdc |
local data = rpm.expand("%{-d*}")
|
|
|
838cdc |
print(script)
|
|
|
838cdc |
if keyring ~= "" then
|
|
|
838cdc |
print(rpm.expand("--keyring='%{SOURCE" .. keyring .. "}' "))
|
|
|
838cdc |
end
|
|
|
838cdc |
if signature ~= "" then
|
|
|
838cdc |
print(rpm.expand("--signature='%{SOURCE" .. signature .. "}' "))
|
|
|
838cdc |
end
|
|
|
838cdc |
if data ~= "" then
|
|
|
838cdc |
print(rpm.expand("--data='%{SOURCE" .. data .. "}' "))
|
|
|
838cdc |
end
|
|
|
838cdc |
}
|
|
|
838cdc |
|
|
|
838cdc |
# From https://src.fedoraproject.org/rpms/python-rpm-macros/blob/master/f/macros.python3
|
|
|
838cdc |
# This is intended for Python 3 only, hence also no Python version in the name.
|
|
|
838cdc |
%__pytest /usr/bin/pytest%(test %{python3_pkgversion} == 3 || echo -%{python3_version})
|
|
|
838cdc |
%pytest %{expand:\\\
|
|
|
838cdc |
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
|
|
|
838cdc |
PATH="%{buildroot}%{_bindir}:$PATH"\\\
|
|
|
838cdc |
PYTHONPATH="${PYTHONPATH:-%{buildroot}%{python3_sitearch}:%{buildroot}%{python3_sitelib}}"\\\
|
|
|
838cdc |
PYTHONDONTWRITEBYTECODE=1\\\
|
|
|
838cdc |
%__pytest}
|
|
|
838cdc |
|
|
|
838cdc |
# From https://src.fedoraproject.org/rpms/python-rpm-macros/blob/master/f/macros.python-srpm
|
|
|
838cdc |
%python3 %__python3
|
|
|
838cdc |
|
|
|
838cdc |
# From https://src.fedoraproject.org/rpms/python-rpm-macros/blob/master/f/macros.python3
|
|
|
838cdc |
# This only supports Python 3.5+ and will never work with Python 2.
|
|
|
838cdc |
# Hence, it has no Python version in the name.
|
|
|
838cdc |
%pycached() %{lua:
|
|
|
838cdc |
path = rpm.expand("%{?*}")
|
|
|
838cdc |
if (string.sub(path, "-3") ~= ".py") then
|
|
|
838cdc |
rpm.expand("%{error:%%pycached can only be used with paths explicitly ending with .py}")
|
|
|
838cdc |
else
|
|
|
838cdc |
print(path)
|
|
|
838cdc |
pyminor = path:match("/python3.(%d+)/") or "*"
|
|
|
838cdc |
dirname = path:match("(.*/)")
|
|
|
838cdc |
modulename = path:match(".*/([^/]+).py")
|
|
|
838cdc |
print("\\n" .. dirname .. "__pycache__/" .. modulename .. ".cpython-3" .. pyminor .. "{,.opt-?}.pyc")
|
|
|
838cdc |
end
|
|
|
838cdc |
}
|