!4 openEuler-rpm-config

Merge pull request !4 from syyhao/dev2
This commit is contained in:
openeuler-ci-bot 2020-01-13 22:53:16 +08:00 committed by Gitee
commit fe0e75ab5c
5 changed files with 2576 additions and 2570 deletions

3644
config.sub vendored

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
Name: %{vendor}-rpm-config Name: %{vendor}-rpm-config
Version: 30 Version: 30
Release: 2 Release: 3
License: GPL+ License: GPL+
Summary: specific rpm configuration files Summary: specific rpm configuration files
URL: https://gitee.com/src-openeuler/openEuler-rpm-config URL: https://gitee.com/src-openeuler/openEuler-rpm-config
@ -104,6 +104,12 @@ mkdir -p %{buildroot}%{_fileattrsdir}
%{_rpmconfigdir}/macros.d/* %{_rpmconfigdir}/macros.d/*
%changelog %changelog
* Mon Jan 13 2020 openEuler Buildteam <buildteam@openeuler.org> - 30-3
- Type:enhancement
- ID:NA
- SUG:NA
- DESC:change type of files
* Mon Jan 13 2020 openEuler Buildteam <buildteam@openeuler.org> - 30-2 * Mon Jan 13 2020 openEuler Buildteam <buildteam@openeuler.org> - 30-2
- Type:enhancement - Type:enhancement
- ID:NA - ID:NA

588
macros
View File

@ -1,294 +1,294 @@
# Per-platform rpm configuration file. # Per-platform rpm configuration file.
%_vendor %{?_vendor:%{_vendor}}%{!?_vendor:openEuler} %_vendor %{?_vendor:%{_vendor}}%{!?_vendor:openEuler}
%_os linux %_os linux
%_target_platform %{_target_cpu}-%{_vendor}-%{_target_os}%{?_gnu} %_target_platform %{_target_cpu}-%{_vendor}-%{_target_os}%{?_gnu}
#============================================================================== #==============================================================================
# ---- configure macros. note that most of these are inherited # ---- configure macros. note that most of these are inherited
# from the defaults. # from the defaults.
# #
%_localstatedir /var %_localstatedir /var
%_pkgdocdir %{_docdir}/%{name} %_pkgdocdir %{_docdir}/%{name}
%_docdir_fmt %%{NAME} %_docdir_fmt %%{NAME}
%_fmoddir %{_libdir}/gfortran/modules %_fmoddir %{_libdir}/gfortran/modules
%_enable_debug_packages 1 %_enable_debug_packages 1
#%_include_minidebuginfo 1 #%_include_minidebuginfo 1
%_include_gdb_index 1 %_include_gdb_index 1
%_debugsource_packages 1 %_debugsource_packages 1
#%_debuginfo_subpackages 1 #%_debuginfo_subpackages 1
#============================================================================== #==============================================================================
# ---- compiler flags. # ---- compiler flags.
%build_cflags %{optflags} %build_cflags %{optflags}
%build_cxxflags %{optflags} %build_cxxflags %{optflags}
%build_fflags %{optflags} -I%{_fmoddir} %build_fflags %{optflags} -I%{_fmoddir}
%build_ldflags -Wl,-z,relro %{_ld_as_needed_flags} %{_ld_symbols_flags} %{_hardened_ldflags} %build_ldflags -Wl,-z,relro %{_ld_as_needed_flags} %{_ld_symbols_flags} %{_hardened_ldflags}
%set_build_flags \ %set_build_flags \
CFLAGS="${CFLAGS:-%{build_cflags}}" ; export CFLAGS ; \ CFLAGS="${CFLAGS:-%{build_cflags}}" ; export CFLAGS ; \
CXXFLAGS="${CXXFLAGS:-%{build_cxxflags}}" ; export CXXFLAGS ; \ CXXFLAGS="${CXXFLAGS:-%{build_cxxflags}}" ; export CXXFLAGS ; \
FFLAGS="${FFLAGS:-%{build_fflags}}" ; export FFLAGS ; \ FFLAGS="${FFLAGS:-%{build_fflags}}" ; export FFLAGS ; \
FCFLAGS="${FCFLAGS:-%{build_fflags}}" ; export FCFLAGS ; \ FCFLAGS="${FCFLAGS:-%{build_fflags}}" ; export FCFLAGS ; \
LDFLAGS="${LDFLAGS:-%{build_ldflags}}" ; export LDFLAGS LDFLAGS="${LDFLAGS:-%{build_ldflags}}" ; export LDFLAGS
#For backwards compatibility only. #For backwards compatibility only.
%__global_cflags %{build_cflags} %__global_cflags %{build_cflags}
%__global_cxxflags %{build_cxxflags} %__global_cxxflags %{build_cxxflags}
%__global_fflags %{build_fflags} %__global_fflags %{build_fflags}
%__global_fcflags %{build_fflags} %__global_fcflags %{build_fflags}
%__global_ldflags %{build_ldflags} %__global_ldflags %{build_ldflags}
#============================================================================== #==============================================================================
# ---- configure and makeinstall. # ---- configure and makeinstall.
%_configure_gnuconfig_hack 1 %_configure_gnuconfig_hack 1
%_configure_libtool_hardening_hack 1 %_configure_libtool_hardening_hack 1
%configure \ %configure \
%{set_build_flags}; \ %{set_build_flags}; \
[ "%_configure_gnuconfig_hack" = 1 ] && for i in $(find $(dirname %{_configure}) -name config.guess -o -name config.sub) ; do \ [ "%_configure_gnuconfig_hack" = 1 ] && for i in $(find $(dirname %{_configure}) -name config.guess -o -name config.sub) ; do \
[ -f /usr/lib/rpm/openEuler/$(basename $i) ] && %{__rm} -f $i && %{__cp} -fv /usr/lib/rpm/openEuler/$(basename $i) $i ; \ [ -f /usr/lib/rpm/openEuler/$(basename $i) ] && %{__rm} -f $i && %{__cp} -fv /usr/lib/rpm/openEuler/$(basename $i) $i ; \
done ; \ done ; \
[ "%_configure_libtool_hardening_hack" = 1 ] && [ x != "x%{_hardened_ldflags}" ] && \ [ "%_configure_libtool_hardening_hack" = 1 ] && [ x != "x%{_hardened_ldflags}" ] && \
for i in $(find . -name ltmain.sh) ; do \ for i in $(find . -name ltmain.sh) ; do \
%{__sed} -i.backup -e 's~compiler_flags=$~compiler_flags="%{_hardened_ldflags}"~' $i \ %{__sed} -i.backup -e 's~compiler_flags=$~compiler_flags="%{_hardened_ldflags}"~' $i \
done ; \ done ; \
%{_configure} --build=%{_build} --host=%{_host} \\\ %{_configure} --build=%{_build} --host=%{_host} \\\
--program-prefix=%{?_program_prefix} \\\ --program-prefix=%{?_program_prefix} \\\
--disable-dependency-tracking \\\ --disable-dependency-tracking \\\
%{?_configure_disable_silent_rules:--disable-silent-rules} \\\ %{?_configure_disable_silent_rules:--disable-silent-rules} \\\
--prefix=%{_prefix} \\\ --prefix=%{_prefix} \\\
--exec-prefix=%{_exec_prefix} \\\ --exec-prefix=%{_exec_prefix} \\\
--bindir=%{_bindir} \\\ --bindir=%{_bindir} \\\
--sbindir=%{_sbindir} \\\ --sbindir=%{_sbindir} \\\
--sysconfdir=%{_sysconfdir} \\\ --sysconfdir=%{_sysconfdir} \\\
--datadir=%{_datadir} \\\ --datadir=%{_datadir} \\\
--includedir=%{_includedir} \\\ --includedir=%{_includedir} \\\
--libdir=%{_libdir} \\\ --libdir=%{_libdir} \\\
--libexecdir=%{_libexecdir} \\\ --libexecdir=%{_libexecdir} \\\
--localstatedir=%{_localstatedir} \\\ --localstatedir=%{_localstatedir} \\\
--sharedstatedir=%{_sharedstatedir} \\\ --sharedstatedir=%{_sharedstatedir} \\\
--mandir=%{_mandir} \\\ --mandir=%{_mandir} \\\
--infodir=%{_infodir} --infodir=%{_infodir}
# ---- Build policy macros. # ---- Build policy macros.
%__spec_install_pre %{___build_pre}\ %__spec_install_pre %{___build_pre}\
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf "${RPM_BUILD_ROOT}"\ [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf "${RPM_BUILD_ROOT}"\
mkdir -p `dirname "$RPM_BUILD_ROOT"`\ mkdir -p `dirname "$RPM_BUILD_ROOT"`\
mkdir "$RPM_BUILD_ROOT"\ mkdir "$RPM_BUILD_ROOT"\
%{nil} %{nil}
# ---- Expanded at end of %install scriptlet. # ---- Expanded at end of %install scriptlet.
%__arch_install_post /usr/lib/rpm/check-buildroot %__arch_install_post /usr/lib/rpm/check-buildroot
# Build root policy macros. Standard naming: # Build root policy macros. Standard naming:
# convert all '-' in basename to '_', add two leading underscores. # convert all '-' in basename to '_', add two leading underscores.
%__brp_ldconfig /usr/lib/rpm/openEuler/brp-ldconfig %__brp_ldconfig /usr/lib/rpm/openEuler/brp-ldconfig
%__brp_compress /usr/lib/rpm/brp-compress %__brp_compress /usr/lib/rpm/brp-compress
%__brp_strip /usr/lib/rpm/brp-strip %{__strip} %__brp_strip /usr/lib/rpm/brp-strip %{__strip}
%__brp_strip_comment_note /usr/lib/rpm/brp-strip-comment-note %{__strip} %{__objdump} %__brp_strip_comment_note /usr/lib/rpm/brp-strip-comment-note %{__strip} %{__objdump}
%__brp_strip_static_archive /usr/lib/rpm/brp-strip-static-archive %{__strip} %__brp_strip_static_archive /usr/lib/rpm/brp-strip-static-archive %{__strip}
%__brp_python_bytecompile /usr/lib/rpm/brp-python-bytecompile "%{__python}" "%{?_python_bytecompile_errors_terminate_build}" "%{?_python_bytecompile_extra}" %__brp_python_bytecompile /usr/lib/rpm/brp-python-bytecompile "%{__python}" "%{?_python_bytecompile_errors_terminate_build}" "%{?_python_bytecompile_extra}"
%__brp_python_hardlink /usr/lib/rpm/brp-python-hardlink %__brp_python_hardlink /usr/lib/rpm/brp-python-hardlink
%__os_install_post \ %__os_install_post \
%{?__brp_ldconfig} \ %{?__brp_ldconfig} \
%{?__brp_compress} \ %{?__brp_compress} \
%{!?__debug_package:\ %{!?__debug_package:\
%{?__brp_strip} \ %{?__brp_strip} \
%{?__brp_strip_comment_note} \ %{?__brp_strip_comment_note} \
} \ } \
%{?__brp_strip_static_archive} \ %{?__brp_strip_static_archive} \
%{?py_auto_byte_compile:%{?__brp_python_bytecompile}} \ %{?py_auto_byte_compile:%{?__brp_python_bytecompile}} \
%{?__brp_python_hardlink} \ %{?__brp_python_hardlink} \
%{nil} %{nil}
%__spec_install_post\ %__spec_install_post\
%{?__debug_package:%{__debug_install_post}}\ %{?__debug_package:%{__debug_install_post}}\
%{__arch_install_post}\ %{__arch_install_post}\
%{__os_install_post}\ %{__os_install_post}\
%{nil} %{nil}
%install %{?_enable_debug_packages:%{?buildsubdir:%{debug_package}}}\ %install %{?_enable_debug_packages:%{?buildsubdir:%{debug_package}}}\
%%install\ %%install\
%{nil} %{nil}
# #
# Should missing buildids terminate a build? # Should missing buildids terminate a build?
%_missing_build_ids_terminate_build 1 %_missing_build_ids_terminate_build 1
# #
## Automatically compile python files ## Automatically compile python files
%py_auto_byte_compile 1 %py_auto_byte_compile 1
# #
## Should python bytecompilation errors terminate a build? ## Should python bytecompilation errors terminate a build?
%_python_bytecompile_errors_terminate_build 1 %_python_bytecompile_errors_terminate_build 1
## Should python bytecompilation compile outisde python specific directories? ## Should python bytecompilation compile outisde python specific directories?
%_python_bytecompile_extra 1 %_python_bytecompile_extra 1
# Use SHA-256 for FILEDIGESTS instead of default MD5 # Use SHA-256 for FILEDIGESTS instead of default MD5
%_source_filedigest_algorithm 8 %_source_filedigest_algorithm 8
%_binary_filedigest_algorithm 8 %_binary_filedigest_algorithm 8
# Use XZ compression for binary payloads # Use XZ compression for binary payloads
%_binary_payload w2.xzdio %_binary_payload w2.xzdio
# secure options for rpmbuild # secure options for rpmbuild
# #
# #hardened options # #hardened options
%_hardening_cflags -specs=/usr/lib/rpm/%{_vendor}/openEuler-hardened-cc1 %_hardening_cflags -specs=/usr/lib/rpm/%{_vendor}/openEuler-hardened-cc1
%_hardening_ldflags -Wl,-z,now -specs=/usr/lib/rpm/%{_vendor}/openEuler-hardened-ld %_hardening_ldflags -Wl,-z,now -specs=/usr/lib/rpm/%{_vendor}/openEuler-hardened-ld
# Use "%undefine _hardened_build" to disable. # Use "%undefine _hardened_build" to disable.
%_hardened_build 1 %_hardened_build 1
%_hardened_cflags %{?_hardened_build:%{_hardening_cflags}} %_hardened_cflags %{?_hardened_build:%{_hardening_cflags}}
%_hardened_ldflags %{?_hardened_build:%{_hardening_ldflags}} %_hardened_ldflags %{?_hardened_build:%{_hardening_ldflags}}
#secure options pie #secure options pie
%_sec_opt_build 1 %_sec_opt_build 1
#Use "%undefine _sec_opt_build" to disable. #Use "%undefine _sec_opt_build" to disable.
#Use "%undefine _pie_build" to disable. #Use "%undefine _pie_build" to disable.
%_pie_build 1 %_pie_build 1
%_pie_pre_cflags -specs=/usr/lib/rpm/%{_vendor}/openEuler-pie-cc1 %_pie_pre_cflags -specs=/usr/lib/rpm/%{_vendor}/openEuler-pie-cc1
%_pie_pre_ldflags -Wl,-z,now -specs=/usr/lib/rpm/%{_vendor}/openEuler-pie-ld %_pie_pre_ldflags -Wl,-z,now -specs=/usr/lib/rpm/%{_vendor}/openEuler-pie-ld
%_pie_cflags %{?_sec_opt_build:?_pie_build:%{_pie_pre_cflags}} %_pie_cflags %{?_sec_opt_build:?_pie_build:%{_pie_pre_cflags}}
%_pie_ldflags %{?_sec_opt_build:?_pie_build:%{_pie_pre_ldflags}} %_pie_ldflags %{?_sec_opt_build:?_pie_build:%{_pie_pre_ldflags}}
#Use "%undefine _fs_build" to disable. #Use "%undefine _fs_build" to disable.
%_fs_build 1 %_fs_build 1
%_fs_pre_cflags -specs=/usr/lib/rpm/%{_vendor}/openEuler-fs-cc1 %_fs_pre_cflags -specs=/usr/lib/rpm/%{_vendor}/openEuler-fs-cc1
%_fs_cflags %{?_fs_build:%{_fs_pre_cflags}} %_fs_cflags %{?_fs_build:%{_fs_pre_cflags}}
# Fail linking if there are undefined symbols. Required for proper # Fail linking if there are undefined symbols. Required for proper
# ELF symbol versioning support. Disabled by default. # ELF symbol versioning support. Disabled by default.
# Use "%define _ld_strict_symbol_defs 1" to enable. # Use "%define _ld_strict_symbol_defs 1" to enable.
#%_ld_strict_symbol_defs 1 #%_ld_strict_symbol_defs 1
%_ld_symbols_flags %{?_ld_strict_symbol_defs:-Wl,-z,defs} %_ld_symbols_flags %{?_ld_strict_symbol_defs:-Wl,-z,defs}
# use "%define _ld_as_needed 1" to enable. # use "%define _ld_as_needed 1" to enable.
#%_ld_as_needed 1 #%_ld_as_needed 1
%_ld_as_needed_flags %{?_ld_as_needed:-Wl,--as-needed} %_ld_as_needed_flags %{?_ld_as_needed:-Wl,--as-needed}
%__global_compiler_flags -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches %{_hardened_cflags} %__global_compiler_flags -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches %{_hardened_cflags}
# Automatically trim changelog entries after 2 years # Automatically trim changelog entries after 2 years
%_changelog_trimtime %{lua:print(os.time() - 2 * 365 * 86400)} %_changelog_trimtime %{lua:print(os.time() - 2 * 365 * 86400)}
#============================================================================== #==============================================================================
# ---- Generic auto req/prov filtering macros # ---- Generic auto req/prov filtering macros
# prevent anything matching from being scanned for provides # prevent anything matching from being scanned for provides
%filter_provides_in(P) %{expand: \ %filter_provides_in(P) %{expand: \
%global __filter_prov_cmd %{?__filter_prov_cmd} %{__grep} -v %{-P} '%*' | \ %global __filter_prov_cmd %{?__filter_prov_cmd} %{__grep} -v %{-P} '%*' | \
} }
# prevent anything matching from being scanned for requires # prevent anything matching from being scanned for requires
%filter_requires_in(P) %{expand: \ %filter_requires_in(P) %{expand: \
%global __filter_req_cmd %{?__filter_req_cmd} %{__grep} -v %{-P} '%*' | \ %global __filter_req_cmd %{?__filter_req_cmd} %{__grep} -v %{-P} '%*' | \
} }
# filter anything matching out of the provides stream # filter anything matching out of the provides stream
%filter_from_provides() %{expand: \ %filter_from_provides() %{expand: \
%global __filter_from_prov %{?__filter_from_prov} | %{__sed} -e '%*' \ %global __filter_from_prov %{?__filter_from_prov} | %{__sed} -e '%*' \
} }
# filter anything matching out of the requires stream # filter anything matching out of the requires stream
%filter_from_requires() %{expand: \ %filter_from_requires() %{expand: \
%global __filter_from_req %{?__filter_from_req} | %{__sed} -e '%*' \ %global __filter_from_req %{?__filter_from_req} | %{__sed} -e '%*' \
} }
# actually set up the filtering bits # actually set up the filtering bits
%filter_setup %{expand: \ %filter_setup %{expand: \
%global _use_internal_dependency_generator 0 \ %global _use_internal_dependency_generator 0 \
%global __deploop() while read FILE; do echo "${FILE}" | /usr/lib/rpm/rpmdeps -%{1}; done | /bin/sort -u \ %global __deploop() while read FILE; do echo "${FILE}" | /usr/lib/rpm/rpmdeps -%{1}; done | /bin/sort -u \
%global __find_provides /bin/sh -c "%{?__filter_prov_cmd} %{__deploop P} %{?__filter_from_prov}" \ %global __find_provides /bin/sh -c "%{?__filter_prov_cmd} %{__deploop P} %{?__filter_from_prov}" \
%global __find_requires /bin/sh -c "%{?__filter_req_cmd} %{__deploop R} %{?__filter_from_req}" \ %global __find_requires /bin/sh -c "%{?__filter_req_cmd} %{__deploop R} %{?__filter_from_req}" \
} }
# compare two versions, returns -1, 0, 1, ~~~ # compare two versions, returns -1, 0, 1, ~~~
%rpm_vercmp() %{lua:print(rpm.expand('%1') == '~~~' and '~~~' or rpm.vercmp(rpm.expand('%1'), rpm.expand('%2')))} %rpm_vercmp() %{lua:print(rpm.expand('%1') == '~~~' and '~~~' or rpm.vercmp(rpm.expand('%1'), rpm.expand('%2')))}
# expand to the installed version of a package/provides # expand to the installed version of a package/provides
%pkg_version() %(LC_ALL=C rpm -q --whatprovides --qf "%%{version}" "%1" | sed -e "s/^no package provides .*/~~~/") %pkg_version() %(LC_ALL=C rpm -q --whatprovides --qf "%%{version}" "%1" | sed -e "s/^no package provides .*/~~~/")
# compare the installed version to a value. returns -1, 0, 1, ~~~ # compare the installed version to a value. returns -1, 0, 1, ~~~
%pkg_version_cmp() %{expand:%{expand:%%%%{rpm_vercmp %%{pkg_version %1} %%2}}} %pkg_version_cmp() %{expand:%{expand:%%%%{rpm_vercmp %%{pkg_version %1} %%2}}}
# convenience/readability # convenience/readability
%pkg_vcmp() (%{expand:%%{pkg_version_cmp %1 %3}} %2 0) %pkg_vcmp() (%{expand:%%{pkg_version_cmp %1 %3}} %2 0)
#arches macros #arches macros
%generic_arches %{ix86} x86_64 %{arm} aarch64 %generic_arches %{ix86} x86_64 %{arm} aarch64
%ldc_arches %{generic_arches} %ldc_arches %{generic_arches}
%valgrind_arches %{generic_arches} %valgrind_arches %{generic_arches}
%nodejs_arches %{generic_arches} %nodejs_arches %{generic_arches}
%ldc_arches %{generic_arches} %ldc_arches %{generic_arches}
%mono_arches %{generic_arches} %mono_arches %{generic_arches}
%fpc_arches %{generic_arches} %fpc_arches %{generic_arches}
%ghc_arches_with_ghci %{generic_arches} %ghc_arches_with_ghci %{generic_arches}
%ghc_arches %{generic_arches} %ghc_arches %{generic_arches}
%GNAT_arches %{GPRbuild_arches} %{generic_arches} %GNAT_arches %{GPRbuild_arches} %{generic_arches}
%GPRbuild_arches %{generic_arches} %GPRbuild_arches %{generic_arches}
%nim_arches %{generic_arches} %nim_arches %{generic_arches}
%nodejs_arches %{generic_arches} %nodejs_arches %{generic_arches}
%ocaml_native_compiler %{generic_arches} %ocaml_native_compiler %{generic_arches}
%ocaml_natdynlink %{generic_arches} %ocaml_natdynlink %{generic_arches}
%ocaml_native_profiling %{generic_arches} %ocaml_native_profiling %{generic_arches}
%openblas_arches %{generic_arches} %openblas_arches %{generic_arches}
#%ldconfig /sbin/ldconfig #%ldconfig /sbin/ldconfig
%ldconfig_post(n:) %{?ldconfig:%post -p %ldconfig %{?*} %{-n:-n %{-n*}}\ %ldconfig_post(n:) %{?ldconfig:%post -p %ldconfig %{?*} %{-n:-n %{-n*}}\
%end} %end}
%ldconfig_postun(n:) %{?ldconfig:%postun -p %ldconfig %{?*} %{-n:-n %{-n*}}\ %ldconfig_postun(n:) %{?ldconfig:%postun -p %ldconfig %{?*} %{-n:-n %{-n*}}\
%end} %end}
%ldconfig_scriptlets(n:) %{?ldconfig:\ %ldconfig_scriptlets(n:) %{?ldconfig:\
%ldconfig_post %{?*} %{-n:-n %{-n*}}\ %ldconfig_post %{?*} %{-n:-n %{-n*}}\
%ldconfig_postun %{?*} %{-n:-n %{-n*}}\ %ldconfig_postun %{?*} %{-n:-n %{-n*}}\
} }
# Some miscellaneous macros # Some miscellaneous macros
%_metainfodir %{_datadir}/metainfo %_metainfodir %{_datadir}/metainfo
%rpmmacrodir /usr/lib/rpm/macros.d %rpmmacrodir /usr/lib/rpm/macros.d
# arches that mono builds on # arches that mono builds on
%_monogacdir %{_monodir}/gac %_monogacdir %{_monodir}/gac
%_monodir %{_prefix}/lib/mono %_monodir %{_prefix}/lib/mono
# ---- VPATH default settings # ---- VPATH default settings
%_vpath_builddir %_target_platform %_vpath_builddir %_target_platform
%_vpath_srcdir . %_vpath_srcdir .
# ---- custom macros # ---- custom macros
%disable_rpath \ %disable_rpath \
sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool \ sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool \
sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
%delete_la_and_a \ %delete_la_and_a \
find $RPM_BUILD_ROOT -type f -name "*.la" -delete \ find $RPM_BUILD_ROOT -type f -name "*.la" -delete \
find $RPM_BUILD_ROOT -type f -name "*.a" -delete find $RPM_BUILD_ROOT -type f -name "*.a" -delete
%delete_la find $RPM_BUILD_ROOT -type f -name "*.la" -delete %delete_la find $RPM_BUILD_ROOT -type f -name "*.la" -delete
%chrpath_delete find $RPM_BUILD_ROOT/ -type f -exec file {} ';' | grep "\<ELF\>" | awk -F ':' '{print $1}' | xargs -i chrpath --delete {} %chrpath_delete find $RPM_BUILD_ROOT/ -type f -exec file {} ';' | grep "\<ELF\>" | awk -F ':' '{print $1}' | xargs -i chrpath --delete {}
%package_help \ %package_help \
%package help \ %package help \
Summary: Documents for %{name} \ Summary: Documents for %{name} \
Buildarch: noarch \ Buildarch: noarch \
Requires: man info \ Requires: man info \
\ \
%description help \ %description help \
Man pages and other related documents for %{name}. Man pages and other related documents for %{name}.
#%sbin_installinfo_rm bc.info #%sbin_installinfo_rm bc.info
#%sbin_installinfo_rm bc.info.gz #%sbin_installinfo_rm bc.info.gz
%install_info() \ %install_info() \
/sbin/install-info %1 %{_infodir}/dir || : /sbin/install-info %1 %{_infodir}/dir || :
%install_info_rm() \ %install_info_rm() \
/sbin/install-info --remove %1 %{_infodir}/dir || : /sbin/install-info --remove %1 %{_infodir}/dir || :

View File

@ -1,283 +1,283 @@
# Map forge information to rpm metadata. This macro will compute default spec # Map forge information to rpm metadata. This macro will compute default spec
# variable values. # variable values.
# #
# The following spec variables SHOULD be set before calling the macro: # The following spec variables SHOULD be set before calling the macro:
# #
# forgeurl the project url on the forge, strongly recommended; # forgeurl the project url on the forge, strongly recommended;
# alternatively, use -u <url> # alternatively, use -u <url>
# Version if applicable, set it with Version: <version> # Version if applicable, set it with Version: <version>
# tag if applicable # tag if applicable
# commit if applicable # commit if applicable
# date if applicable (to override the mtime of the Source archive) # date if applicable (to override the mtime of the Source archive)
# #
# The macro will attempt to compute and set the following variables if they are # The macro will attempt to compute and set the following variables if they are
# not already set by the packager: # not already set by the packager:
# #
# forgesource an URL that can be used as SourceX: value # forgesource an URL that can be used as SourceX: value
# forgesetupargs the correct arguments to pass to %setup for this source # forgesetupargs the correct arguments to pass to %setup for this source
# used by %forgesetup and %forgeautosetup # used by %forgesetup and %forgeautosetup
# archivename the source archive filename, without extentions # archivename the source archive filename, without extentions
# archiveext the source archive filename extensions, without leading dot # archiveext the source archive filename extensions, without leading dot
# archiveurl the url that can be used to download the source archive, # archiveurl the url that can be used to download the source archive,
# without renaming # without renaming
# scm the scm type, when packaging code snapshots: commits or tags # scm the scm type, when packaging code snapshots: commits or tags
# #
# If the macro is unable to parse your forgeurl value set at least archivename # If the macro is unable to parse your forgeurl value set at least archivename
# and archiveurl before calling it. # and archiveurl before calling it.
# #
# Most of the computed variables are both overridable and optional. However, # Most of the computed variables are both overridable and optional. However,
# the macro WILL REDEFINE %{dist} when packaging a snapshot (commit or tag). # the macro WILL REDEFINE %{dist} when packaging a snapshot (commit or tag).
# The previous %{dist} value will be lost. Dont call the macro if you dont # The previous %{dist} value will be lost. Dont call the macro if you dont
# wish %{dist} to be changed. # wish %{dist} to be changed.
# #
# Optional parameters: # Optional parameters:
# -u <url> Ignore forgeurl even if it exists and use <url> instead. Note # -u <url> Ignore forgeurl even if it exists and use <url> instead. Note
# that the macro will still end up setting <url> as the forgeurl # that the macro will still end up setting <url> as the forgeurl
# spec variable if it manages to parse it. # spec variable if it manages to parse it.
# -s Silently ignore problems in forgeurl, use it if it can be parsed, # -s Silently ignore problems in forgeurl, use it if it can be parsed,
# ignore it otherwise. # ignore it otherwise.
# -p Restore problem handling, override -s. # -p Restore problem handling, override -s.
# -v Be verbose and print every spec variable the macro sets. # -v Be verbose and print every spec variable the macro sets.
# -i Print some info about the state of spec variables the macro may use or # -i Print some info about the state of spec variables the macro may use or
# set at the end of the processing. # set at the end of the processing.
%forgemeta(u:spvi) %{lua: %forgemeta(u:spvi) %{lua:
local forgeurl = rpm.expand("%{?-u*}") local forgeurl = rpm.expand("%{?-u*}")
if (forgeurl == "") then if (forgeurl == "") then
forgeurl = rpm.expand("%{?forgeurl}") forgeurl = rpm.expand("%{?forgeurl}")
end end
local silent = false local silent = false
local verbose = false local verbose = false
local informative = false local informative = false
if (rpm.expand("%{?-s}") ~= "") then if (rpm.expand("%{?-s}") ~= "") then
silent = true silent = true
end end
if (rpm.expand("%{?-p}") ~= "") then if (rpm.expand("%{?-p}") ~= "") then
silent = false silent = false
end end
if (rpm.expand("%{?-v}") ~= "") then if (rpm.expand("%{?-v}") ~= "") then
verbose = true verbose = true
end end
if (rpm.expand("%{?-i}") ~= "") then if (rpm.expand("%{?-i}") ~= "") then
informative = true informative = true
end end
local tag = rpm.expand("%{?tag}") local tag = rpm.expand("%{?tag}")
local commit = rpm.expand("%{?commit}") local commit = rpm.expand("%{?commit}")
-- Be explicit about the spec variables were setting -- Be explicit about the spec variables were setting
local function explicitset(rpmvariable,value) local function explicitset(rpmvariable,value)
rpm.define(rpmvariable .. " " .. value) rpm.define(rpmvariable .. " " .. value)
if verbose then if verbose then
rpm.expand("%{echo:Setting %%{" .. rpmvariable .. "} = " .. value .. "\\n}") rpm.expand("%{echo:Setting %%{" .. rpmvariable .. "} = " .. value .. "\\n}")
end end
end end
-- Never ever stomp on a spec variable the packager already set -- Never ever stomp on a spec variable the packager already set
local function safeset(rpmvariable,value) local function safeset(rpmvariable,value)
if (rpm.expand("%{?" .. rpmvariable .. "}") == "") then if (rpm.expand("%{?" .. rpmvariable .. "}") == "") then
explicitset(rpmvariable,value) explicitset(rpmvariable,value)
end end
end end
-- Set spec variable values for each known software publishing service -- Set spec variable values for each known software publishing service
if (forgeurl ~= "") then if (forgeurl ~= "") then
local forge = string.match(forgeurl, "^[^:]+://([^/]+)/") local forge = string.match(forgeurl, "^[^:]+://([^/]+)/")
if (forge == nil) then if (forge == nil) then
if not silent then if not silent then
rpm.expand("%{error:URLs must include a protocol such as https:// and a path starting with / !\\n}") rpm.expand("%{error:URLs must include a protocol such as https:// and a path starting with / !\\n}")
end end
else else
if (string.match(forge, "^gitlab[%.-]") or string.match(forge, "[%.-]gitlab[%.]")) then if (string.match(forge, "^gitlab[%.-]") or string.match(forge, "[%.-]gitlab[%.]")) then
forgeurl = string.match(forgeurl, "https://[^/]+/[^/]+/[^/#?]+") forgeurl = string.match(forgeurl, "https://[^/]+/[^/]+/[^/#?]+")
if (forgeurl == nil) then if (forgeurl == nil) then
if not silent then if not silent then
rpm.expand("%{error:Gitlab URLs must match https://(…[-.])gitlab[-.]…/owner/repo !\\n}") rpm.expand("%{error:Gitlab URLs must match https://(…[-.])gitlab[-.]…/owner/repo !\\n}")
end end
else else
explicitset("forgeurl", forgeurl) explicitset("forgeurl", forgeurl)
if (commit == "") then if (commit == "") then
rpm.expand("%{error:All Gitlab URLs require commit value knowledge: you need to define %{commit}!\\nPlease vote on https://gitlab.com/gitlab-org/gitlab-ce/issues/38830\\n}") rpm.expand("%{error:All Gitlab URLs require commit value knowledge: you need to define %{commit}!\\nPlease vote on https://gitlab.com/gitlab-org/gitlab-ce/issues/38830\\n}")
end end
safeset("archiveext", "tar.bz2") safeset("archiveext", "tar.bz2")
safeset("forgesetupargs", "-n %{archivename}") safeset("forgesetupargs", "-n %{archivename}")
if (commit ~= "") or (tag ~= "") then if (commit ~= "") or (tag ~= "") then
safeset("scm", "git") safeset("scm", "git")
end end
local owner = string.match(forgeurl, "^[^:]+://[^/]+/([^/]+)") local owner = string.match(forgeurl, "^[^:]+://[^/]+/([^/]+)")
local repo = string.match(forgeurl, "^[^:]+://[^/]+/[^/]+/([^/]+)") local repo = string.match(forgeurl, "^[^:]+://[^/]+/[^/]+/([^/]+)")
local version = rpm.expand("%{?version}") local version = rpm.expand("%{?version}")
if (version ~= "") and (version ~= "0") and (tag == "") then if (version ~= "") and (version ~= "0") and (tag == "") then
-- GitLab does not have strong versionning semantics -- GitLab does not have strong versionning semantics
-- Some projects use "version" as release tag, others "v" + "version" -- Some projects use "version" as release tag, others "v" + "version"
-- Tag value needs to be explicitly declared before calling the macro -- Tag value needs to be explicitly declared before calling the macro
-- in the second case -- in the second case
tag = version tag = version
safeset("tag", tag) safeset("tag", tag)
end end
if (tag ~= "") then if (tag ~= "") then
safeset("archivename", repo .. "-%{tag}-%{commit}") safeset("archivename", repo .. "-%{tag}-%{commit}")
safeset("archiveurl", "%{forgeurl}/repository/%{tag}/archive.%{archiveext}") safeset("archiveurl", "%{forgeurl}/repository/%{tag}/archive.%{archiveext}")
else else
safeset("archivename", repo .. "-%{commit}") safeset("archivename", repo .. "-%{commit}")
safeset("archiveurl", "%{forgeurl}/repository/%{commit}/archive.%{archiveext}") safeset("archiveurl", "%{forgeurl}/repository/%{commit}/archive.%{archiveext}")
end end
end end
end end
if (string.match(forge, "^github[%.-]") or string.match(forge, "[%.-]github[%.]")) then if (string.match(forge, "^github[%.-]") or string.match(forge, "[%.-]github[%.]")) then
forgeurl = string.match(forgeurl, "https://[^/]+/[^/]+/[^/#?]+") forgeurl = string.match(forgeurl, "https://[^/]+/[^/]+/[^/#?]+")
if (forgeurl == nil) then if (forgeurl == nil) then
if not silent then if not silent then
rpm.expand("%{error:GitHub URLs must match https://(…[-.])github[-.]…/owner/repo !\\n}") rpm.expand("%{error:GitHub URLs must match https://(…[-.])github[-.]…/owner/repo !\\n}")
end end
else else
explicitset("forgeurl", forgeurl) explicitset("forgeurl", forgeurl)
safeset("archiveext", "tar.gz") safeset("archiveext", "tar.gz")
local forgesetupargs = "-n %{archivename}" local forgesetupargs = "-n %{archivename}"
if (commit ~= "") or (tag ~= "") then if (commit ~= "") or (tag ~= "") then
safeset("scm", "git") safeset("scm", "git")
end end
local owner = string.match(forgeurl, "^[^:]+://[^/]+/([^/]+)") local owner = string.match(forgeurl, "^[^:]+://[^/]+/([^/]+)")
local repo = string.match(forgeurl, "^[^:]+://[^/]+/[^/]+/([^/]+)") local repo = string.match(forgeurl, "^[^:]+://[^/]+/[^/]+/([^/]+)")
if (tag ~= "") then if (tag ~= "") then
-- if upstream used a version suffix such as -rc1 or -beta it will not -- if upstream used a version suffix such as -rc1 or -beta it will not
-- be a valid version string for rpm but github will accept it fine and -- be a valid version string for rpm but github will accept it fine and
-- use the same naming as for other versions: v prefix in the tag and -- use the same naming as for other versions: v prefix in the tag and
-- archivename, no v prefix in the topdir naming inside the archive -- archivename, no v prefix in the topdir naming inside the archive
local version = rpm.expand("%{?version}") local version = rpm.expand("%{?version}")
if version ~= "" and if version ~= "" and
(string.match(tag, "^v" .. version .. "[^%d]") or (string.match(tag, "^v" .. version .. "[^%d]") or
string.match(tag, "^v" .. version .. "$")) then string.match(tag, "^v" .. version .. "$")) then
forgesetupargs = "-n " .. repo .. "-" .. string.gsub(tag, "^v", "") forgesetupargs = "-n " .. repo .. "-" .. string.gsub(tag, "^v", "")
end end
safeset("archivename", repo .. "-%{tag}") safeset("archivename", repo .. "-%{tag}")
safeset("archiveurl", "%{forgeurl}/archive/%{tag}.%{archiveext}") safeset("archiveurl", "%{forgeurl}/archive/%{tag}.%{archiveext}")
else else
if (commit ~= "") then if (commit ~= "") then
safeset("archivename", repo .. "-%{commit}") safeset("archivename", repo .. "-%{commit}")
safeset("archiveurl", "%{forgeurl}/archive/%{commit}/" .. repo .. "-%{commit}.%{archiveext}") safeset("archiveurl", "%{forgeurl}/archive/%{commit}/" .. repo .. "-%{commit}.%{archiveext}")
else else
safeset("archivename", repo .. "-%{version}") safeset("archivename", repo .. "-%{version}")
safeset("archiveurl", "%{forgeurl}/archive/v%{version}.%{archiveext}") safeset("archiveurl", "%{forgeurl}/archive/v%{version}.%{archiveext}")
end end
end end
safeset("forgesetupargs", forgesetupargs) safeset("forgesetupargs", forgesetupargs)
end end
end end
if (forge == "code.googlesource.com") then if (forge == "code.googlesource.com") then
forgeurl = string.match(forgeurl, "https://code.googlesource.com/[^#?]*[^/#?]+") forgeurl = string.match(forgeurl, "https://code.googlesource.com/[^#?]*[^/#?]+")
if (forgeurl == nil) then if (forgeurl == nil) then
if not silent then if not silent then
rpm.expand("%{error:Googlesource URLs must match https://code.googlesource.com/…/repo !\\n}") rpm.expand("%{error:Googlesource URLs must match https://code.googlesource.com/…/repo !\\n}")
end end
else else
explicitset("forgeurl", forgeurl) explicitset("forgeurl", forgeurl)
safeset("archiveext", "tar.gz") safeset("archiveext", "tar.gz")
safeset("forgesetupargs", "-c") safeset("forgesetupargs", "-c")
if (commit ~= "") or (tag ~= "") then if (commit ~= "") or (tag ~= "") then
safeset("scm", "git") safeset("scm", "git")
end end
local repo = string.match(forgeurl, "^[^:]+://.+/([^/?#]+)") local repo = string.match(forgeurl, "^[^:]+://.+/([^/?#]+)")
if (tag ~= "") then if (tag ~= "") then
safeset("archivename", repo .. "-%{tag}") safeset("archivename", repo .. "-%{tag}")
safeset("archiveurl", "%{forgeurl}/+archive/%{tag}.%{archiveext}") safeset("archiveurl", "%{forgeurl}/+archive/%{tag}.%{archiveext}")
else else
if (commit ~= "") then if (commit ~= "") then
safeset("archivename", repo .. "-%{commit}") safeset("archivename", repo .. "-%{commit}")
safeset("archiveurl", "%{forgeurl}/+archive/%{commit}.%{archiveext}") safeset("archiveurl", "%{forgeurl}/+archive/%{commit}.%{archiveext}")
else else
safeset("archivename", repo .. "-v%{version}") safeset("archivename", repo .. "-v%{version}")
safeset("archiveurl", "%{forgeurl}/+archive/v%{version}.%{archiveext}") safeset("archiveurl", "%{forgeurl}/+archive/v%{version}.%{archiveext}")
end end
end end
end end
end end
if (forge == "bitbucket.org") then if (forge == "bitbucket.org") then
forgeurl = string.match(forgeurl, "https://[^/]+/[^/]+/[^/#?]+") forgeurl = string.match(forgeurl, "https://[^/]+/[^/]+/[^/#?]+")
if (forgeurl == nil) then if (forgeurl == nil) then
if not silent then if not silent then
rpm.expand("%{error:BitBucket URLs must match https://bitbucket.org/owner/repo !\\n}") rpm.expand("%{error:BitBucket URLs must match https://bitbucket.org/owner/repo !\\n}")
end end
else else
explicitset("forgeurl", forgeurl) explicitset("forgeurl", forgeurl)
if (commit == "") then if (commit == "") then
rpm.expand("%{error:All BitBucket URLs require commit value knowledge: you need to define %{commit}!\\n}") rpm.expand("%{error:All BitBucket URLs require commit value knowledge: you need to define %{commit}!\\n}")
end end
local shortcommit = string.sub(commit, 1, 12) local shortcommit = string.sub(commit, 1, 12)
safeset("archiveext", "tar.bz2") safeset("archiveext", "tar.bz2")
-- Default to git even though BitBucket allows choosing between several SCMs -- Default to git even though BitBucket allows choosing between several SCMs
-- Set scm to hg for example before calling the macro if your project does not use git -- Set scm to hg for example before calling the macro if your project does not use git
safeset("scm", "git") safeset("scm", "git")
local owner = string.match(forgeurl, "^[^:]+://[^/]+/([^/]+)") local owner = string.match(forgeurl, "^[^:]+://[^/]+/([^/]+)")
local repo = string.match(forgeurl, "^[^:]+://[^/]+/[^/]+/([^/]+)") local repo = string.match(forgeurl, "^[^:]+://[^/]+/[^/]+/([^/]+)")
safeset("archivename", owner .. "-" .. repo .. "-" .. shortcommit) safeset("archivename", owner .. "-" .. repo .. "-" .. shortcommit)
safeset("forgesetupargs", "-n %{archivename}") safeset("forgesetupargs", "-n %{archivename}")
if (tag ~= "") then if (tag ~= "") then
safeset("archiveurl", "%{forgeurl}/get/%{tag}.%{archiveext}") safeset("archiveurl", "%{forgeurl}/get/%{tag}.%{archiveext}")
else else
safeset("archiveurl", "%{forgeurl}/get/%{commit}.%{archiveext}") safeset("archiveurl", "%{forgeurl}/get/%{commit}.%{archiveext}")
end end
end end
end end
if (forge == "pagure.io") then if (forge == "pagure.io") then
if not silent then if not silent then
rpm.expand("%{error:https://pagure.io/pagure/issue/861 needs to be resolved before the “pagure.io”\\nsoftware publishing service can be supported.\\n}") rpm.expand("%{error:https://pagure.io/pagure/issue/861 needs to be resolved before the “pagure.io”\\nsoftware publishing service can be supported.\\n}")
end end
end end
-- Final tests to check forgeurl was successfuly parsed -- Final tests to check forgeurl was successfuly parsed
if not silent then if not silent then
if (rpm.expand("%{?archivename}") == "") or (rpm.expand("%{?archiveurl}") == "") then if (rpm.expand("%{?archivename}") == "") or (rpm.expand("%{?archiveurl}") == "") then
rpm.expand("%{error:Automation for the “" .. forge .. "”\\nsoftware publishing service is not implemented yet.\\nPlease extend the %%forgemeta macro!\\n}") rpm.expand("%{error:Automation for the “" .. forge .. "”\\nsoftware publishing service is not implemented yet.\\nPlease extend the %%forgemeta macro!\\n}")
end end
end end
end end
end end
-- Set defaults if forgeurl is missing or does not parse -- Set defaults if forgeurl is missing or does not parse
local archivename = rpm.expand("%{?archivename}") local archivename = rpm.expand("%{?archivename}")
safeset("archiveext", "tar.gz") safeset("archiveext", "tar.gz")
if (archivename ~= "") then if (archivename ~= "") then
safeset("forgesetupargs", "-n %{archivename}") safeset("forgesetupargs", "-n %{archivename}")
end end
if (commit ~= "") or (tag ~= "") then if (commit ~= "") or (tag ~= "") then
safeset("scm", "git") safeset("scm", "git")
end end
-- Source URL processing (computing the forgesource spec variable) -- Source URL processing (computing the forgesource spec variable)
local archiveurl = rpm.expand("%{?archiveurl}") local archiveurl = rpm.expand("%{?archiveurl}")
local archiveext = rpm.expand("%{?archiveext}") local archiveext = rpm.expand("%{?archiveext}")
if (archivename ~= "") and (archiveurl ~= "") then if (archivename ~= "") and (archiveurl ~= "") then
if (string.match(archiveurl, "/([^/]+)$") == archivename .. "." .. archiveext) then if (string.match(archiveurl, "/([^/]+)$") == archivename .. "." .. archiveext) then
safeset("forgesource", "%{archiveurl}") safeset("forgesource", "%{archiveurl}")
else else
safeset("forgesource", "%{?archiveurl}#/%{?archivename}.%{archiveext}") safeset("forgesource", "%{?archiveurl}#/%{?archivename}.%{archiveext}")
end end
end end
-- dist processing (computing the correct pefix for snapshots) -- dist processing (computing the correct pefix for snapshots)
local distprefix = rpm.expand("%{?tag}") local distprefix = rpm.expand("%{?tag}")
local version = rpm.expand("%{?version}") local version = rpm.expand("%{?version}")
if (distprefix == version) or (distprefix == "v" .. version) then if (distprefix == version) or (distprefix == "v" .. version) then
distprefix = "" distprefix = ""
end end
if (distprefix == "") then if (distprefix == "") then
distprefix = string.sub(rpm.expand("%{?commit}"), 1, 7) distprefix = string.sub(rpm.expand("%{?commit}"), 1, 7)
end end
if (distprefix ~= "") then if (distprefix ~= "") then
local dist = ".%{?date}%{!?date:%([ -r %{_sourcedir}/%{archivename}.%{archiveext} ] && date +%Y%m%d -u -r %{_sourcedir}/%{archivename}.%{archiveext})}%{scm}" .. string.gsub(distprefix, "-",".") .. rpm.expand("%{?dist}") local dist = ".%{?date}%{!?date:%([ -r %{_sourcedir}/%{archivename}.%{archiveext} ] && date +%Y%m%d -u -r %{_sourcedir}/%{archivename}.%{archiveext})}%{scm}" .. string.gsub(distprefix, "-",".") .. rpm.expand("%{?dist}")
explicitset("dist", dist) explicitset("dist", dist)
end end
-- Final spec variable summary if the macro was called with -i -- Final spec variable summary if the macro was called with -i
if informative then if informative then
rpm.expand("%{echo:Forge-specific packaging variables\\n}") rpm.expand("%{echo:Forge-specific packaging variables\\n}")
rpm.expand("%{echo: forgeurl: %{?forgeurl}\\n}") rpm.expand("%{echo: forgeurl: %{?forgeurl}\\n}")
rpm.expand("%{echo: forgesource: %{?forgesource}\\n}") rpm.expand("%{echo: forgesource: %{?forgesource}\\n}")
rpm.expand("%{echo: forgesetupargs: %{?forgesetupargs}\\n}") rpm.expand("%{echo: forgesetupargs: %{?forgesetupargs}\\n}")
rpm.expand("%{echo:Generic variables\\n}") rpm.expand("%{echo:Generic variables\\n}")
rpm.expand("%{echo: archivename: %{?archivename}\\n}") rpm.expand("%{echo: archivename: %{?archivename}\\n}")
rpm.expand("%{echo: archiveext: %{?archiveext}\\n}") rpm.expand("%{echo: archiveext: %{?archiveext}\\n}")
rpm.expand("%{echo: archiveurl: %{?archiveurl}\\n}") rpm.expand("%{echo: archiveurl: %{?archiveurl}\\n}")
rpm.expand("%{echo: scm: %{?scm}\\n}") rpm.expand("%{echo: scm: %{?scm}\\n}")
rpm.expand("%{echo: tag: %{?tag}\\n}") rpm.expand("%{echo: tag: %{?tag}\\n}")
rpm.expand("%{echo: commit: %{?commit}\\n}") rpm.expand("%{echo: commit: %{?commit}\\n}")
rpm.expand("%{echo: dist: %{?dist} (snapshot date is either manually supplied or computed once %%{_sourcedir}/%%{archivename}.%%{archiveext} is available)\\n}") rpm.expand("%{echo: dist: %{?dist} (snapshot date is either manually supplied or computed once %%{_sourcedir}/%%{archivename}.%%{archiveext} is available)\\n}")
end end
} }
# Convenience macro to relay computed arguments to %setup # Convenience macro to relay computed arguments to %setup
%forgesetup(a:b:cDn:Tq) %setup %{?forgesetupargs} %{-a} %{-b} %{-c} %{-D} %{-n} %{-T} %{-q} %forgesetup(a:b:cDn:Tq) %setup %{?forgesetupargs} %{-a} %{-b} %{-c} %{-D} %{-n} %{-T} %{-q}
# Convenience macro to relay computed arguments to %autosetup # Convenience macro to relay computed arguments to %autosetup
%forgeautosetup(a:b:cDn:TvNS:p:) %autosetup %{?forgesetupargs} %{-a} %{-b} %{-c} %{-D} %{-n} %{-T} %{-v} %{-N} %{-S} %{-p} %forgeautosetup(a:b:cDn:TvNS:p:) %autosetup %{?forgesetupargs} %{-a} %{-b} %{-c} %{-D} %{-n} %{-T} %{-v} %{-N} %{-S} %{-p}

340
macros.go
View File

@ -1,170 +1,170 @@
# Copyright (c) 2015-2018 Jakub Cajka <jcajka@redhat.com>, # Copyright (c) 2015-2018 Jakub Cajka <jcajka@redhat.com>,
# Jan Chaloupka <jchaloup@redhat.com>, # Jan Chaloupka <jchaloup@redhat.com>,
# Nicolas Mailhot <nim@fedoraproject.org> # Nicolas Mailhot <nim@fedoraproject.org>
# This file is distributed under the terms of GNU GPL license version 3, or # This file is distributed under the terms of GNU GPL license version 3, or
# any later version. # any later version.
# This file contains macros for building projects in golang for packages # This file contains macros for building projects in golang for packages
# with golang compiler or gcc-go compiler based on an architecture. # with golang compiler or gcc-go compiler based on an architecture.
# Golang is primarly for primary architectures, gcc-go for secondary. # Golang is primarly for primary architectures, gcc-go for secondary.
# #
# This file provides only macros and must not use any other package except # This file provides only macros and must not use any other package except
# redhat-rpm-macros. # redhat-rpm-macros.
# Define arches for PA and SA # Define arches for PA and SA
%golang_arches %{ix86} x86_64 %{arm} aarch64 ppc64le s390x %golang_arches %{ix86} x86_64 %{arm} aarch64 ppc64le s390x
%gccgo_arches %{mips} %gccgo_arches %{mips}
%go_arches %{golang_arches} %{gccgo_arches} %go_arches %{golang_arches} %{gccgo_arches}
# Where to set GOPATH for builds # Where to set GOPATH for builds
%gopath %{_datadir}/gocode %gopath %{_datadir}/gocode
# Define go_compilers macro to signal go-compiler package is available # Define go_compilers macro to signal go-compiler package is available
%go_compiler 1 %go_compiler 1
# Sanitize a Go import path that can then serve as rpm package name # Sanitize a Go import path that can then serve as rpm package name
# Mandatory parameter: a Go import path # Mandatory parameter: a Go import path
%gorpmname() %{lua: %gorpmname() %{lua:
local goname = rpm.expand("%1") local goname = rpm.expand("%1")
-- lowercase and end with '/' -- lowercase and end with '/'
goname = string.lower(goname .. "/") goname = string.lower(goname .. "/")
-- remove eventual protocol prefix -- remove eventual protocol prefix
goname = string.gsub(goname, "^http(s?)://", "") goname = string.gsub(goname, "^http(s?)://", "")
-- remove eventual .git suffix -- remove eventual .git suffix
goname = string.gsub(goname, "%.git/*", "") goname = string.gsub(goname, "%.git/*", "")
-- remove eventual git. prefix -- remove eventual git. prefix
goname = string.gsub(goname, "^git%.", "") goname = string.gsub(goname, "^git%.", "")
-- add golang prefix -- add golang prefix
goname = "golang-" .. goname goname = "golang-" .. goname
-- remove FQDN root (.com, .org, etc) -- remove FQDN root (.com, .org, etc)
goname = string.gsub(goname, "^([^/]+)%.([^%./]+)/", "%1/") goname = string.gsub(goname, "^([^/]+)%.([^%./]+)/", "%1/")
-- special-case x.y.z number-strings as thats an exception in our naming -- special-case x.y.z number-strings as thats an exception in our naming
-- guidelines -- guidelines
repeat repeat
goname, i = string.gsub(goname, "(%d)%.(%d)", "%1:%2") goname, i = string.gsub(goname, "(%d)%.(%d)", "%1:%2")
until i == 0 until i == 0
-- replace various separators rpm does not like with - -- replace various separators rpm does not like with -
goname = string.gsub(goname, "[%._/%-]+", "-") goname = string.gsub(goname, "[%._/%-]+", "-")
-- because of the Azure sdk -- because of the Azure sdk
goname = string.gsub(goname, "%-for%-go%-", "-") goname = string.gsub(goname, "%-for%-go%-", "-")
-- Tokenize along - separators and remove duplicates to avoid -- Tokenize along - separators and remove duplicates to avoid
-- golang-foo-foo-bar-foo names -- golang-foo-foo-bar-foo names
local result = "" local result = ""
local tokens = {} local tokens = {}
tokens["go"] = true tokens["go"] = true
for token in string.gmatch(goname, "[^%-]+") do for token in string.gmatch(goname, "[^%-]+") do
if not tokens[token] then if not tokens[token] then
result = result .. "-" .. token result = result .. "-" .. token
tokens[token] = true tokens[token] = true
end end
end end
-- reassemble the string, restore x.y.z runs, convert the vx.y.z -- reassemble the string, restore x.y.z runs, convert the vx.y.z
-- Go convention to x.y.z as prefered in rpm naming -- Go convention to x.y.z as prefered in rpm naming
result = string.gsub(result, "^-", "") result = string.gsub(result, "^-", "")
result = string.gsub(result, ":", ".") result = string.gsub(result, ":", ".")
-- some projects have a name that end up in a number, and *also* add release -- some projects have a name that end up in a number, and *also* add release
-- numbers on top of it, keep a - prefix before version strings -- numbers on top of it, keep a - prefix before version strings
result = string.gsub(result, "%-v([%.%d])", "-%1") result = string.gsub(result, "%-v([%.%d])", "-%1")
print(result) print(result)
} }
# Map Go information to rpm metadata. This macro will compute default spec # Map Go information to rpm metadata. This macro will compute default spec
# variable values. # variable values.
# #
# The following spec variable MUST be set before calling the macro: # The following spec variable MUST be set before calling the macro:
# #
# goipath the packaged Go project import path # goipath the packaged Go project import path
# #
# The following spec variables SHOULD be set before calling the macro: # The following spec variables SHOULD be set before calling the macro:
# #
# forgeurl the project url on the forge, strongly recommended, if it can not # forgeurl the project url on the forge, strongly recommended, if it can not
# be deduced from goipath; alternatively, use -u <url> # be deduced from goipath; alternatively, use -u <url>
# Version if applicable, set it with Version: <version> # Version if applicable, set it with Version: <version>
# tag if applicable # tag if applicable
# commit if applicable # commit if applicable
# #
# The macro will attempt to compute and set the following variables if they are # The macro will attempt to compute and set the following variables if they are
# not already set by the packager: # not already set by the packager:
# #
# goname an rpm-compatible package name derived from goipath # goname an rpm-compatible package name derived from goipath
# gosource an URL that can be used as SourceX: value # gosource an URL that can be used as SourceX: value
# gourl an URL that can be used as URL: value # gourl an URL that can be used as URL: value
# #
# It will delegate processing to the forgemeta macro for: # It will delegate processing to the forgemeta macro for:
# #
# forgesource an URL that can be used as SourceX: value # forgesource an URL that can be used as SourceX: value
# forgesetupargs the correct arguments to pass to %setup for this source # forgesetupargs the correct arguments to pass to %setup for this source
# used by %forgesetup and %forgeautosetup # used by %forgesetup and %forgeautosetup
# archivename the source archive filename, without extentions # archivename the source archive filename, without extentions
# archiveext the source archive filename extensions, without leading dot # archiveext the source archive filename extensions, without leading dot
# archiveurl the url that can be used to download the source archive, # archiveurl the url that can be used to download the source archive,
# without renaming # without renaming
# scm the scm type, when packaging code snapshots: commits or tags # scm the scm type, when packaging code snapshots: commits or tags
# #
# If the macro is unable to parse your forgeurl value set at least archivename # If the macro is unable to parse your forgeurl value set at least archivename
# and archiveurl before calling it. # and archiveurl before calling it.
# #
# Most of the computed variables are both overridable and optional. However, # Most of the computed variables are both overridable and optional. However,
# the macro WILL REDEFINE %{dist} when packaging a snapshot (commit or tag). # the macro WILL REDEFINE %{dist} when packaging a snapshot (commit or tag).
# The previous %{dist} value will be lost. Dont call the macro if you dont # The previous %{dist} value will be lost. Dont call the macro if you dont
# wish %{dist} to be changed. # wish %{dist} to be changed.
# #
# Optional parameters: # Optional parameters:
# -u <url> Ignore forgeurl even if it exists and use <url> instead. Note # -u <url> Ignore forgeurl even if it exists and use <url> instead. Note
# that the macro will still end up setting <url> as the forgeurl # that the macro will still end up setting <url> as the forgeurl
# spec variable if it manages to parse it. # spec variable if it manages to parse it.
# -s Silently ignore problems in forgeurl, use it if it can be parsed, # -s Silently ignore problems in forgeurl, use it if it can be parsed,
# ignore it otherwise. # ignore it otherwise.
# -p Restore problem handling, override -s. # -p Restore problem handling, override -s.
# -v Be verbose and print every spec variable the macro sets. # -v Be verbose and print every spec variable the macro sets.
# -i Print some info about the state of spec variables the macro may use or # -i Print some info about the state of spec variables the macro may use or
# set at the end of the processing. # set at the end of the processing.
%gometa(u:spvi) %{expand:%{lua: %gometa(u:spvi) %{expand:%{lua:
local forgeurl = rpm.expand("%{?-u*}") local forgeurl = rpm.expand("%{?-u*}")
if (forgeurl == "") then if (forgeurl == "") then
forgeurl = rpm.expand("%{?forgeurl}") forgeurl = rpm.expand("%{?forgeurl}")
end end
-- Be explicit about the spec variables were setting -- Be explicit about the spec variables were setting
local function explicitset(rpmvariable,value) local function explicitset(rpmvariable,value)
rpm.define(rpmvariable .. " " .. value) rpm.define(rpmvariable .. " " .. value)
if (rpm.expand("%{?-v}") ~= "") then if (rpm.expand("%{?-v}") ~= "") then
rpm.expand("%{echo:Setting %%{" .. rpmvariable .. "} = " .. value .. "\\n}") rpm.expand("%{echo:Setting %%{" .. rpmvariable .. "} = " .. value .. "\\n}")
end end
end end
-- Never ever stomp on a spec variable the packager already set -- Never ever stomp on a spec variable the packager already set
local function safeset(rpmvariable,value) local function safeset(rpmvariable,value)
if (rpm.expand("%{?" .. rpmvariable .. "}") == "") then if (rpm.expand("%{?" .. rpmvariable .. "}") == "") then
explicitset(rpmvariable,value) explicitset(rpmvariable,value)
end end
end end
-- All the Go packaging automation relies on goipath being set -- All the Go packaging automation relies on goipath being set
local goipath = rpm.expand("%{?goipath}") local goipath = rpm.expand("%{?goipath}")
if (goipath == "") then if (goipath == "") then
rpm.expand("%{error:Please set the Go import path in the “goipath” variable before calling “gometa”!}") rpm.expand("%{error:Please set the Go import path in the “goipath” variable before calling “gometa”!}")
end end
-- Compute and set spec variables -- Compute and set spec variables
if (forgeurl ~= "") then if (forgeurl ~= "") then
rpm.expand("%forgemeta %{?-v} %{?-i} %{?-s} %{?-p} -u " .. forgeurl .. "\\n") rpm.expand("%forgemeta %{?-v} %{?-i} %{?-s} %{?-p} -u " .. forgeurl .. "\\n")
safeset("gourl", forgeurl) safeset("gourl", forgeurl)
else else
safeset("gourl", "https://" .. goipath) safeset("gourl", "https://" .. goipath)
rpm.expand("%forgemeta %{?-v} %{?-i} -s %{?-p} -u %{gourl}\\n") rpm.expand("%forgemeta %{?-v} %{?-i} -s %{?-p} -u %{gourl}\\n")
end end
if (rpm.expand("%{?forgesource}") ~= "") then if (rpm.expand("%{?forgesource}") ~= "") then
safeset("gosource", "%{forgesource}") safeset("gosource", "%{forgesource}")
else else
safeset("gosource", "%{gourl}/%{archivename}.%{archiveext}") safeset("gosource", "%{gourl}/%{archivename}.%{archiveext}")
end end
safeset("goname", "%gorpmname %{goipath}") safeset("goname", "%gorpmname %{goipath}")
rpm.define("gosetup %forgesetup") rpm.define("gosetup %forgesetup")
-- Final spec variable summary if the macro was called with -i -- Final spec variable summary if the macro was called with -i
if (rpm.expand("%{?-i}") ~= "") then if (rpm.expand("%{?-i}") ~= "") then
rpm.expand("%{echo:Go-specific packaging variables}") rpm.expand("%{echo:Go-specific packaging variables}")
rpm.expand("%{echo: goipath: %{?goipath}}") rpm.expand("%{echo: goipath: %{?goipath}}")
rpm.expand("%{echo: goname: %{?goname}}") rpm.expand("%{echo: goname: %{?goname}}")
rpm.expand("%{echo: gourl: %{?gourl}}") rpm.expand("%{echo: gourl: %{?gourl}}")
rpm.expand("%{echo: gosource: %{?gosource}}") rpm.expand("%{echo: gosource: %{?gosource}}")
end} end}
BuildRequires: compiler(go-compiler) BuildRequires: compiler(go-compiler)
ExclusiveArch: %{go_arches} ExclusiveArch: %{go_arches}
} }