commit
fe0e75ab5c
3644
config.sub
vendored
3644
config.sub
vendored
File diff suppressed because it is too large
Load Diff
@ -2,7 +2,7 @@
|
||||
|
||||
Name: %{vendor}-rpm-config
|
||||
Version: 30
|
||||
Release: 2
|
||||
Release: 3
|
||||
License: GPL+
|
||||
Summary: specific rpm configuration files
|
||||
URL: https://gitee.com/src-openeuler/openEuler-rpm-config
|
||||
@ -104,6 +104,12 @@ mkdir -p %{buildroot}%{_fileattrsdir}
|
||||
%{_rpmconfigdir}/macros.d/*
|
||||
|
||||
%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
|
||||
- Type:enhancement
|
||||
- ID:NA
|
||||
|
||||
588
macros
588
macros
@ -1,294 +1,294 @@
|
||||
# Per-platform rpm configuration file.
|
||||
|
||||
%_vendor %{?_vendor:%{_vendor}}%{!?_vendor:openEuler}
|
||||
%_os linux
|
||||
%_target_platform %{_target_cpu}-%{_vendor}-%{_target_os}%{?_gnu}
|
||||
|
||||
#==============================================================================
|
||||
# ---- configure macros. note that most of these are inherited
|
||||
# from the defaults.
|
||||
#
|
||||
%_localstatedir /var
|
||||
|
||||
%_pkgdocdir %{_docdir}/%{name}
|
||||
%_docdir_fmt %%{NAME}
|
||||
|
||||
%_fmoddir %{_libdir}/gfortran/modules
|
||||
|
||||
%_enable_debug_packages 1
|
||||
#%_include_minidebuginfo 1
|
||||
%_include_gdb_index 1
|
||||
%_debugsource_packages 1
|
||||
#%_debuginfo_subpackages 1
|
||||
|
||||
#==============================================================================
|
||||
# ---- compiler flags.
|
||||
|
||||
%build_cflags %{optflags}
|
||||
%build_cxxflags %{optflags}
|
||||
%build_fflags %{optflags} -I%{_fmoddir}
|
||||
%build_ldflags -Wl,-z,relro %{_ld_as_needed_flags} %{_ld_symbols_flags} %{_hardened_ldflags}
|
||||
|
||||
%set_build_flags \
|
||||
CFLAGS="${CFLAGS:-%{build_cflags}}" ; export CFLAGS ; \
|
||||
CXXFLAGS="${CXXFLAGS:-%{build_cxxflags}}" ; export CXXFLAGS ; \
|
||||
FFLAGS="${FFLAGS:-%{build_fflags}}" ; export FFLAGS ; \
|
||||
FCFLAGS="${FCFLAGS:-%{build_fflags}}" ; export FCFLAGS ; \
|
||||
LDFLAGS="${LDFLAGS:-%{build_ldflags}}" ; export LDFLAGS
|
||||
|
||||
#For backwards compatibility only.
|
||||
%__global_cflags %{build_cflags}
|
||||
%__global_cxxflags %{build_cxxflags}
|
||||
%__global_fflags %{build_fflags}
|
||||
%__global_fcflags %{build_fflags}
|
||||
%__global_ldflags %{build_ldflags}
|
||||
|
||||
#==============================================================================
|
||||
# ---- configure and makeinstall.
|
||||
%_configure_gnuconfig_hack 1
|
||||
%_configure_libtool_hardening_hack 1
|
||||
%configure \
|
||||
%{set_build_flags}; \
|
||||
[ "%_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 ; \
|
||||
done ; \
|
||||
[ "%_configure_libtool_hardening_hack" = 1 ] && [ x != "x%{_hardened_ldflags}" ] && \
|
||||
for i in $(find . -name ltmain.sh) ; do \
|
||||
%{__sed} -i.backup -e 's~compiler_flags=$~compiler_flags="%{_hardened_ldflags}"~' $i \
|
||||
done ; \
|
||||
%{_configure} --build=%{_build} --host=%{_host} \\\
|
||||
--program-prefix=%{?_program_prefix} \\\
|
||||
--disable-dependency-tracking \\\
|
||||
%{?_configure_disable_silent_rules:--disable-silent-rules} \\\
|
||||
--prefix=%{_prefix} \\\
|
||||
--exec-prefix=%{_exec_prefix} \\\
|
||||
--bindir=%{_bindir} \\\
|
||||
--sbindir=%{_sbindir} \\\
|
||||
--sysconfdir=%{_sysconfdir} \\\
|
||||
--datadir=%{_datadir} \\\
|
||||
--includedir=%{_includedir} \\\
|
||||
--libdir=%{_libdir} \\\
|
||||
--libexecdir=%{_libexecdir} \\\
|
||||
--localstatedir=%{_localstatedir} \\\
|
||||
--sharedstatedir=%{_sharedstatedir} \\\
|
||||
--mandir=%{_mandir} \\\
|
||||
--infodir=%{_infodir}
|
||||
|
||||
# ---- Build policy macros.
|
||||
|
||||
%__spec_install_pre %{___build_pre}\
|
||||
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf "${RPM_BUILD_ROOT}"\
|
||||
mkdir -p `dirname "$RPM_BUILD_ROOT"`\
|
||||
mkdir "$RPM_BUILD_ROOT"\
|
||||
%{nil}
|
||||
|
||||
# ---- Expanded at end of %install scriptlet.
|
||||
%__arch_install_post /usr/lib/rpm/check-buildroot
|
||||
|
||||
# Build root policy macros. Standard naming:
|
||||
# convert all '-' in basename to '_', add two leading underscores.
|
||||
%__brp_ldconfig /usr/lib/rpm/openEuler/brp-ldconfig
|
||||
%__brp_compress /usr/lib/rpm/brp-compress
|
||||
%__brp_strip /usr/lib/rpm/brp-strip %{__strip}
|
||||
%__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_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
|
||||
|
||||
%__os_install_post \
|
||||
%{?__brp_ldconfig} \
|
||||
%{?__brp_compress} \
|
||||
%{!?__debug_package:\
|
||||
%{?__brp_strip} \
|
||||
%{?__brp_strip_comment_note} \
|
||||
} \
|
||||
%{?__brp_strip_static_archive} \
|
||||
%{?py_auto_byte_compile:%{?__brp_python_bytecompile}} \
|
||||
%{?__brp_python_hardlink} \
|
||||
%{nil}
|
||||
|
||||
%__spec_install_post\
|
||||
%{?__debug_package:%{__debug_install_post}}\
|
||||
%{__arch_install_post}\
|
||||
%{__os_install_post}\
|
||||
%{nil}
|
||||
|
||||
%install %{?_enable_debug_packages:%{?buildsubdir:%{debug_package}}}\
|
||||
%%install\
|
||||
%{nil}
|
||||
|
||||
#
|
||||
# Should missing buildids terminate a build?
|
||||
%_missing_build_ids_terminate_build 1
|
||||
|
||||
#
|
||||
## Automatically compile python files
|
||||
%py_auto_byte_compile 1
|
||||
|
||||
#
|
||||
## Should python bytecompilation errors terminate a build?
|
||||
%_python_bytecompile_errors_terminate_build 1
|
||||
## Should python bytecompilation compile outisde python specific directories?
|
||||
%_python_bytecompile_extra 1
|
||||
|
||||
# Use SHA-256 for FILEDIGESTS instead of default MD5
|
||||
%_source_filedigest_algorithm 8
|
||||
%_binary_filedigest_algorithm 8
|
||||
|
||||
# Use XZ compression for binary payloads
|
||||
%_binary_payload w2.xzdio
|
||||
|
||||
|
||||
# secure options for rpmbuild
|
||||
#
|
||||
# #hardened options
|
||||
%_hardening_cflags -specs=/usr/lib/rpm/%{_vendor}/openEuler-hardened-cc1
|
||||
%_hardening_ldflags -Wl,-z,now -specs=/usr/lib/rpm/%{_vendor}/openEuler-hardened-ld
|
||||
# Use "%undefine _hardened_build" to disable.
|
||||
%_hardened_build 1
|
||||
%_hardened_cflags %{?_hardened_build:%{_hardening_cflags}}
|
||||
%_hardened_ldflags %{?_hardened_build:%{_hardening_ldflags}}
|
||||
|
||||
#secure options pie
|
||||
%_sec_opt_build 1
|
||||
#Use "%undefine _sec_opt_build" to disable.
|
||||
#Use "%undefine _pie_build" to disable.
|
||||
%_pie_build 1
|
||||
%_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_cflags %{?_sec_opt_build:?_pie_build:%{_pie_pre_cflags}}
|
||||
%_pie_ldflags %{?_sec_opt_build:?_pie_build:%{_pie_pre_ldflags}}
|
||||
|
||||
#Use "%undefine _fs_build" to disable.
|
||||
%_fs_build 1
|
||||
%_fs_pre_cflags -specs=/usr/lib/rpm/%{_vendor}/openEuler-fs-cc1
|
||||
%_fs_cflags %{?_fs_build:%{_fs_pre_cflags}}
|
||||
|
||||
|
||||
# Fail linking if there are undefined symbols. Required for proper
|
||||
# ELF symbol versioning support. Disabled by default.
|
||||
# Use "%define _ld_strict_symbol_defs 1" to enable.
|
||||
#%_ld_strict_symbol_defs 1
|
||||
%_ld_symbols_flags %{?_ld_strict_symbol_defs:-Wl,-z,defs}
|
||||
|
||||
# use "%define _ld_as_needed 1" to enable.
|
||||
#%_ld_as_needed 1
|
||||
%_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}
|
||||
|
||||
# Automatically trim changelog entries after 2 years
|
||||
%_changelog_trimtime %{lua:print(os.time() - 2 * 365 * 86400)}
|
||||
|
||||
#==============================================================================
|
||||
# ---- Generic auto req/prov filtering macros
|
||||
|
||||
# prevent anything matching from being scanned for provides
|
||||
%filter_provides_in(P) %{expand: \
|
||||
%global __filter_prov_cmd %{?__filter_prov_cmd} %{__grep} -v %{-P} '%*' | \
|
||||
}
|
||||
|
||||
# prevent anything matching from being scanned for requires
|
||||
%filter_requires_in(P) %{expand: \
|
||||
%global __filter_req_cmd %{?__filter_req_cmd} %{__grep} -v %{-P} '%*' | \
|
||||
}
|
||||
|
||||
# filter anything matching out of the provides stream
|
||||
%filter_from_provides() %{expand: \
|
||||
%global __filter_from_prov %{?__filter_from_prov} | %{__sed} -e '%*' \
|
||||
}
|
||||
|
||||
# filter anything matching out of the requires stream
|
||||
%filter_from_requires() %{expand: \
|
||||
%global __filter_from_req %{?__filter_from_req} | %{__sed} -e '%*' \
|
||||
}
|
||||
|
||||
# actually set up the filtering bits
|
||||
%filter_setup %{expand: \
|
||||
%global _use_internal_dependency_generator 0 \
|
||||
%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_requires /bin/sh -c "%{?__filter_req_cmd} %{__deploop R} %{?__filter_from_req}" \
|
||||
}
|
||||
|
||||
# compare two versions, returns -1, 0, 1, ~~~
|
||||
%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
|
||||
%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, ~~~
|
||||
%pkg_version_cmp() %{expand:%{expand:%%%%{rpm_vercmp %%{pkg_version %1} %%2}}}
|
||||
# convenience/readability
|
||||
%pkg_vcmp() (%{expand:%%{pkg_version_cmp %1 %3}} %2 0)
|
||||
|
||||
#arches macros
|
||||
%generic_arches %{ix86} x86_64 %{arm} aarch64
|
||||
%ldc_arches %{generic_arches}
|
||||
%valgrind_arches %{generic_arches}
|
||||
%nodejs_arches %{generic_arches}
|
||||
%ldc_arches %{generic_arches}
|
||||
%mono_arches %{generic_arches}
|
||||
%fpc_arches %{generic_arches}
|
||||
%ghc_arches_with_ghci %{generic_arches}
|
||||
%ghc_arches %{generic_arches}
|
||||
%GNAT_arches %{GPRbuild_arches} %{generic_arches}
|
||||
%GPRbuild_arches %{generic_arches}
|
||||
%nim_arches %{generic_arches}
|
||||
%nodejs_arches %{generic_arches}
|
||||
%ocaml_native_compiler %{generic_arches}
|
||||
%ocaml_natdynlink %{generic_arches}
|
||||
%ocaml_native_profiling %{generic_arches}
|
||||
%openblas_arches %{generic_arches}
|
||||
|
||||
#%ldconfig /sbin/ldconfig
|
||||
%ldconfig_post(n:) %{?ldconfig:%post -p %ldconfig %{?*} %{-n:-n %{-n*}}\
|
||||
%end}
|
||||
%ldconfig_postun(n:) %{?ldconfig:%postun -p %ldconfig %{?*} %{-n:-n %{-n*}}\
|
||||
%end}
|
||||
%ldconfig_scriptlets(n:) %{?ldconfig:\
|
||||
%ldconfig_post %{?*} %{-n:-n %{-n*}}\
|
||||
%ldconfig_postun %{?*} %{-n:-n %{-n*}}\
|
||||
}
|
||||
|
||||
# Some miscellaneous macros
|
||||
%_metainfodir %{_datadir}/metainfo
|
||||
%rpmmacrodir /usr/lib/rpm/macros.d
|
||||
|
||||
# arches that mono builds on
|
||||
%_monogacdir %{_monodir}/gac
|
||||
%_monodir %{_prefix}/lib/mono
|
||||
|
||||
# ---- VPATH default settings
|
||||
%_vpath_builddir %_target_platform
|
||||
%_vpath_srcdir .
|
||||
|
||||
|
||||
# ---- custom macros
|
||||
%disable_rpath \
|
||||
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
|
||||
|
||||
%delete_la_and_a \
|
||||
find $RPM_BUILD_ROOT -type f -name "*.la" -delete \
|
||||
find $RPM_BUILD_ROOT -type f -name "*.a" -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 {}
|
||||
|
||||
%package_help \
|
||||
%package help \
|
||||
Summary: Documents for %{name} \
|
||||
Buildarch: noarch \
|
||||
Requires: man info \
|
||||
\
|
||||
%description help \
|
||||
Man pages and other related documents for %{name}.
|
||||
|
||||
#%sbin_installinfo_rm bc.info
|
||||
#%sbin_installinfo_rm bc.info.gz
|
||||
|
||||
%install_info() \
|
||||
/sbin/install-info %1 %{_infodir}/dir || :
|
||||
|
||||
%install_info_rm() \
|
||||
/sbin/install-info --remove %1 %{_infodir}/dir || :
|
||||
# Per-platform rpm configuration file.
|
||||
|
||||
%_vendor %{?_vendor:%{_vendor}}%{!?_vendor:openEuler}
|
||||
%_os linux
|
||||
%_target_platform %{_target_cpu}-%{_vendor}-%{_target_os}%{?_gnu}
|
||||
|
||||
#==============================================================================
|
||||
# ---- configure macros. note that most of these are inherited
|
||||
# from the defaults.
|
||||
#
|
||||
%_localstatedir /var
|
||||
|
||||
%_pkgdocdir %{_docdir}/%{name}
|
||||
%_docdir_fmt %%{NAME}
|
||||
|
||||
%_fmoddir %{_libdir}/gfortran/modules
|
||||
|
||||
%_enable_debug_packages 1
|
||||
#%_include_minidebuginfo 1
|
||||
%_include_gdb_index 1
|
||||
%_debugsource_packages 1
|
||||
#%_debuginfo_subpackages 1
|
||||
|
||||
#==============================================================================
|
||||
# ---- compiler flags.
|
||||
|
||||
%build_cflags %{optflags}
|
||||
%build_cxxflags %{optflags}
|
||||
%build_fflags %{optflags} -I%{_fmoddir}
|
||||
%build_ldflags -Wl,-z,relro %{_ld_as_needed_flags} %{_ld_symbols_flags} %{_hardened_ldflags}
|
||||
|
||||
%set_build_flags \
|
||||
CFLAGS="${CFLAGS:-%{build_cflags}}" ; export CFLAGS ; \
|
||||
CXXFLAGS="${CXXFLAGS:-%{build_cxxflags}}" ; export CXXFLAGS ; \
|
||||
FFLAGS="${FFLAGS:-%{build_fflags}}" ; export FFLAGS ; \
|
||||
FCFLAGS="${FCFLAGS:-%{build_fflags}}" ; export FCFLAGS ; \
|
||||
LDFLAGS="${LDFLAGS:-%{build_ldflags}}" ; export LDFLAGS
|
||||
|
||||
#For backwards compatibility only.
|
||||
%__global_cflags %{build_cflags}
|
||||
%__global_cxxflags %{build_cxxflags}
|
||||
%__global_fflags %{build_fflags}
|
||||
%__global_fcflags %{build_fflags}
|
||||
%__global_ldflags %{build_ldflags}
|
||||
|
||||
#==============================================================================
|
||||
# ---- configure and makeinstall.
|
||||
%_configure_gnuconfig_hack 1
|
||||
%_configure_libtool_hardening_hack 1
|
||||
%configure \
|
||||
%{set_build_flags}; \
|
||||
[ "%_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 ; \
|
||||
done ; \
|
||||
[ "%_configure_libtool_hardening_hack" = 1 ] && [ x != "x%{_hardened_ldflags}" ] && \
|
||||
for i in $(find . -name ltmain.sh) ; do \
|
||||
%{__sed} -i.backup -e 's~compiler_flags=$~compiler_flags="%{_hardened_ldflags}"~' $i \
|
||||
done ; \
|
||||
%{_configure} --build=%{_build} --host=%{_host} \\\
|
||||
--program-prefix=%{?_program_prefix} \\\
|
||||
--disable-dependency-tracking \\\
|
||||
%{?_configure_disable_silent_rules:--disable-silent-rules} \\\
|
||||
--prefix=%{_prefix} \\\
|
||||
--exec-prefix=%{_exec_prefix} \\\
|
||||
--bindir=%{_bindir} \\\
|
||||
--sbindir=%{_sbindir} \\\
|
||||
--sysconfdir=%{_sysconfdir} \\\
|
||||
--datadir=%{_datadir} \\\
|
||||
--includedir=%{_includedir} \\\
|
||||
--libdir=%{_libdir} \\\
|
||||
--libexecdir=%{_libexecdir} \\\
|
||||
--localstatedir=%{_localstatedir} \\\
|
||||
--sharedstatedir=%{_sharedstatedir} \\\
|
||||
--mandir=%{_mandir} \\\
|
||||
--infodir=%{_infodir}
|
||||
|
||||
# ---- Build policy macros.
|
||||
|
||||
%__spec_install_pre %{___build_pre}\
|
||||
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf "${RPM_BUILD_ROOT}"\
|
||||
mkdir -p `dirname "$RPM_BUILD_ROOT"`\
|
||||
mkdir "$RPM_BUILD_ROOT"\
|
||||
%{nil}
|
||||
|
||||
# ---- Expanded at end of %install scriptlet.
|
||||
%__arch_install_post /usr/lib/rpm/check-buildroot
|
||||
|
||||
# Build root policy macros. Standard naming:
|
||||
# convert all '-' in basename to '_', add two leading underscores.
|
||||
%__brp_ldconfig /usr/lib/rpm/openEuler/brp-ldconfig
|
||||
%__brp_compress /usr/lib/rpm/brp-compress
|
||||
%__brp_strip /usr/lib/rpm/brp-strip %{__strip}
|
||||
%__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_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
|
||||
|
||||
%__os_install_post \
|
||||
%{?__brp_ldconfig} \
|
||||
%{?__brp_compress} \
|
||||
%{!?__debug_package:\
|
||||
%{?__brp_strip} \
|
||||
%{?__brp_strip_comment_note} \
|
||||
} \
|
||||
%{?__brp_strip_static_archive} \
|
||||
%{?py_auto_byte_compile:%{?__brp_python_bytecompile}} \
|
||||
%{?__brp_python_hardlink} \
|
||||
%{nil}
|
||||
|
||||
%__spec_install_post\
|
||||
%{?__debug_package:%{__debug_install_post}}\
|
||||
%{__arch_install_post}\
|
||||
%{__os_install_post}\
|
||||
%{nil}
|
||||
|
||||
%install %{?_enable_debug_packages:%{?buildsubdir:%{debug_package}}}\
|
||||
%%install\
|
||||
%{nil}
|
||||
|
||||
#
|
||||
# Should missing buildids terminate a build?
|
||||
%_missing_build_ids_terminate_build 1
|
||||
|
||||
#
|
||||
## Automatically compile python files
|
||||
%py_auto_byte_compile 1
|
||||
|
||||
#
|
||||
## Should python bytecompilation errors terminate a build?
|
||||
%_python_bytecompile_errors_terminate_build 1
|
||||
## Should python bytecompilation compile outisde python specific directories?
|
||||
%_python_bytecompile_extra 1
|
||||
|
||||
# Use SHA-256 for FILEDIGESTS instead of default MD5
|
||||
%_source_filedigest_algorithm 8
|
||||
%_binary_filedigest_algorithm 8
|
||||
|
||||
# Use XZ compression for binary payloads
|
||||
%_binary_payload w2.xzdio
|
||||
|
||||
|
||||
# secure options for rpmbuild
|
||||
#
|
||||
# #hardened options
|
||||
%_hardening_cflags -specs=/usr/lib/rpm/%{_vendor}/openEuler-hardened-cc1
|
||||
%_hardening_ldflags -Wl,-z,now -specs=/usr/lib/rpm/%{_vendor}/openEuler-hardened-ld
|
||||
# Use "%undefine _hardened_build" to disable.
|
||||
%_hardened_build 1
|
||||
%_hardened_cflags %{?_hardened_build:%{_hardening_cflags}}
|
||||
%_hardened_ldflags %{?_hardened_build:%{_hardening_ldflags}}
|
||||
|
||||
#secure options pie
|
||||
%_sec_opt_build 1
|
||||
#Use "%undefine _sec_opt_build" to disable.
|
||||
#Use "%undefine _pie_build" to disable.
|
||||
%_pie_build 1
|
||||
%_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_cflags %{?_sec_opt_build:?_pie_build:%{_pie_pre_cflags}}
|
||||
%_pie_ldflags %{?_sec_opt_build:?_pie_build:%{_pie_pre_ldflags}}
|
||||
|
||||
#Use "%undefine _fs_build" to disable.
|
||||
%_fs_build 1
|
||||
%_fs_pre_cflags -specs=/usr/lib/rpm/%{_vendor}/openEuler-fs-cc1
|
||||
%_fs_cflags %{?_fs_build:%{_fs_pre_cflags}}
|
||||
|
||||
|
||||
# Fail linking if there are undefined symbols. Required for proper
|
||||
# ELF symbol versioning support. Disabled by default.
|
||||
# Use "%define _ld_strict_symbol_defs 1" to enable.
|
||||
#%_ld_strict_symbol_defs 1
|
||||
%_ld_symbols_flags %{?_ld_strict_symbol_defs:-Wl,-z,defs}
|
||||
|
||||
# use "%define _ld_as_needed 1" to enable.
|
||||
#%_ld_as_needed 1
|
||||
%_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}
|
||||
|
||||
# Automatically trim changelog entries after 2 years
|
||||
%_changelog_trimtime %{lua:print(os.time() - 2 * 365 * 86400)}
|
||||
|
||||
#==============================================================================
|
||||
# ---- Generic auto req/prov filtering macros
|
||||
|
||||
# prevent anything matching from being scanned for provides
|
||||
%filter_provides_in(P) %{expand: \
|
||||
%global __filter_prov_cmd %{?__filter_prov_cmd} %{__grep} -v %{-P} '%*' | \
|
||||
}
|
||||
|
||||
# prevent anything matching from being scanned for requires
|
||||
%filter_requires_in(P) %{expand: \
|
||||
%global __filter_req_cmd %{?__filter_req_cmd} %{__grep} -v %{-P} '%*' | \
|
||||
}
|
||||
|
||||
# filter anything matching out of the provides stream
|
||||
%filter_from_provides() %{expand: \
|
||||
%global __filter_from_prov %{?__filter_from_prov} | %{__sed} -e '%*' \
|
||||
}
|
||||
|
||||
# filter anything matching out of the requires stream
|
||||
%filter_from_requires() %{expand: \
|
||||
%global __filter_from_req %{?__filter_from_req} | %{__sed} -e '%*' \
|
||||
}
|
||||
|
||||
# actually set up the filtering bits
|
||||
%filter_setup %{expand: \
|
||||
%global _use_internal_dependency_generator 0 \
|
||||
%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_requires /bin/sh -c "%{?__filter_req_cmd} %{__deploop R} %{?__filter_from_req}" \
|
||||
}
|
||||
|
||||
# compare two versions, returns -1, 0, 1, ~~~
|
||||
%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
|
||||
%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, ~~~
|
||||
%pkg_version_cmp() %{expand:%{expand:%%%%{rpm_vercmp %%{pkg_version %1} %%2}}}
|
||||
# convenience/readability
|
||||
%pkg_vcmp() (%{expand:%%{pkg_version_cmp %1 %3}} %2 0)
|
||||
|
||||
#arches macros
|
||||
%generic_arches %{ix86} x86_64 %{arm} aarch64
|
||||
%ldc_arches %{generic_arches}
|
||||
%valgrind_arches %{generic_arches}
|
||||
%nodejs_arches %{generic_arches}
|
||||
%ldc_arches %{generic_arches}
|
||||
%mono_arches %{generic_arches}
|
||||
%fpc_arches %{generic_arches}
|
||||
%ghc_arches_with_ghci %{generic_arches}
|
||||
%ghc_arches %{generic_arches}
|
||||
%GNAT_arches %{GPRbuild_arches} %{generic_arches}
|
||||
%GPRbuild_arches %{generic_arches}
|
||||
%nim_arches %{generic_arches}
|
||||
%nodejs_arches %{generic_arches}
|
||||
%ocaml_native_compiler %{generic_arches}
|
||||
%ocaml_natdynlink %{generic_arches}
|
||||
%ocaml_native_profiling %{generic_arches}
|
||||
%openblas_arches %{generic_arches}
|
||||
|
||||
#%ldconfig /sbin/ldconfig
|
||||
%ldconfig_post(n:) %{?ldconfig:%post -p %ldconfig %{?*} %{-n:-n %{-n*}}\
|
||||
%end}
|
||||
%ldconfig_postun(n:) %{?ldconfig:%postun -p %ldconfig %{?*} %{-n:-n %{-n*}}\
|
||||
%end}
|
||||
%ldconfig_scriptlets(n:) %{?ldconfig:\
|
||||
%ldconfig_post %{?*} %{-n:-n %{-n*}}\
|
||||
%ldconfig_postun %{?*} %{-n:-n %{-n*}}\
|
||||
}
|
||||
|
||||
# Some miscellaneous macros
|
||||
%_metainfodir %{_datadir}/metainfo
|
||||
%rpmmacrodir /usr/lib/rpm/macros.d
|
||||
|
||||
# arches that mono builds on
|
||||
%_monogacdir %{_monodir}/gac
|
||||
%_monodir %{_prefix}/lib/mono
|
||||
|
||||
# ---- VPATH default settings
|
||||
%_vpath_builddir %_target_platform
|
||||
%_vpath_srcdir .
|
||||
|
||||
|
||||
# ---- custom macros
|
||||
%disable_rpath \
|
||||
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
|
||||
|
||||
%delete_la_and_a \
|
||||
find $RPM_BUILD_ROOT -type f -name "*.la" -delete \
|
||||
find $RPM_BUILD_ROOT -type f -name "*.a" -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 {}
|
||||
|
||||
%package_help \
|
||||
%package help \
|
||||
Summary: Documents for %{name} \
|
||||
Buildarch: noarch \
|
||||
Requires: man info \
|
||||
\
|
||||
%description help \
|
||||
Man pages and other related documents for %{name}.
|
||||
|
||||
#%sbin_installinfo_rm bc.info
|
||||
#%sbin_installinfo_rm bc.info.gz
|
||||
|
||||
%install_info() \
|
||||
/sbin/install-info %1 %{_infodir}/dir || :
|
||||
|
||||
%install_info_rm() \
|
||||
/sbin/install-info --remove %1 %{_infodir}/dir || :
|
||||
|
||||
566
macros.forge
566
macros.forge
@ -1,283 +1,283 @@
|
||||
# Map forge information to rpm metadata. This macro will compute default spec
|
||||
# variable values.
|
||||
#
|
||||
# The following spec variables SHOULD be set before calling the macro:
|
||||
#
|
||||
# forgeurl the project url on the forge, strongly recommended;
|
||||
# alternatively, use -u <url>
|
||||
# Version if applicable, set it with Version: <version>
|
||||
# tag if applicable
|
||||
# commit if applicable
|
||||
# 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
|
||||
# not already set by the packager:
|
||||
#
|
||||
# forgesource an URL that can be used as SourceX: value
|
||||
# forgesetupargs the correct arguments to pass to %setup for this source
|
||||
# used by %forgesetup and %forgeautosetup
|
||||
# archivename the source archive filename, without extentions
|
||||
# archiveext the source archive filename extensions, without leading dot
|
||||
# archiveurl the url that can be used to download the source archive,
|
||||
# without renaming
|
||||
# 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
|
||||
# and archiveurl before calling it.
|
||||
#
|
||||
# Most of the computed variables are both overridable and optional. However,
|
||||
# the macro WILL REDEFINE %{dist} when packaging a snapshot (commit or tag).
|
||||
# The previous %{dist} value will be lost. Don’t call the macro if you don’t
|
||||
# wish %{dist} to be changed.
|
||||
#
|
||||
# Optional parameters:
|
||||
# -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
|
||||
# spec variable if it manages to parse it.
|
||||
# -s Silently ignore problems in forgeurl, use it if it can be parsed,
|
||||
# ignore it otherwise.
|
||||
# -p Restore problem handling, override -s.
|
||||
# -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
|
||||
# set at the end of the processing.
|
||||
%forgemeta(u:spvi) %{lua:
|
||||
local forgeurl = rpm.expand("%{?-u*}")
|
||||
if (forgeurl == "") then
|
||||
forgeurl = rpm.expand("%{?forgeurl}")
|
||||
end
|
||||
local silent = false
|
||||
local verbose = false
|
||||
local informative = false
|
||||
if (rpm.expand("%{?-s}") ~= "") then
|
||||
silent = true
|
||||
end
|
||||
if (rpm.expand("%{?-p}") ~= "") then
|
||||
silent = false
|
||||
end
|
||||
if (rpm.expand("%{?-v}") ~= "") then
|
||||
verbose = true
|
||||
end
|
||||
if (rpm.expand("%{?-i}") ~= "") then
|
||||
informative = true
|
||||
end
|
||||
local tag = rpm.expand("%{?tag}")
|
||||
local commit = rpm.expand("%{?commit}")
|
||||
-- Be explicit about the spec variables we’re setting
|
||||
local function explicitset(rpmvariable,value)
|
||||
rpm.define(rpmvariable .. " " .. value)
|
||||
if verbose then
|
||||
rpm.expand("%{echo:Setting %%{" .. rpmvariable .. "} = " .. value .. "\\n}")
|
||||
end
|
||||
end
|
||||
-- Never ever stomp on a spec variable the packager already set
|
||||
local function safeset(rpmvariable,value)
|
||||
if (rpm.expand("%{?" .. rpmvariable .. "}") == "") then
|
||||
explicitset(rpmvariable,value)
|
||||
end
|
||||
end
|
||||
-- Set spec variable values for each known software publishing service
|
||||
if (forgeurl ~= "") then
|
||||
local forge = string.match(forgeurl, "^[^:]+://([^/]+)/")
|
||||
if (forge == nil) then
|
||||
if not silent then
|
||||
rpm.expand("%{error:URLs must include a protocol such as https:// and a path starting with / !\\n}")
|
||||
end
|
||||
else
|
||||
if (string.match(forge, "^gitlab[%.-]") or string.match(forge, "[%.-]gitlab[%.]")) then
|
||||
forgeurl = string.match(forgeurl, "https://[^/]+/[^/]+/[^/#?]+")
|
||||
if (forgeurl == nil) then
|
||||
if not silent then
|
||||
rpm.expand("%{error:Gitlab URLs must match https://(…[-.])gitlab[-.]…/owner/repo !\\n}")
|
||||
end
|
||||
else
|
||||
explicitset("forgeurl", forgeurl)
|
||||
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}")
|
||||
end
|
||||
safeset("archiveext", "tar.bz2")
|
||||
safeset("forgesetupargs", "-n %{archivename}")
|
||||
if (commit ~= "") or (tag ~= "") then
|
||||
safeset("scm", "git")
|
||||
end
|
||||
local owner = string.match(forgeurl, "^[^:]+://[^/]+/([^/]+)")
|
||||
local repo = string.match(forgeurl, "^[^:]+://[^/]+/[^/]+/([^/]+)")
|
||||
local version = rpm.expand("%{?version}")
|
||||
if (version ~= "") and (version ~= "0") and (tag == "") then
|
||||
-- GitLab does not have strong versionning semantics
|
||||
-- Some projects use "version" as release tag, others "v" + "version"
|
||||
-- Tag value needs to be explicitly declared before calling the macro
|
||||
-- in the second case
|
||||
tag = version
|
||||
safeset("tag", tag)
|
||||
end
|
||||
if (tag ~= "") then
|
||||
safeset("archivename", repo .. "-%{tag}-%{commit}")
|
||||
safeset("archiveurl", "%{forgeurl}/repository/%{tag}/archive.%{archiveext}")
|
||||
else
|
||||
safeset("archivename", repo .. "-%{commit}")
|
||||
safeset("archiveurl", "%{forgeurl}/repository/%{commit}/archive.%{archiveext}")
|
||||
end
|
||||
end
|
||||
end
|
||||
if (string.match(forge, "^github[%.-]") or string.match(forge, "[%.-]github[%.]")) then
|
||||
forgeurl = string.match(forgeurl, "https://[^/]+/[^/]+/[^/#?]+")
|
||||
if (forgeurl == nil) then
|
||||
if not silent then
|
||||
rpm.expand("%{error:GitHub URLs must match https://(…[-.])github[-.]…/owner/repo !\\n}")
|
||||
end
|
||||
else
|
||||
explicitset("forgeurl", forgeurl)
|
||||
safeset("archiveext", "tar.gz")
|
||||
local forgesetupargs = "-n %{archivename}"
|
||||
if (commit ~= "") or (tag ~= "") then
|
||||
safeset("scm", "git")
|
||||
end
|
||||
local owner = string.match(forgeurl, "^[^:]+://[^/]+/([^/]+)")
|
||||
local repo = string.match(forgeurl, "^[^:]+://[^/]+/[^/]+/([^/]+)")
|
||||
if (tag ~= "") then
|
||||
-- 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
|
||||
-- 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
|
||||
local version = rpm.expand("%{?version}")
|
||||
if version ~= "" and
|
||||
(string.match(tag, "^v" .. version .. "[^%d]") or
|
||||
string.match(tag, "^v" .. version .. "$")) then
|
||||
forgesetupargs = "-n " .. repo .. "-" .. string.gsub(tag, "^v", "")
|
||||
end
|
||||
safeset("archivename", repo .. "-%{tag}")
|
||||
safeset("archiveurl", "%{forgeurl}/archive/%{tag}.%{archiveext}")
|
||||
else
|
||||
if (commit ~= "") then
|
||||
safeset("archivename", repo .. "-%{commit}")
|
||||
safeset("archiveurl", "%{forgeurl}/archive/%{commit}/" .. repo .. "-%{commit}.%{archiveext}")
|
||||
else
|
||||
safeset("archivename", repo .. "-%{version}")
|
||||
safeset("archiveurl", "%{forgeurl}/archive/v%{version}.%{archiveext}")
|
||||
end
|
||||
end
|
||||
safeset("forgesetupargs", forgesetupargs)
|
||||
end
|
||||
end
|
||||
if (forge == "code.googlesource.com") then
|
||||
forgeurl = string.match(forgeurl, "https://code.googlesource.com/[^#?]*[^/#?]+")
|
||||
if (forgeurl == nil) then
|
||||
if not silent then
|
||||
rpm.expand("%{error:Googlesource URLs must match https://code.googlesource.com/…/repo !\\n}")
|
||||
end
|
||||
else
|
||||
explicitset("forgeurl", forgeurl)
|
||||
safeset("archiveext", "tar.gz")
|
||||
safeset("forgesetupargs", "-c")
|
||||
if (commit ~= "") or (tag ~= "") then
|
||||
safeset("scm", "git")
|
||||
end
|
||||
local repo = string.match(forgeurl, "^[^:]+://.+/([^/?#]+)")
|
||||
if (tag ~= "") then
|
||||
safeset("archivename", repo .. "-%{tag}")
|
||||
safeset("archiveurl", "%{forgeurl}/+archive/%{tag}.%{archiveext}")
|
||||
else
|
||||
if (commit ~= "") then
|
||||
safeset("archivename", repo .. "-%{commit}")
|
||||
safeset("archiveurl", "%{forgeurl}/+archive/%{commit}.%{archiveext}")
|
||||
else
|
||||
safeset("archivename", repo .. "-v%{version}")
|
||||
safeset("archiveurl", "%{forgeurl}/+archive/v%{version}.%{archiveext}")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if (forge == "bitbucket.org") then
|
||||
forgeurl = string.match(forgeurl, "https://[^/]+/[^/]+/[^/#?]+")
|
||||
if (forgeurl == nil) then
|
||||
if not silent then
|
||||
rpm.expand("%{error:BitBucket URLs must match https://bitbucket.org/owner/repo !\\n}")
|
||||
end
|
||||
else
|
||||
explicitset("forgeurl", forgeurl)
|
||||
if (commit == "") then
|
||||
rpm.expand("%{error:All BitBucket URLs require commit value knowledge: you need to define %{commit}!\\n}")
|
||||
end
|
||||
local shortcommit = string.sub(commit, 1, 12)
|
||||
safeset("archiveext", "tar.bz2")
|
||||
-- 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
|
||||
safeset("scm", "git")
|
||||
local owner = string.match(forgeurl, "^[^:]+://[^/]+/([^/]+)")
|
||||
local repo = string.match(forgeurl, "^[^:]+://[^/]+/[^/]+/([^/]+)")
|
||||
safeset("archivename", owner .. "-" .. repo .. "-" .. shortcommit)
|
||||
safeset("forgesetupargs", "-n %{archivename}")
|
||||
if (tag ~= "") then
|
||||
safeset("archiveurl", "%{forgeurl}/get/%{tag}.%{archiveext}")
|
||||
else
|
||||
safeset("archiveurl", "%{forgeurl}/get/%{commit}.%{archiveext}")
|
||||
end
|
||||
end
|
||||
end
|
||||
if (forge == "pagure.io") 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}")
|
||||
end
|
||||
end
|
||||
-- Final tests to check forgeurl was successfuly parsed
|
||||
if not silent 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}")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
-- Set defaults if forgeurl is missing or does not parse
|
||||
local archivename = rpm.expand("%{?archivename}")
|
||||
safeset("archiveext", "tar.gz")
|
||||
if (archivename ~= "") then
|
||||
safeset("forgesetupargs", "-n %{archivename}")
|
||||
end
|
||||
if (commit ~= "") or (tag ~= "") then
|
||||
safeset("scm", "git")
|
||||
end
|
||||
-- Source URL processing (computing the forgesource spec variable)
|
||||
local archiveurl = rpm.expand("%{?archiveurl}")
|
||||
local archiveext = rpm.expand("%{?archiveext}")
|
||||
if (archivename ~= "") and (archiveurl ~= "") then
|
||||
if (string.match(archiveurl, "/([^/]+)$") == archivename .. "." .. archiveext) then
|
||||
safeset("forgesource", "%{archiveurl}")
|
||||
else
|
||||
safeset("forgesource", "%{?archiveurl}#/%{?archivename}.%{archiveext}")
|
||||
end
|
||||
end
|
||||
-- dist processing (computing the correct pefix for snapshots)
|
||||
local distprefix = rpm.expand("%{?tag}")
|
||||
local version = rpm.expand("%{?version}")
|
||||
if (distprefix == version) or (distprefix == "v" .. version) then
|
||||
distprefix = ""
|
||||
end
|
||||
if (distprefix == "") then
|
||||
distprefix = string.sub(rpm.expand("%{?commit}"), 1, 7)
|
||||
end
|
||||
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}")
|
||||
explicitset("dist", dist)
|
||||
end
|
||||
-- Final spec variable summary if the macro was called with -i
|
||||
if informative then
|
||||
rpm.expand("%{echo:Forge-specific packaging variables\\n}")
|
||||
rpm.expand("%{echo: forgeurl: %{?forgeurl}\\n}")
|
||||
rpm.expand("%{echo: forgesource: %{?forgesource}\\n}")
|
||||
rpm.expand("%{echo: forgesetupargs: %{?forgesetupargs}\\n}")
|
||||
rpm.expand("%{echo:Generic variables\\n}")
|
||||
rpm.expand("%{echo: archivename: %{?archivename}\\n}")
|
||||
rpm.expand("%{echo: archiveext: %{?archiveext}\\n}")
|
||||
rpm.expand("%{echo: archiveurl: %{?archiveurl}\\n}")
|
||||
rpm.expand("%{echo: scm: %{?scm}\\n}")
|
||||
rpm.expand("%{echo: tag: %{?tag}\\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}")
|
||||
end
|
||||
}
|
||||
|
||||
# Convenience macro to relay computed arguments to %setup
|
||||
%forgesetup(a:b:cDn:Tq) %setup %{?forgesetupargs} %{-a} %{-b} %{-c} %{-D} %{-n} %{-T} %{-q}
|
||||
|
||||
# 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}
|
||||
# Map forge information to rpm metadata. This macro will compute default spec
|
||||
# variable values.
|
||||
#
|
||||
# The following spec variables SHOULD be set before calling the macro:
|
||||
#
|
||||
# forgeurl the project url on the forge, strongly recommended;
|
||||
# alternatively, use -u <url>
|
||||
# Version if applicable, set it with Version: <version>
|
||||
# tag if applicable
|
||||
# commit if applicable
|
||||
# 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
|
||||
# not already set by the packager:
|
||||
#
|
||||
# forgesource an URL that can be used as SourceX: value
|
||||
# forgesetupargs the correct arguments to pass to %setup for this source
|
||||
# used by %forgesetup and %forgeautosetup
|
||||
# archivename the source archive filename, without extentions
|
||||
# archiveext the source archive filename extensions, without leading dot
|
||||
# archiveurl the url that can be used to download the source archive,
|
||||
# without renaming
|
||||
# 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
|
||||
# and archiveurl before calling it.
|
||||
#
|
||||
# Most of the computed variables are both overridable and optional. However,
|
||||
# the macro WILL REDEFINE %{dist} when packaging a snapshot (commit or tag).
|
||||
# The previous %{dist} value will be lost. Don’t call the macro if you don’t
|
||||
# wish %{dist} to be changed.
|
||||
#
|
||||
# Optional parameters:
|
||||
# -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
|
||||
# spec variable if it manages to parse it.
|
||||
# -s Silently ignore problems in forgeurl, use it if it can be parsed,
|
||||
# ignore it otherwise.
|
||||
# -p Restore problem handling, override -s.
|
||||
# -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
|
||||
# set at the end of the processing.
|
||||
%forgemeta(u:spvi) %{lua:
|
||||
local forgeurl = rpm.expand("%{?-u*}")
|
||||
if (forgeurl == "") then
|
||||
forgeurl = rpm.expand("%{?forgeurl}")
|
||||
end
|
||||
local silent = false
|
||||
local verbose = false
|
||||
local informative = false
|
||||
if (rpm.expand("%{?-s}") ~= "") then
|
||||
silent = true
|
||||
end
|
||||
if (rpm.expand("%{?-p}") ~= "") then
|
||||
silent = false
|
||||
end
|
||||
if (rpm.expand("%{?-v}") ~= "") then
|
||||
verbose = true
|
||||
end
|
||||
if (rpm.expand("%{?-i}") ~= "") then
|
||||
informative = true
|
||||
end
|
||||
local tag = rpm.expand("%{?tag}")
|
||||
local commit = rpm.expand("%{?commit}")
|
||||
-- Be explicit about the spec variables we’re setting
|
||||
local function explicitset(rpmvariable,value)
|
||||
rpm.define(rpmvariable .. " " .. value)
|
||||
if verbose then
|
||||
rpm.expand("%{echo:Setting %%{" .. rpmvariable .. "} = " .. value .. "\\n}")
|
||||
end
|
||||
end
|
||||
-- Never ever stomp on a spec variable the packager already set
|
||||
local function safeset(rpmvariable,value)
|
||||
if (rpm.expand("%{?" .. rpmvariable .. "}") == "") then
|
||||
explicitset(rpmvariable,value)
|
||||
end
|
||||
end
|
||||
-- Set spec variable values for each known software publishing service
|
||||
if (forgeurl ~= "") then
|
||||
local forge = string.match(forgeurl, "^[^:]+://([^/]+)/")
|
||||
if (forge == nil) then
|
||||
if not silent then
|
||||
rpm.expand("%{error:URLs must include a protocol such as https:// and a path starting with / !\\n}")
|
||||
end
|
||||
else
|
||||
if (string.match(forge, "^gitlab[%.-]") or string.match(forge, "[%.-]gitlab[%.]")) then
|
||||
forgeurl = string.match(forgeurl, "https://[^/]+/[^/]+/[^/#?]+")
|
||||
if (forgeurl == nil) then
|
||||
if not silent then
|
||||
rpm.expand("%{error:Gitlab URLs must match https://(…[-.])gitlab[-.]…/owner/repo !\\n}")
|
||||
end
|
||||
else
|
||||
explicitset("forgeurl", forgeurl)
|
||||
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}")
|
||||
end
|
||||
safeset("archiveext", "tar.bz2")
|
||||
safeset("forgesetupargs", "-n %{archivename}")
|
||||
if (commit ~= "") or (tag ~= "") then
|
||||
safeset("scm", "git")
|
||||
end
|
||||
local owner = string.match(forgeurl, "^[^:]+://[^/]+/([^/]+)")
|
||||
local repo = string.match(forgeurl, "^[^:]+://[^/]+/[^/]+/([^/]+)")
|
||||
local version = rpm.expand("%{?version}")
|
||||
if (version ~= "") and (version ~= "0") and (tag == "") then
|
||||
-- GitLab does not have strong versionning semantics
|
||||
-- Some projects use "version" as release tag, others "v" + "version"
|
||||
-- Tag value needs to be explicitly declared before calling the macro
|
||||
-- in the second case
|
||||
tag = version
|
||||
safeset("tag", tag)
|
||||
end
|
||||
if (tag ~= "") then
|
||||
safeset("archivename", repo .. "-%{tag}-%{commit}")
|
||||
safeset("archiveurl", "%{forgeurl}/repository/%{tag}/archive.%{archiveext}")
|
||||
else
|
||||
safeset("archivename", repo .. "-%{commit}")
|
||||
safeset("archiveurl", "%{forgeurl}/repository/%{commit}/archive.%{archiveext}")
|
||||
end
|
||||
end
|
||||
end
|
||||
if (string.match(forge, "^github[%.-]") or string.match(forge, "[%.-]github[%.]")) then
|
||||
forgeurl = string.match(forgeurl, "https://[^/]+/[^/]+/[^/#?]+")
|
||||
if (forgeurl == nil) then
|
||||
if not silent then
|
||||
rpm.expand("%{error:GitHub URLs must match https://(…[-.])github[-.]…/owner/repo !\\n}")
|
||||
end
|
||||
else
|
||||
explicitset("forgeurl", forgeurl)
|
||||
safeset("archiveext", "tar.gz")
|
||||
local forgesetupargs = "-n %{archivename}"
|
||||
if (commit ~= "") or (tag ~= "") then
|
||||
safeset("scm", "git")
|
||||
end
|
||||
local owner = string.match(forgeurl, "^[^:]+://[^/]+/([^/]+)")
|
||||
local repo = string.match(forgeurl, "^[^:]+://[^/]+/[^/]+/([^/]+)")
|
||||
if (tag ~= "") then
|
||||
-- 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
|
||||
-- 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
|
||||
local version = rpm.expand("%{?version}")
|
||||
if version ~= "" and
|
||||
(string.match(tag, "^v" .. version .. "[^%d]") or
|
||||
string.match(tag, "^v" .. version .. "$")) then
|
||||
forgesetupargs = "-n " .. repo .. "-" .. string.gsub(tag, "^v", "")
|
||||
end
|
||||
safeset("archivename", repo .. "-%{tag}")
|
||||
safeset("archiveurl", "%{forgeurl}/archive/%{tag}.%{archiveext}")
|
||||
else
|
||||
if (commit ~= "") then
|
||||
safeset("archivename", repo .. "-%{commit}")
|
||||
safeset("archiveurl", "%{forgeurl}/archive/%{commit}/" .. repo .. "-%{commit}.%{archiveext}")
|
||||
else
|
||||
safeset("archivename", repo .. "-%{version}")
|
||||
safeset("archiveurl", "%{forgeurl}/archive/v%{version}.%{archiveext}")
|
||||
end
|
||||
end
|
||||
safeset("forgesetupargs", forgesetupargs)
|
||||
end
|
||||
end
|
||||
if (forge == "code.googlesource.com") then
|
||||
forgeurl = string.match(forgeurl, "https://code.googlesource.com/[^#?]*[^/#?]+")
|
||||
if (forgeurl == nil) then
|
||||
if not silent then
|
||||
rpm.expand("%{error:Googlesource URLs must match https://code.googlesource.com/…/repo !\\n}")
|
||||
end
|
||||
else
|
||||
explicitset("forgeurl", forgeurl)
|
||||
safeset("archiveext", "tar.gz")
|
||||
safeset("forgesetupargs", "-c")
|
||||
if (commit ~= "") or (tag ~= "") then
|
||||
safeset("scm", "git")
|
||||
end
|
||||
local repo = string.match(forgeurl, "^[^:]+://.+/([^/?#]+)")
|
||||
if (tag ~= "") then
|
||||
safeset("archivename", repo .. "-%{tag}")
|
||||
safeset("archiveurl", "%{forgeurl}/+archive/%{tag}.%{archiveext}")
|
||||
else
|
||||
if (commit ~= "") then
|
||||
safeset("archivename", repo .. "-%{commit}")
|
||||
safeset("archiveurl", "%{forgeurl}/+archive/%{commit}.%{archiveext}")
|
||||
else
|
||||
safeset("archivename", repo .. "-v%{version}")
|
||||
safeset("archiveurl", "%{forgeurl}/+archive/v%{version}.%{archiveext}")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if (forge == "bitbucket.org") then
|
||||
forgeurl = string.match(forgeurl, "https://[^/]+/[^/]+/[^/#?]+")
|
||||
if (forgeurl == nil) then
|
||||
if not silent then
|
||||
rpm.expand("%{error:BitBucket URLs must match https://bitbucket.org/owner/repo !\\n}")
|
||||
end
|
||||
else
|
||||
explicitset("forgeurl", forgeurl)
|
||||
if (commit == "") then
|
||||
rpm.expand("%{error:All BitBucket URLs require commit value knowledge: you need to define %{commit}!\\n}")
|
||||
end
|
||||
local shortcommit = string.sub(commit, 1, 12)
|
||||
safeset("archiveext", "tar.bz2")
|
||||
-- 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
|
||||
safeset("scm", "git")
|
||||
local owner = string.match(forgeurl, "^[^:]+://[^/]+/([^/]+)")
|
||||
local repo = string.match(forgeurl, "^[^:]+://[^/]+/[^/]+/([^/]+)")
|
||||
safeset("archivename", owner .. "-" .. repo .. "-" .. shortcommit)
|
||||
safeset("forgesetupargs", "-n %{archivename}")
|
||||
if (tag ~= "") then
|
||||
safeset("archiveurl", "%{forgeurl}/get/%{tag}.%{archiveext}")
|
||||
else
|
||||
safeset("archiveurl", "%{forgeurl}/get/%{commit}.%{archiveext}")
|
||||
end
|
||||
end
|
||||
end
|
||||
if (forge == "pagure.io") 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}")
|
||||
end
|
||||
end
|
||||
-- Final tests to check forgeurl was successfuly parsed
|
||||
if not silent 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}")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
-- Set defaults if forgeurl is missing or does not parse
|
||||
local archivename = rpm.expand("%{?archivename}")
|
||||
safeset("archiveext", "tar.gz")
|
||||
if (archivename ~= "") then
|
||||
safeset("forgesetupargs", "-n %{archivename}")
|
||||
end
|
||||
if (commit ~= "") or (tag ~= "") then
|
||||
safeset("scm", "git")
|
||||
end
|
||||
-- Source URL processing (computing the forgesource spec variable)
|
||||
local archiveurl = rpm.expand("%{?archiveurl}")
|
||||
local archiveext = rpm.expand("%{?archiveext}")
|
||||
if (archivename ~= "") and (archiveurl ~= "") then
|
||||
if (string.match(archiveurl, "/([^/]+)$") == archivename .. "." .. archiveext) then
|
||||
safeset("forgesource", "%{archiveurl}")
|
||||
else
|
||||
safeset("forgesource", "%{?archiveurl}#/%{?archivename}.%{archiveext}")
|
||||
end
|
||||
end
|
||||
-- dist processing (computing the correct pefix for snapshots)
|
||||
local distprefix = rpm.expand("%{?tag}")
|
||||
local version = rpm.expand("%{?version}")
|
||||
if (distprefix == version) or (distprefix == "v" .. version) then
|
||||
distprefix = ""
|
||||
end
|
||||
if (distprefix == "") then
|
||||
distprefix = string.sub(rpm.expand("%{?commit}"), 1, 7)
|
||||
end
|
||||
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}")
|
||||
explicitset("dist", dist)
|
||||
end
|
||||
-- Final spec variable summary if the macro was called with -i
|
||||
if informative then
|
||||
rpm.expand("%{echo:Forge-specific packaging variables\\n}")
|
||||
rpm.expand("%{echo: forgeurl: %{?forgeurl}\\n}")
|
||||
rpm.expand("%{echo: forgesource: %{?forgesource}\\n}")
|
||||
rpm.expand("%{echo: forgesetupargs: %{?forgesetupargs}\\n}")
|
||||
rpm.expand("%{echo:Generic variables\\n}")
|
||||
rpm.expand("%{echo: archivename: %{?archivename}\\n}")
|
||||
rpm.expand("%{echo: archiveext: %{?archiveext}\\n}")
|
||||
rpm.expand("%{echo: archiveurl: %{?archiveurl}\\n}")
|
||||
rpm.expand("%{echo: scm: %{?scm}\\n}")
|
||||
rpm.expand("%{echo: tag: %{?tag}\\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}")
|
||||
end
|
||||
}
|
||||
|
||||
# Convenience macro to relay computed arguments to %setup
|
||||
%forgesetup(a:b:cDn:Tq) %setup %{?forgesetupargs} %{-a} %{-b} %{-c} %{-D} %{-n} %{-T} %{-q}
|
||||
|
||||
# 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}
|
||||
|
||||
340
macros.go
340
macros.go
@ -1,170 +1,170 @@
|
||||
# Copyright (c) 2015-2018 Jakub Cajka <jcajka@redhat.com>,
|
||||
# Jan Chaloupka <jchaloup@redhat.com>,
|
||||
# Nicolas Mailhot <nim@fedoraproject.org>
|
||||
# This file is distributed under the terms of GNU GPL license version 3, or
|
||||
# any later version.
|
||||
|
||||
# This file contains macros for building projects in golang for packages
|
||||
# with golang compiler or gcc-go compiler based on an architecture.
|
||||
# Golang is primarly for primary architectures, gcc-go for secondary.
|
||||
#
|
||||
# This file provides only macros and must not use any other package except
|
||||
# redhat-rpm-macros.
|
||||
|
||||
# Define arches for PA and SA
|
||||
%golang_arches %{ix86} x86_64 %{arm} aarch64 ppc64le s390x
|
||||
%gccgo_arches %{mips}
|
||||
%go_arches %{golang_arches} %{gccgo_arches}
|
||||
|
||||
# Where to set GOPATH for builds
|
||||
%gopath %{_datadir}/gocode
|
||||
|
||||
# Define go_compilers macro to signal go-compiler package is available
|
||||
%go_compiler 1
|
||||
|
||||
# Sanitize a Go import path that can then serve as rpm package name
|
||||
# Mandatory parameter: a Go import path
|
||||
%gorpmname() %{lua:
|
||||
local goname = rpm.expand("%1")
|
||||
-- lowercase and end with '/'
|
||||
goname = string.lower(goname .. "/")
|
||||
-- remove eventual protocol prefix
|
||||
goname = string.gsub(goname, "^http(s?)://", "")
|
||||
-- remove eventual .git suffix
|
||||
goname = string.gsub(goname, "%.git/*", "")
|
||||
-- remove eventual git. prefix
|
||||
goname = string.gsub(goname, "^git%.", "")
|
||||
-- add golang prefix
|
||||
goname = "golang-" .. goname
|
||||
-- remove FQDN root (.com, .org, etc)
|
||||
goname = string.gsub(goname, "^([^/]+)%.([^%./]+)/", "%1/")
|
||||
-- special-case x.y.z number-strings as that’s an exception in our naming
|
||||
-- guidelines
|
||||
repeat
|
||||
goname, i = string.gsub(goname, "(%d)%.(%d)", "%1:%2")
|
||||
until i == 0
|
||||
-- replace various separators rpm does not like with -
|
||||
goname = string.gsub(goname, "[%._/%-]+", "-")
|
||||
-- because of the Azure sdk
|
||||
goname = string.gsub(goname, "%-for%-go%-", "-")
|
||||
-- Tokenize along - separators and remove duplicates to avoid
|
||||
-- golang-foo-foo-bar-foo names
|
||||
local result = ""
|
||||
local tokens = {}
|
||||
tokens["go"] = true
|
||||
for token in string.gmatch(goname, "[^%-]+") do
|
||||
if not tokens[token] then
|
||||
result = result .. "-" .. token
|
||||
tokens[token] = true
|
||||
end
|
||||
end
|
||||
-- reassemble the string, restore x.y.z runs, convert the vx.y.z
|
||||
-- Go convention to x.y.z as prefered in rpm naming
|
||||
result = string.gsub(result, "^-", "")
|
||||
result = string.gsub(result, ":", ".")
|
||||
-- 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
|
||||
result = string.gsub(result, "%-v([%.%d])", "-%1")
|
||||
print(result)
|
||||
}
|
||||
|
||||
# Map Go information to rpm metadata. This macro will compute default spec
|
||||
# variable values.
|
||||
#
|
||||
# The following spec variable MUST be set before calling the macro:
|
||||
#
|
||||
# goipath the packaged Go project import path
|
||||
#
|
||||
# The following spec variables SHOULD be set before calling the macro:
|
||||
#
|
||||
# forgeurl the project url on the forge, strongly recommended, if it can not
|
||||
# be deduced from goipath; alternatively, use -u <url>
|
||||
# Version if applicable, set it with Version: <version>
|
||||
# tag if applicable
|
||||
# commit if applicable
|
||||
#
|
||||
# The macro will attempt to compute and set the following variables if they are
|
||||
# not already set by the packager:
|
||||
#
|
||||
# goname an rpm-compatible package name derived from goipath
|
||||
# gosource an URL that can be used as SourceX: value
|
||||
# gourl an URL that can be used as URL: value
|
||||
#
|
||||
# It will delegate processing to the forgemeta macro for:
|
||||
#
|
||||
# forgesource an URL that can be used as SourceX: value
|
||||
# forgesetupargs the correct arguments to pass to %setup for this source
|
||||
# used by %forgesetup and %forgeautosetup
|
||||
# archivename the source archive filename, without extentions
|
||||
# archiveext the source archive filename extensions, without leading dot
|
||||
# archiveurl the url that can be used to download the source archive,
|
||||
# without renaming
|
||||
# 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
|
||||
# and archiveurl before calling it.
|
||||
#
|
||||
# Most of the computed variables are both overridable and optional. However,
|
||||
# the macro WILL REDEFINE %{dist} when packaging a snapshot (commit or tag).
|
||||
# The previous %{dist} value will be lost. Don’t call the macro if you don’t
|
||||
# wish %{dist} to be changed.
|
||||
#
|
||||
# Optional parameters:
|
||||
# -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
|
||||
# spec variable if it manages to parse it.
|
||||
# -s Silently ignore problems in forgeurl, use it if it can be parsed,
|
||||
# ignore it otherwise.
|
||||
# -p Restore problem handling, override -s.
|
||||
# -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
|
||||
# set at the end of the processing.
|
||||
%gometa(u:spvi) %{expand:%{lua:
|
||||
local forgeurl = rpm.expand("%{?-u*}")
|
||||
if (forgeurl == "") then
|
||||
forgeurl = rpm.expand("%{?forgeurl}")
|
||||
end
|
||||
-- Be explicit about the spec variables we’re setting
|
||||
local function explicitset(rpmvariable,value)
|
||||
rpm.define(rpmvariable .. " " .. value)
|
||||
if (rpm.expand("%{?-v}") ~= "") then
|
||||
rpm.expand("%{echo:Setting %%{" .. rpmvariable .. "} = " .. value .. "\\n}")
|
||||
end
|
||||
end
|
||||
-- Never ever stomp on a spec variable the packager already set
|
||||
local function safeset(rpmvariable,value)
|
||||
if (rpm.expand("%{?" .. rpmvariable .. "}") == "") then
|
||||
explicitset(rpmvariable,value)
|
||||
end
|
||||
end
|
||||
-- All the Go packaging automation relies on goipath being set
|
||||
local goipath = rpm.expand("%{?goipath}")
|
||||
if (goipath == "") then
|
||||
rpm.expand("%{error:Please set the Go import path in the “goipath” variable before calling “gometa”!}")
|
||||
end
|
||||
-- Compute and set spec variables
|
||||
if (forgeurl ~= "") then
|
||||
rpm.expand("%forgemeta %{?-v} %{?-i} %{?-s} %{?-p} -u " .. forgeurl .. "\\n")
|
||||
safeset("gourl", forgeurl)
|
||||
else
|
||||
safeset("gourl", "https://" .. goipath)
|
||||
rpm.expand("%forgemeta %{?-v} %{?-i} -s %{?-p} -u %{gourl}\\n")
|
||||
end
|
||||
if (rpm.expand("%{?forgesource}") ~= "") then
|
||||
safeset("gosource", "%{forgesource}")
|
||||
else
|
||||
safeset("gosource", "%{gourl}/%{archivename}.%{archiveext}")
|
||||
end
|
||||
safeset("goname", "%gorpmname %{goipath}")
|
||||
rpm.define("gosetup %forgesetup")
|
||||
-- Final spec variable summary if the macro was called with -i
|
||||
if (rpm.expand("%{?-i}") ~= "") then
|
||||
rpm.expand("%{echo:Go-specific packaging variables}")
|
||||
rpm.expand("%{echo: goipath: %{?goipath}}")
|
||||
rpm.expand("%{echo: goname: %{?goname}}")
|
||||
rpm.expand("%{echo: gourl: %{?gourl}}")
|
||||
rpm.expand("%{echo: gosource: %{?gosource}}")
|
||||
end}
|
||||
BuildRequires: compiler(go-compiler)
|
||||
ExclusiveArch: %{go_arches}
|
||||
}
|
||||
# Copyright (c) 2015-2018 Jakub Cajka <jcajka@redhat.com>,
|
||||
# Jan Chaloupka <jchaloup@redhat.com>,
|
||||
# Nicolas Mailhot <nim@fedoraproject.org>
|
||||
# This file is distributed under the terms of GNU GPL license version 3, or
|
||||
# any later version.
|
||||
|
||||
# This file contains macros for building projects in golang for packages
|
||||
# with golang compiler or gcc-go compiler based on an architecture.
|
||||
# Golang is primarly for primary architectures, gcc-go for secondary.
|
||||
#
|
||||
# This file provides only macros and must not use any other package except
|
||||
# redhat-rpm-macros.
|
||||
|
||||
# Define arches for PA and SA
|
||||
%golang_arches %{ix86} x86_64 %{arm} aarch64 ppc64le s390x
|
||||
%gccgo_arches %{mips}
|
||||
%go_arches %{golang_arches} %{gccgo_arches}
|
||||
|
||||
# Where to set GOPATH for builds
|
||||
%gopath %{_datadir}/gocode
|
||||
|
||||
# Define go_compilers macro to signal go-compiler package is available
|
||||
%go_compiler 1
|
||||
|
||||
# Sanitize a Go import path that can then serve as rpm package name
|
||||
# Mandatory parameter: a Go import path
|
||||
%gorpmname() %{lua:
|
||||
local goname = rpm.expand("%1")
|
||||
-- lowercase and end with '/'
|
||||
goname = string.lower(goname .. "/")
|
||||
-- remove eventual protocol prefix
|
||||
goname = string.gsub(goname, "^http(s?)://", "")
|
||||
-- remove eventual .git suffix
|
||||
goname = string.gsub(goname, "%.git/*", "")
|
||||
-- remove eventual git. prefix
|
||||
goname = string.gsub(goname, "^git%.", "")
|
||||
-- add golang prefix
|
||||
goname = "golang-" .. goname
|
||||
-- remove FQDN root (.com, .org, etc)
|
||||
goname = string.gsub(goname, "^([^/]+)%.([^%./]+)/", "%1/")
|
||||
-- special-case x.y.z number-strings as that’s an exception in our naming
|
||||
-- guidelines
|
||||
repeat
|
||||
goname, i = string.gsub(goname, "(%d)%.(%d)", "%1:%2")
|
||||
until i == 0
|
||||
-- replace various separators rpm does not like with -
|
||||
goname = string.gsub(goname, "[%._/%-]+", "-")
|
||||
-- because of the Azure sdk
|
||||
goname = string.gsub(goname, "%-for%-go%-", "-")
|
||||
-- Tokenize along - separators and remove duplicates to avoid
|
||||
-- golang-foo-foo-bar-foo names
|
||||
local result = ""
|
||||
local tokens = {}
|
||||
tokens["go"] = true
|
||||
for token in string.gmatch(goname, "[^%-]+") do
|
||||
if not tokens[token] then
|
||||
result = result .. "-" .. token
|
||||
tokens[token] = true
|
||||
end
|
||||
end
|
||||
-- reassemble the string, restore x.y.z runs, convert the vx.y.z
|
||||
-- Go convention to x.y.z as prefered in rpm naming
|
||||
result = string.gsub(result, "^-", "")
|
||||
result = string.gsub(result, ":", ".")
|
||||
-- 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
|
||||
result = string.gsub(result, "%-v([%.%d])", "-%1")
|
||||
print(result)
|
||||
}
|
||||
|
||||
# Map Go information to rpm metadata. This macro will compute default spec
|
||||
# variable values.
|
||||
#
|
||||
# The following spec variable MUST be set before calling the macro:
|
||||
#
|
||||
# goipath the packaged Go project import path
|
||||
#
|
||||
# The following spec variables SHOULD be set before calling the macro:
|
||||
#
|
||||
# forgeurl the project url on the forge, strongly recommended, if it can not
|
||||
# be deduced from goipath; alternatively, use -u <url>
|
||||
# Version if applicable, set it with Version: <version>
|
||||
# tag if applicable
|
||||
# commit if applicable
|
||||
#
|
||||
# The macro will attempt to compute and set the following variables if they are
|
||||
# not already set by the packager:
|
||||
#
|
||||
# goname an rpm-compatible package name derived from goipath
|
||||
# gosource an URL that can be used as SourceX: value
|
||||
# gourl an URL that can be used as URL: value
|
||||
#
|
||||
# It will delegate processing to the forgemeta macro for:
|
||||
#
|
||||
# forgesource an URL that can be used as SourceX: value
|
||||
# forgesetupargs the correct arguments to pass to %setup for this source
|
||||
# used by %forgesetup and %forgeautosetup
|
||||
# archivename the source archive filename, without extentions
|
||||
# archiveext the source archive filename extensions, without leading dot
|
||||
# archiveurl the url that can be used to download the source archive,
|
||||
# without renaming
|
||||
# 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
|
||||
# and archiveurl before calling it.
|
||||
#
|
||||
# Most of the computed variables are both overridable and optional. However,
|
||||
# the macro WILL REDEFINE %{dist} when packaging a snapshot (commit or tag).
|
||||
# The previous %{dist} value will be lost. Don’t call the macro if you don’t
|
||||
# wish %{dist} to be changed.
|
||||
#
|
||||
# Optional parameters:
|
||||
# -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
|
||||
# spec variable if it manages to parse it.
|
||||
# -s Silently ignore problems in forgeurl, use it if it can be parsed,
|
||||
# ignore it otherwise.
|
||||
# -p Restore problem handling, override -s.
|
||||
# -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
|
||||
# set at the end of the processing.
|
||||
%gometa(u:spvi) %{expand:%{lua:
|
||||
local forgeurl = rpm.expand("%{?-u*}")
|
||||
if (forgeurl == "") then
|
||||
forgeurl = rpm.expand("%{?forgeurl}")
|
||||
end
|
||||
-- Be explicit about the spec variables we’re setting
|
||||
local function explicitset(rpmvariable,value)
|
||||
rpm.define(rpmvariable .. " " .. value)
|
||||
if (rpm.expand("%{?-v}") ~= "") then
|
||||
rpm.expand("%{echo:Setting %%{" .. rpmvariable .. "} = " .. value .. "\\n}")
|
||||
end
|
||||
end
|
||||
-- Never ever stomp on a spec variable the packager already set
|
||||
local function safeset(rpmvariable,value)
|
||||
if (rpm.expand("%{?" .. rpmvariable .. "}") == "") then
|
||||
explicitset(rpmvariable,value)
|
||||
end
|
||||
end
|
||||
-- All the Go packaging automation relies on goipath being set
|
||||
local goipath = rpm.expand("%{?goipath}")
|
||||
if (goipath == "") then
|
||||
rpm.expand("%{error:Please set the Go import path in the “goipath” variable before calling “gometa”!}")
|
||||
end
|
||||
-- Compute and set spec variables
|
||||
if (forgeurl ~= "") then
|
||||
rpm.expand("%forgemeta %{?-v} %{?-i} %{?-s} %{?-p} -u " .. forgeurl .. "\\n")
|
||||
safeset("gourl", forgeurl)
|
||||
else
|
||||
safeset("gourl", "https://" .. goipath)
|
||||
rpm.expand("%forgemeta %{?-v} %{?-i} -s %{?-p} -u %{gourl}\\n")
|
||||
end
|
||||
if (rpm.expand("%{?forgesource}") ~= "") then
|
||||
safeset("gosource", "%{forgesource}")
|
||||
else
|
||||
safeset("gosource", "%{gourl}/%{archivename}.%{archiveext}")
|
||||
end
|
||||
safeset("goname", "%gorpmname %{goipath}")
|
||||
rpm.define("gosetup %forgesetup")
|
||||
-- Final spec variable summary if the macro was called with -i
|
||||
if (rpm.expand("%{?-i}") ~= "") then
|
||||
rpm.expand("%{echo:Go-specific packaging variables}")
|
||||
rpm.expand("%{echo: goipath: %{?goipath}}")
|
||||
rpm.expand("%{echo: goname: %{?goname}}")
|
||||
rpm.expand("%{echo: gourl: %{?gourl}}")
|
||||
rpm.expand("%{echo: gosource: %{?gosource}}")
|
||||
end}
|
||||
BuildRequires: compiler(go-compiler)
|
||||
ExclusiveArch: %{go_arches}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user