diff options
-rw-r--r-- | .gitignore | 23 | ||||
-rw-r--r-- | Makefile.am | 30 | ||||
-rw-r--r-- | NEWS | 213 | ||||
-rwxr-xr-x | autogen.sh | 2 | ||||
-rwxr-xr-x | brp-mangle-shebangs | 72 | ||||
-rw-r--r-- | build.macros.in | 513 | ||||
-rw-r--r-- | configure.ac | 26 | ||||
-rw-r--r-- | devel.prov | 2 | ||||
-rw-r--r-- | devel.req | 4 | ||||
-rwxr-xr-x | find-provides.in | 2 | ||||
-rwxr-xr-x | find-requires.in | 2 | ||||
-rwxr-xr-x | fix-libtool-from-moving-options-after-libs | 2 | ||||
-rwxr-xr-x | force-as-needed-for-shared-lib-in-libtool | 2 | ||||
-rwxr-xr-x | git-repository--after-tarball | 70 | ||||
-rwxr-xr-x | git-repository--apply-patch | 158 | ||||
-rwxr-xr-x | info-file.req | 5 | ||||
-rw-r--r-- | info.attr | 3 | ||||
-rw-r--r-- | macros.gnome.in | 22 | ||||
-rw-r--r-- | macros.in | 481 | ||||
-rw-r--r-- | rpm-spec-mode.el | 970 | ||||
-rw-r--r-- | rpmrc.in | 114 | ||||
-rwxr-xr-x | tests.sh | 2 | ||||
-rwxr-xr-x | tests/macros.sh | 2 |
23 files changed, 1384 insertions, 1336 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d1969d6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,23 @@ +rpm-mageia-setup-*.tar.* +*.patch +.deps/ +Makefile +Makefile.in +aclocal.m4 +autom4te.cache/ +compile +config.guess +config.log +config.status +config.sub +configure +depcomp +install-sh +libtool +ltmain.sh +m4/ +macros-perarch +make_arch_macrosfiles.sh +missing +rpmgenplatform +*~ diff --git a/Makefile.am b/Makefile.am index 619d682..2f7673b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -7,14 +7,11 @@ pkg_gdata = \ macros \ rpmrc -pkg_sysconf_macros_tmp = \ - build.macros - pkg_data_in = $(pkg_gdata:=.in) -pkg_sysconf_macros_in = $(pkg_sysconf_macros_tmp:=.in) +pkg_macrosd = macros.gnome -pkg_sysconf_macros = $(pkg_sysconf_macros_tmp) +pkg_macrosd_in = $(pkg_macrosd:=.in) pkg_gconfig = \ platform \ @@ -28,10 +25,7 @@ pkg_scripts = \ fix-libtool-from-moving-options-after-libs \ fix-libtool-ltmain-from-overlinking \ force-as-needed-for-shared-lib-in-libtool \ - git-repository--after-tarball \ - git-repository--apply-patch \ http.req \ - info-file.req \ multiarch.req \ perl_base.req \ perl.prov \ @@ -48,13 +42,12 @@ pkg_scripts_in = $(pkg_gscripts:=.in) pkg_attr_defs = \ devel.attr \ - info.attr \ multiarch.attr \ perl_base.attr \ perl_from_meta.attr \ php.attr -redhat_defs = \ +redhat_scripts = \ brp-mangle-shebangs BUILT_SOURCES = macros-perarch make_arch_macrosfiles.sh rpmgenplatform @@ -80,11 +73,11 @@ foobar_pkglib_SCRIPTS = \ EXTRA_DIST = \ $(pkg_data_in) \ - $(pkg_sysconf_macros_in) \ + $(pkg_macrosd_in) \ $(pkg_attr_defs) \ $(pkg_scripts) \ $(pkg_scripts_in) \ - $(redhat_defs) \ + $(redhat_scripts) \ macros-perarch.in make_arch_macrosfiles.sh.in \ rpmgenplatform.in rpmrc.in \ rpm-spec-mode.el \ @@ -100,6 +93,7 @@ edit = sed \ -e 's,@CANONTARGETCPU\@,$(CANONTARGETCPU),g' \ -e 's,@CANONTARGETGNU\@,$(CANONTARGETGNU),g' \ -e 's,@ARMV7CANONTARGETCPU\@,$(ARMV7CANONTARGETCPU),g' \ + -e 's,@ARMV8CANONTARGETCPU\@,$(ARMV8CANONTARGETCPU),g' \ -e 's,@RPMALLARCH\@,$(RPMALLARCH),g' \ -e 's,@DISTSUFFIX\@,$(DISTSUFFIX),g' @@ -116,7 +110,7 @@ platform: rpmgenplatform Makefile platform32: rpmgenplatform Makefile perl rpmgenplatform $(CANONTARGETCPU32) > $@ -install-data-local: $(arch_macrosfiles) $(pkg_gconfig) $(pkg_sysconf_macros_tmp) +install-data-local: $(arch_macrosfiles) $(pkg_gconfig) $(pkg_macrosd) if ONLY_RPMRC echo "not installing per-arch macros which are already in rpmrc and standard rpm per-arch macros" else @@ -126,14 +120,14 @@ else done endif [ -d $(DESTDIR)$(RPMSYSCONFDIR)/macros.d ] || $(mkinstalldirs) $(DESTDIR)$(RPMSYSCONFDIR)/macros.d - for i in $(pkg_sysconf_macros); do \ - $(install_sh_DATA) $${i} $(DESTDIR)$(RPMSYSCONFDIR)/macros.d/$${i}; \ + for i in $(pkg_macrosd); do \ + $(install_sh_DATA) $${i} $(DESTDIR)$(RPMLIBDIR)/macros.d/$${i}; \ done for i in $(pkg_attr_defs); do \ $(install_sh_DATA) $${i} $(DESTDIR)$(RPMLIBDIR)/fileattrs/$${i}; \ done - for i in $(redhat_defs); do \ - $(install_sh_DATA) $${i} $(DESTDIR)$(RPMLIBDIR)/redhat/$${i}; \ + for i in $(redhat_scripts); do \ + $(install_sh_SCRIPT) $${i} $(DESTDIR)$(RPMLIBDIR)/redhat/$${i}; \ done if RPMPLATFORM for i in $(pkg_gconfig); do \ @@ -148,5 +142,5 @@ test: $(pkg_gdata) $(pkg_gscripts) $(arch_macrosfiles) $(pkg_gconfig) sh tests.sh CLEANFILES = $(pkg_gdata) $(pkg_gscripts) $(arch_macrosfiles) $(pkg_gconfig)\ - macros-perarch $(pkg_sysconf_macros_tmp) \ + macros-perarch $(pkg_macrosd) \ make_arch_macrosfiles.sh @@ -1,3 +1,216 @@ +Version 2.75.1 - 24 March 2024, by Jani Välimaa +- configure: force armv7hl target arch when building for armv7hl with armv8l/aarch64 host machine +- macros: make _host_cpu identical with _target_cpu as ATM rpm uses real build + host's arch and it can be different what we really want (armv8l vs. armv7hl) + +Version 2.75 - 23 March 2024, by Jani Välimaa +- Makefile: fix brp-mangle-shebangs install +- rpmrc: use -mtune=generic-armv7-a with armv7hl +- rpmrc: set aapcs-linux ARM ABI for armv7 arches +- rpmrc: explicitly select 32-bit or 64-bit build on ix86 and x86_64 architectures +- rpmrc: update build arch for i686 cabable arches +- rpmrc: add SSE2 support to i686 default flags + +Version 2.74.2 - 29 February 2024, by Jani Välimaa +- rpmrc: remove -fstack-clash-protection from armv7 default flags + +Version 2.74.1 - 23 February 2024, by Jani Välimaa +- rpmrc: remove -fcf-protection=full from i586 default flags (needs i686 or newer) + +Version 2.74 - 23 February 2024, by Jani Välimaa +- rpmeval: fix build with gcc13 +- rpmrc: add -fstack-clash-protection to default flags for all supported arches +- rpmrc: add -fcf-protection=full to x86 default flags +- rpmrc: add -mbranch-protection=standard to aarch64 default flags +- rpmrc: drop arches we don't really support +- rpmrc: drop arch_compat also available in /usr/lib/rpm/rpmrc +- macros: use -fstack-protector-strong instead of '-fstack-protector --param=ssp-buffer-size=4' in %_ssp_cflags +- macros: simplify %serverbuild macro +- macros: use -Wl,-z,now with -Wl,-z,relro unless _disable_ld_now is defined +- mangle script shebangs + +Version 2.73 - 22 November 2023, by Jani Välimaa +- macros: include RUSTFLAGS in %set_build_flags +- macros: set -g when building Vala applications +- macros: make _FORTIFY_SOURCE flags configurable via %_fortify_level variable +- macros: undefine _FORTIFY_SOURCE before defining it to avoid build warnings on some packages defining it already + +Version 2.72 - 18 November 2023, by Jani Välimaa +- macros: define _use_weak_usergroup_deps to only add user() and group() requires as recommends + +Version 2.71 - 15 January 2023, by Jani Välimaa +- brp-mangle-shebangs: also mangle shebangs of JavaScript executables (rhbz#1998924) +- macros: drop unused %_sys_macros_dir and %build_sysmacrospath() + +Version 2.70 - 7 January 2023, by Jani Välimaa +- macros: drop separate macros.build and combine it with macros + +Version 2.69 - 7 January 2023, by Jani Välimaa +- macros.build: rename from build.macros +- macros.gnome: really add to dist + +Version 2.68 - 7 January 2023, by Jani Välimaa +- add macros.gnome to introduce %url_ver and %tarball_version macros +- rpm-spec-mode.el: sync script and tag lists with rpm >= 4.12.90 +- rpm-spec-mode.el: fix compatibility with Emacs 28.1, + patch from https://github.com/stigbjorlykke/rpm-spec-mode/pull/17 + +Version 2.67 - 3 September 2022, by Jani Välimaa +- replace obsolescent egrep with 'grep -E' in devel.prov and devel.req + +Version 2.66 - 19 June 2022, by Jani Välimaa +- build.macros: use -Wl,--build-id=sha1 with %build_ldflags + +Version 2.65 - 10 April 2022, by Jani Välimaa +- build.macros: remove macro definitions living in python-rpm-macros + - py_auto_byte_compile + - _python_bytecompile_errors_terminate_build + - _python_bytecompile_extra + +Version 2.64 - 10 April 2022, by Jani Välimaa +- build.macros: use %__os_install_post_python in %__os_install_post + +Version 2.63 - 10 April 2022, by Jani Välimaa +- build.macros: remove %__brp_python_bytecompile as it lives now in python-rpm-macros + +Version 2.62 - 17 October 2021, by Jani Välimaa +- configure.ac: update and modernize with autoconf 2.71 +- build.macros: export LT_SYS_LIBRARY_PATH with %set_build_flags to prevent libtool hardcoding %_libdir into the binaries' RPATH (originally from Fedora) + +Version 2.61 - 7 September 2021, by Jani Välimaa +- brp-mangle-shebang: fix handling of files without newlines (from Fedora) +- build.macros: run /usr/lib/rpm/brp-remove-la-files after %install (available since RPM 4.17.0) +- build.macros: run /usr/lib/rpm/check-rpaths after %install + +Version 2.60 - 23 June 2021, by Thierry Vignaud +- Drop __brp_python_hardlink for rpm-4.17beta1 + +Version 2.59 - 1 June 2021, by Thierry Vignaud +- Drop __brp_strip_shared for rpm-4.17a1 + +Version 2.58 - 13 March 2021, by Jani Välimaa +- disable python byte compilation outside python dirs by default (set _python_bytecompile_extra to 0) +- rpm-spec-mode.el: update to version 0.16 + +Version 2.57 - 23 June 2020, by Thierry Vignaud +- %rename: + o don't obsolete what is provided (mga#26801) + o take a 2nd arg to set the VR to obsolete + +Version 2.56 - 1 June 2020, by Jani Välimaa +- build.macros: add _configure_gnuconfig_hack macro based on one from Fedora to update config.{guess,sub} + +Version 2.55 - 21 May 2020, by Jani Välimaa +- build.macros: add _legacy_common_support macro for adding -fcommon to compiler flags +- build.macros: run /usr/lib/rpm/check-buildroot at end of %install scriptlet + via __arch_install_post + +Version 2.54 - 14 April 2020, by Thierry Vignaud +- stop emiting requires(posttrans) on info-install (less container bloat) + +Version 2.53 - 1 February 2020, by Thierry Vignaud +- build.macros: restore '--without <section>' rpmbuild functionality + (which is very useful in order to work on huge packages before submiting them + to BS) + +Version 2.52 - 4 February 2020, by Jani Välimaa +- build.macros: remove '--without <section>' rpmbuild functionality +- build.macros: add __spec_install_post + +Version 2.51 - 3 February 2020, by Jani Välimaa +- rpmrc: use _ssp_cflags also with arm optflags +- build.macros: drop pyver macro (moved to python-rpm-macros) +- build.macros: drop unused macros + - _package_i18n() + - py_platlibdir + - py_purelibdir + - py_platsitedir + - py_puresitedir + - perl_sitearch + - perl_archlib + +Version 2.50 - 16 January 2020, by Jani Välimaa +- build.macros: add mistakenly removed --prefix= back to configure macro + +Version 2.49 - 16 January 2020, by Jani Välimaa +- build.macros: replace configure2_5x with configure macro + - sync configure macro with rpm upstream +- build.macros: drop legacy libtoolize calls from configure macros +- build.macros: drop legacy --x-includes= and --x-libraries= from configure macros +- build.macros: drop deprecated and unused macros + - __cputoolize + +Version 2.48 - 2 January 2020, by Jani Välimaa +- build.macros: add build_* flags and set_build_flags macro from upstream rpm +- build.macros: add __global_* macros for compatibility with Fedora +- build.macros: drop deprecated and unused macros + - __chkconfig + - __service + - _update_menus_bin + - _update_desktop_database_bin + - _update_mime_database_bin + - _scrollkeeper_bin + - make_session + - make_dm_session + - post_install_gconf_schemas + - update_menus + - clean_menus + - update_desktop_database + - clean_desktop_database + - update_mime_database + - clean_mime_database + - update_scrollkeeper + - clean_scrollkeeper +- build.macros: use rpm built-in %{warn:...} macro for deprecation warnings +- remove unused git-repository--after-tarball and git-repository--apply-patch +- build.macros: remove %_after_setup leftovers after + introduce-_after_setup-which-is-called-after-setup.patch was removed from rpm +- rpmrc: drop deprecated macrofiles line + +Version 2.47 - 25 December 2019, by Jani Välimaa +- replace %setup_compile_flags with upstream %set_build_flags and + output deprecation warning if %setup_compile_flags is used + +Version 2.46 - 24 December 2019, by Jani Välimaa + +- make brp-mangle-shebangs to not exit if 'read shebang_line < "$f"' + exits with a non-zero status. + +Version 2.45 - 23 December 2019, by Thierry Vignaud + +- switch binary payload compression to Zstandard level 19 + for faster installations + See https://fedoraproject.org/wiki/Changes/Switch_RPMs_to_zstd_compression +- sync brp-mangle-shebangs with FC: + o do not stat / touch files needlessly + o fix unsafe/incorrect command expansion + o brp-mangle-shebangs: speed up finding of "text executables" (scripts) + o Make ambiguous python shebangs error + +Version 2.44 - 15 October 2019, by Pascal Terjan + +- previous change worked manually on my mga7 but doesn't seem to work in cauldron + chroot in iurt. Try harder. + +Version 2.43 - 15 October 2019, by Pascal Terjan + +- make armv7hl chroots on aarch64 work on all armv8 flavours + +Version 2.42 - 15 October 2019, by Pascal Terjan + +- actually make armv7hl chroots on aarch64 work as expected + +Version 2.41 - 19 September 2019, by Thierry Vignaud + +- fix %__libtoolize disapearing in rpm-4.15 (mga#25440) + +Version 2.40 - 29 August 2019, by Thierry Vignaud + +- move files from /etc/rpm/macros.d into /usr/lib/rpm/macros.d thus fixing most + issues with rpm's testsuite (related to not being able to disable debuginfo) + +Version 2.39 - 4 May 2019, by Pascal Terjan + - make armv7hl chroots on aarch64 work as expected (urpmi accepts to install armv7hl packages and default rpm build target is armv7hl) @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/sh aclocal libtoolize --force --copy automake -a -c diff --git a/brp-mangle-shebangs b/brp-mangle-shebangs index ecf8ae7..f27ad73 100755 --- a/brp-mangle-shebangs +++ b/brp-mangle-shebangs @@ -1,4 +1,4 @@ -#!/bin/bash -eu +#!/usr/bin/bash -eu # If using normal root, avoid changing anything. if [ -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" ]; then @@ -70,13 +70,17 @@ done cd "$RPM_BUILD_ROOT" -trim() { - printf '%s' "$*" -} - +# Large packages such as kernel can have thousands of executable files. +# We take care to not fork/exec thousands of "file"s and "grep"s, +# but run just two of them. +# (Take care to exclude filenames which would mangle "file" output). +find -executable -type f ! -path '*:*' ! -path $'*\n*' \ +| file -N --mime-type -f - \ +| grep -P ".+(?=: (text/|application/javascript))" \ +| { fail=0 -while IFS= read -r -d $'\0' f; do - file -N --mime-type "$f" | grep -q -P ".+(?=: text/)" || continue +while IFS= read -r line; do + f=${line%%:*} # Remove the dot path="${f#.}" @@ -88,24 +92,41 @@ while IFS= read -r -d $'\0' f; do echo "$path" | grep -q -E -f "$exclude_files_from" && continue fi - ts=$(stat -c %y "$f") - read shebang_line < "$f" || : - orig_shebang=$(trim $(echo "$shebang_line" | grep -Po "#!\K.*" || echo)) - shebang="$orig_shebang" - if [ -n "$exclude_shebangs" ]; then - echo "$shebang" | grep -q -E "$exclude_shebangs" && continue + if ! read shebang_line < "$f"; then + echo >&2 "*** WARNING: Cannot read the first line from $f, removing executable bit" + ts=$(stat -c %y "$f") + chmod -x "$f" + touch -d "$ts" "$f" + continue fi - if [ -n "$exclude_shebangs_from" ]; then - echo "$shebang" | grep -q -E -f "$exclude_shebangs_from" && continue + + orig_shebang="${shebang_line#\#!}" + if [ "$orig_shebang" = "$shebang_line" ]; then + echo >&2 "*** WARNING: $f is executable but has no shebang, removing executable bit" + ts=$(stat -c %y "$f") + chmod -x "$f" + touch -d "$ts" "$f" + continue fi + # Trim spaces + while shebang="${orig_shebang// / }"; [ "$shebang" != "$orig_shebang" ]; do + orig_shebang="$shebang" + done + # Treat "#! /path/to " as "#!/path/to" + orig_shebang="${orig_shebang# }" + + shebang="$orig_shebang" + if [ -z "$shebang" ]; then - echo >&2 "*** WARNING: $f is executable but has empty or no shebang, removing executable bit" + echo >&2 "*** WARNING: $f is executable but has empty shebang, removing executable bit" + ts=$(stat -c %y "$f") chmod -x "$f" touch -d "$ts" "$f" continue - elif [ -n "${shebang##/*}" ]; then + fi + if [ -n "${shebang##/*}" ]; then echo >&2 "*** ERROR: $f has shebang which doesn't start with '/' ($shebang)" fail=1 continue @@ -116,10 +137,10 @@ while IFS= read -r -d $'\0' f; do fi # Replace "special" env shebang: - # /whatsoever/env /whatever/foo → /whatever/foo - shebang=$(echo "$shebang" | sed -r -e 's@^(.+)/env /(.+)$@/\2@') - # /whatsoever/env foo → /whatsoever/foo - shebang=$(echo "$shebang" | sed -r -e 's@^(.+/)env (.+)$@\1\2@') + # /whatsoever/env -whatever /whatever/foo → /whatever/foo + shebang=$(echo "$shebang" | sed -r -e 's@^(.+)/env( -[^ ]+)* /(.+)$@/\3@') + # /whatsoever/env -whatever foo → /whatsoever/foo + shebang=$(echo "$shebang" | sed -r -e 's@^(.+/)env( -[^ ]+)* (.+)$@\1\3@') # If the shebang now starts with /bin, change it to /usr/bin # https://bugzilla.redhat.com/show_bug.cgi?id=1581757 @@ -130,12 +151,15 @@ while IFS= read -r -d $'\0' f; do if [ "$shebang" != "$py_shebang" ]; then echo >&2 "*** ERROR: ambiguous python shebang in $path: #!$orig_shebang. Change it to python3 (or python2) explicitly." + fail=1 elif [ "#!$shebang" != "#!$orig_shebang" ]; then - sed -i -e "1c #!$shebang" "$f" echo "mangling shebang in $path from $orig_shebang to #!$shebang" + ts=$(stat -c %y "$f") + sed -i -e "1c #!$shebang" "$f" + touch -d "$ts" "$f" fi - touch -d "$ts" "$f" -done < <(find -executable -type f -print0) +done exit $fail +} diff --git a/build.macros.in b/build.macros.in deleted file mode 100644 index c9c1491..0000000 --- a/build.macros.in +++ /dev/null @@ -1,513 +0,0 @@ - -%_sys_macros_dir @RPMSYSCONFDIR@/macros.d -%build_sysmacrospath() %{_sys_macros_dir}/%{?1:%{1}}%{?!1:%{name}}.macros - -# when %_with_git_repository is set, these macros modify the behaviour of "%prep" step: -%_after_setup %{?_with_git_repository:GIT_URL="%{?git_url}" GIT_REPOSITORY_CACHE=%{?git_repository_cache} @RPMVENDORDIR@/git-repository--after-tarball} -%_patch %{?_with_git_repository:PKG_NAME=%{name} @RPMVENDORDIR@/git-repository--apply-patch}%{?!_with_git_repository:%__patch -U} - -# used by "git-repository--after-tarball": -%git_repository_cache %_topdir/%{name}.git - - -# Various programs used in rpm scripts -%_update_desktop_database_bin %{_bindir}/update-desktop-database -%_update_mime_database_bin %{_bindir}/update-mime-database -%_update_icon_cache_bin %{_bindir}/gtk-update-icon-cache -%_gconftool_bin %{_bindir}/gconftool-2 -%_scrollkeeper_bin %{_bindir}/scrollkeeper-update - -%__service /sbin/service -%__chkconfig /sbin/chkconfig - -#============================================================================== -# ---- Required rpmrc macros. -# Macros that used to be initialized as a side effect of rpmrc parsing. -# These are the default values that can be overridden by other -# (e.g. per-platform, per-system, per-packager, per-package) macros. -# - -%ix86 i386 i486 i586 i686 pentium3 pentium4 athlon k6 - -# Multilibs -%_multilibpatt (/%{_lib}|/usr/%{_lib}(|/gconv)|/usr/local/%{_lib}|/usr/X11R6/%{_lib}|/opt/%{_lib})/[^/]*\\.([oa]|la|so[0-9.]*)$ - -%_arch_tag_suffix %([ "%{?_lib}" = "lib64" ] && echo "()(64bit)") -%arch_tagged() %{1}%{_arch_tag_suffix} %{?2:%{2} %{3}%{?!3:%{error:undefined 3rd argument in arch_tagged}}} - -# Games macros -%_gamesdir games -%_gamesbindir %{_prefix}/%{_gamesdir} -%_gamesdatadir %{_datadir}/%{_gamesdir} - -# Menu directories -%_menudir %{_prefix}/lib/menu -%_iconsdir %{_datadir}/icons -%_miconsdir %{_datadir}/icons/mini -%_liconsdir %{_datadir}/icons/large - -%_xfontdir %_datadir/fonts - -%_webconfdir %{_sysconfdir}/httpd/conf -%_webappconfdir %_webconfdir/sites.d -# compatibility -%webappconfdir %_webappconfdir - -# For Appdata metainfo -%_metainfodir %{_datadir}/metainfo - -#============================================================================== -# ---- Build configuration macros. -# -# Package version macro. -# The type of package to produce, for compatibility with legacy -# versions of rpm. -# -# Script gets packaged file list on input. -# Returns list of multiarch files that are not marked as such, -# i.e. files in $RPM_BUILD_ROOT that have arch-dependent values -# -# Note: Disable (by commenting out) for legacy compatibility. -#%__check_multiarch_files @RPMLIBDIR@/check-multiarch-files %{buildroot} - -# stuff below has been deprecated by rpm filetriggers [June 2008] -%update_menus %{nil} -%clean_menus %{nil} -%update_desktop_database %{nil} -%clean_desktop_database %{nil} -%update_mime_database %{nil} -%clean_mime_database %{nil} -%update_scrollkeeper %{nil} -%clean_scrollkeeper %{nil} - -# Update Menu -%_update_menus_bin %{_bindir}/update-menus - -# Update Window Managers session. -%_fndsession_bin %{_sbindir}/fndSession -%make_session %{nil} -%make_dm_session if [ -x %{_fndsession_bin} ]; then %{_fndsession_bin} || true ; fi \ -%{nil} - -# For rebuilding gcj-db -%_rebuildgcjdb_bin %{_bindir}/rebuild-gcj-db -%update_gcjdb if [ -x %{_rebuildgcjdb_bin} ]; then %{_rebuildgcjdb_bin} || true ; fi \ -%{nil} - -%clean_gcjdb if [ -x %{_rebuildgcjdb_bin} ]; then %{_rebuildgcjdb_bin} || true ; fi \ -%{nil} - -# Rebuild icon cache -# -# following themes are handled through filetriggers: -%icon_cache_through_filetrigger_hicolor 1 -%icon_cache_through_filetrigger_gnome 1 -%icon_cache_through_filetrigger_oxygen 1 - -%update_icon_cache() %{expand: %%{!?icon_cache_through_filetrigger_%1:if [ -x %%{_update_icon_cache_bin} ]; then \ -%%{_update_icon_cache_bin} --force --quiet %%{_iconsdir}/%%{1} || true; fi \ -%%{nil}}} - -%clean_icon_cache() %{expand: %%{!?icon_cache_through_filetrigger_%1:if [ -x %%{_update_icon_cache_bin} -a -r %%{_iconsdir}/%%{1}/index.theme ]; then \ -%%{_update_icon_cache_bin} --force --quiet %%{_iconsdir}/%%{1} || true ; fi \ -%%{nil}}} - -# GConf schemas: -# installation is handled by filetriggers -%post_install_gconf_schemas() %{nil} -# but uninstall still need to be done in %preun: -%preun_uninstall_gconf_schemas() if [ "$1" = "0" -a -x %{_gconftool_bin} ]; then \ -SCHEMAS="" \ -for SCHEMA in %{*} ; do \ - SCHEMAS="$SCHEMAS %{_sysconfdir}/gconf/schemas/$SCHEMA.schemas" \ -done \ -GCONF_CONFIG_SOURCE=`%{_gconftool_bin} --get-default-source` %{_gconftool_bin} --makefile-uninstall-rule $SCHEMAS > /dev/null || true ; fi \ -%{nil} - -# Mageia Linux version -# - "9.1" => 910 -# - "10.2.2" => 1022 -# (user may copy the following line in specfile) -%mgaversion %distro_release - -%distsuffix @DISTSUFFIX@ - -%__dist_ident %{?distsuffix:%distsuffix}%{?!distsuffix:.mga}%{?distro_release:%distro_release} - -%__distro_section %{?distro_section:%distro_section}%{?!distro_section:core} - -%mkrel(c:) %{-c: 0.%{-c*}.}%{1}%{?subrel:.%subrel}%{?dist:%dist}%{?!dist:%__dist_ident}%([ "%{__distro_section}" != "core" ] && echo .%__distro_section) - -%_logdir %{_var}/log -%_localstatedir /var - -%_pkgdocdir %{_docdir}/%{name} -%_docdir_fmt %%{NAME} - -# Include minimal debug information in build binaries. -# Requires _enable_debug_packages. -# -%_enable_debug_packages 1 -%_include_minidebuginfo 1 -%_include_gdb_index 1 -%_debugsource_packages 1 -%_debuginfo_subpackages 1 - - -#------------------------------------------------------------------------------ -# definions merged from manbo-setup-build -# - -# Default extension to use (for info files) -%_extension .xz - -%__install_info /sbin/install-info - -%_install_info() if [[ -f %{_infodir}/%{1}%{_extension} ]]; then %{__install_info} %{_infodir}/%{1}%{_extension} --dir=%{_infodir}/dir; fi \ -%{nil} -# (nb: keep the "alone on its line ';'") -%_remove_install_info() if [ "$1" = "0" ]; then if [[ -f %{_infodir}/%{1}%{_extension} ]]; then %{__install_info} %{_infodir}/%{1}%{_extension} --dir=%{_infodir}/dir --remove ; fi; fi \ -%{nil} - - -# Macro: %{mklibname <name> [<major> [<minor>]] [-s] [-d]} -# - %{mklibname test} => lib64test, on a lib64 platform -# - %{mklibname test 1 -d} => libtest1-devel -# - %{mklibname test 1 -d 0 -s} => libtest1_0-static-devel -%mklibname(ds) %{_lib}%{1}%{?2:%{2}}%{?3:_%{3}}%{-s:-static}%{-d:-devel} - -# Dynamic EVRD tags macro for use with versioned provides/requires in place of -# '%{version}-%{release}', ie. to automatically add distepoch or epoch if present -%EVRD %{?epoch:%{epoch}:}%{?version:%{version}}%{?release:-%{release}}%{?distepoch::%{distepoch}} - -#============================================================================== -# ---- compiler flags. - -# C compiler flags. This is traditionally called CFLAGS in makefiles. -# Historically also available as %%{optflags}, and %%build sets the -# environment variable RPM_OPT_FLAGS to this value. - -%debugcflags %{?_enable_debug_packages:-g} - -%_fortify_cflags -Wp,-D_FORTIFY_SOURCE=2 - -# cf http://wiki.mandriva.com/en/Development/Packaging/Problems#format_not_a_string_literal_and_no_format_arguments -%Werror_cflags -Wformat -Werror=format-security - -%_ssp_cflags -fstack-protector --param=ssp-buffer-size=4%{?_serverbuild_flags: %_serverbuild_flags} -%__common_cflags -O2 %{debugcflags} -pipe %{Werror_cflags} %{?_fortify_cflags} -%__common_cflags_with_ssp %{__common_cflags} %{?_ssp_cflags} - -# Servers opt flags. -# Also set the env variables for backward compatibility (mdv #32050). -%serverbuild %define _serverbuild_flags -fstack-protector-all \ -export CFLAGS="%optflags"; export CXXFLAGS="%optflags"; export RPM_OPT_FLAGS="%optflags" \ -%{nil} - -%make \ - echo "warning: %%make is deprecated, try %%make_build instead" 1>&2\ - %{__make} -O %_smp_mflags - -%makeinstall_std \ - echo "warning: %%makeinstall_std is deprecated, try %%make_install instead" 1>&2\ - make DESTDIR=%{?buildroot:%{buildroot}} install - -%__fix_libtool_ltmain_from_overlinking @RPMVENDORDIR@/fix-libtool-ltmain-from-overlinking -%__fix_libtool_from_moving_options_after_libs @RPMVENDORDIR@/fix-libtool-from-moving-options-after-libs -%__fix_dlsearch_path_in_libtool_for_multilib @RPMVENDORDIR@/fix-dlsearch-path-in-libtool-for-multilib - -%__cputoolize cputoolize - -%__libtoolize_configure %{?__libtoolize:(cd $CONFIGURE_TOP; [ ! -f configure.in -a ! -f configure.ac ] || %{__libtoolize} --copy --force)} - -%ldflags %{?!_disable_ld_as_needed: -Wl,--as-needed}%{?!_disable_ld_no_undefined: -Wl,--no-undefined}%{?!_disable_ld_relro: -Wl,-z,relro}%{?!_disable_ld_O1: -Wl,-O1}%{?!_disable_ld_build_id: -Wl,--build-id}%{?!_disable_ld_enable_new_dtags: -Wl,--enable-new-dtags} - -%setup_compile_flags \ - CFLAGS="${CFLAGS:-%optflags}" ; export CFLAGS ; \ - CXXFLAGS="${CXXFLAGS:-%optflags}" ; export CXXFLAGS ; \ - FFLAGS="${FFLAGS:-%optflags}" ; export FFLAGS ; \ - LDFLAGS="${LDFLAGS:-%ldflags}" ; export LDFLAGS - -%before_configure \ - %setup_compile_flags \ - CONFIGURE_TOP="${CONFIGURE_TOP:-.}"; \ - %{?!_disable_ld_as_needed:@RPMVENDORDIR@/force-as-needed-for-shared-lib-in-libtool ;} \ - %{?!_disable_ld_no_undefined:@RPMVENDORDIR@/drop-ld-no-undefined-for-shared-lib-modules-in-libtool ;} \ - %{__fix_libtool_ltmain_from_overlinking} ; \ - %{__fix_libtool_from_moving_options_after_libs} $CONFIGURE_TOP ; \ - %{__fix_dlsearch_path_in_libtool_for_multilib} $CONFIGURE_TOP %{_lib} - -# This is an improved version of %configure (from PLD team). -%main_configure \ - %before_configure ; \ - %{?_legacy_autotools:%{?!_disable_libtoolize:%{?__libtoolize_configure:%{__libtoolize_configure};}}} \ - %{!?_legacy_autotools:%{?_enable_libtoolize:%{?__libtoolize_configure:%{__libtoolize_configure};}}} \ - [ -f $CONFIGURE_TOP/configure.in -o -f $CONFIGURE_TOP/configure.ac ] && \ - CONFIGURE_XPATH="--x-includes=%{_prefix}/include --x-libraries=%{_prefix}/%{_lib}" \ - $CONFIGURE_TOP/configure %{!?_legacy_autotools:--build=}%{_target_platform} \\\ - %{?_program_prefix:--program-prefix=%{_program_prefix}} \\\ - --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} \\\ - $CONFIGURE_XPATH - -# Implement configure shims -%configure \ - %define _legacy_autotools 1 \ - %main_configure - -%configure2_5x \ - %main_configure - - -# Maximum number of CPU's to use when building, 0 for unlimited. -%_smp_ncpus_max 0 - -#============================================================================== -# ---- Build policy macros. -# -# -#--------------------------------------------------------------------- -# Expanded at beginning of %install scriptlet. -# - - -#============================================================================== -# ---- specfile macros. -# Macro(s) here can be used reliably for reproducible builds. -# (Note: Above is the goal, below are the macros under development) -# - -#------------------------------------------------------------------------------ -# Useful python macros -%pyver %(python -V 2>&1 | cut -f2 -d" " | cut -f1,2 -d".") - -#------------------------------------------------------------------------------ -# Useful perl macros -# (initially from Artur Frysiak <wiget@t17.ds.pwr.wroc.pl>) -# (modified by Pixel <pixel@mandriva.com>) -# -# [...] -# Group: Development/Perl -# [...] -# %build -# perl Makefile.PL INSTALLDIRS=vendor -# %make -# [...] -# %install -# rm -rf $RPM_BUILD_ROOT -# make install PREFIX="$RPM_BUILD_ROOT/%{prefix}" -# [...] -# %files -# %defattr(644,root,root,755) -# %{perl_vendorlib}/CGI -# or -# %{perl_vendorarch}/DBI -# %{perl_vendorarch}/auto/DBI -# %{_mandir}/*/* -# - - -%perl_convert_version() %(perl -Mversion -le ' - $x = "%{1}"; - $y = $x; - $x =~ s/[[:alpha:]]*$//; - $y =~ s/^$x//; - $x =~ s/\D*$//; - $v = version->new($x)->normal; - $v =~ s/^v//; - print "$v$y"; -') - -# kept for compatibility, but should not be used, especially the ugly perl_archlib! -%perl_sitearch %(eval "`perl -V:installsitearch`"; echo $installsitearch) -%perl_archlib %(eval "`perl -V:installarchlib`"; echo $installarchlib) - -#-------------------------------------------------------------------------------- -# Macro from conectiva - -%rename() \ -Obsoletes: %{1} <= %{?epoch:%epoch}%{?!epoch:0}:%{version}-%{release} \ -Provides: %{1} = %{?epoch:%epoch}%{?!epoch:0}:%{version}-%{release} - -# Shorthand for %{defined with_...} -# macros provided by rpm 4.4, but buggy :( -%_with() %{expand: %%{?_with_%1:1} %%{!?_with_%1: %%{?_without_%1:0} %%{!?_without_%1: %%{?with_%1:%%{with_%1}} %%{!?with_%1: %%{?without_%1:!%%{without_%1}} %%{!?without_%1: %%{?2:%%2} %%{!?2:1} } } } } } -%_without() !%{expand: %%{with %1 %{?2:%2}}} - -%_package_i18n(g:f:) \ -%%package -n %{?1:%{1}}%{?!1:%{name}}-i18n\ -Summary: Internationalization and locale data for %{?1:%{1}}%{?!1:%{name}}\ -License: %{license}\ -Group: %{?-g:%{-g*}}%{?!-g:%{group}}\ -\ -%%description -n %{?1:%{1}}%{?!1:%{name}}-i18n\ -Internationalization and locale data for %{?1:%{1}}%{?!1:%{name}}\ -\ -%%files -n %{?1:%{1}}%{?!1:%{name}}-i18n %{?-f:%{-f}}%{?!-f:-f %{?1:%{1}}%{?!1:%{name}}.lang}\ -%{nil} - - -#------------------------------------------------------------------------------ -# Python specific macros - -# More Python specific macro definitions (originally from PLD). -# -# backward compatibility -%py_platlibdir %(python -c 'import distutils.sysconfig; print distutils.sysconfig.get_python_lib(standard_lib=1,plat_specific=1)' 2>/dev/null || echo PYTHON-LIBDIR-NOT-FOUND) -%py_purelibdir %(python -c 'import distutils.sysconfig; print distutils.sysconfig.get_python_lib(standard_lib=1,plat_specific=0)' 2>/dev/null || echo PYTHON-LIBDIR-NOT-FOUND) -%py_platsitedir %(python -c 'import distutils.sysconfig; print distutils.sysconfig.get_python_lib(plat_specific=1)' 2>/dev/null || echo PYTHON-LIBDIR-NOT-FOUND) -%py_puresitedir %(python -c 'import distutils.sysconfig; print distutils.sysconfig.get_python_lib()' 2>/dev/null || echo PYTHON-LIBDIR-NOT-FOUND) - -#------------------------------------------------------------------------------ -# Java Macros -# - -%gcj_support 0 -%gcj_native \ -%if %{gcj_support} \ -BuildRequires: java-gcj-compat-devel \ -%else \ -BuildArch: noarch \ -%endif - -%aot_compile_rpm_bin %{_bindir}/aot-compile-rpm - -%gcj_compile \ -%if %{gcj_support} \ -%aot_compile_rpm_bin \ -%endif - -%gcj_files \ -%if %{gcj_support} \ -%dir %{_libdir}/gcj/%{name} \ -%attr(-,root,root) %{_libdir}/gcj/%{name}/* \ -%endif - -%remove_java_binaries \ -find . -name "*.jar" -delete - -%create_jar_links() \ -pushd %{buildroot}%{_javadir}; \ -for jar in *-%{version}.jar; do ln -sf ${jar} ${jar/-%{version}/}; done \ -popd - -#------------------------------------------------------------------------------ -# Ocaml macro -# - -%ocaml_sitelib %(if [ -x /usr/bin/ocamlc ]; then ocamlc -where;fi)/site-lib - -#------------------------------------------------------------------------------ -# Systemd and general service related macros -# - -%_tmpfilescreate() /usr/bin/systemd-tmpfiles --create %{1}.conf \ -%{nil} - -# Minimum versions for various packaging helpers. -# These is defined here to easy upgrading from previous distros when the various -# service helpers change and thus those pacakges need to be installed first to -# ensure a smooth upgrade -%rpmhelper_required_version 0.24.11 -%systemd_required_version 195 - -#------------------------------------------------------------------------------ -# Redefine RPM sections to allow jumping over them using "--without <section>". -# This an interesting alternative to --short-circuit. -# The following are mostly equivalent: -# % rpmbuild -bi --short-circuit foo.spec && rpmbuild -bb --short-circuit foo.spec -# % rpmbuild -bb --without build foo.spec - -%prep %%prep \ -[ %{_with prep} -eq 1 ] || exit 0 \ -[ %{_with build} -eq 1 ] || exit 0 \ -[ %{_with install} -eq 1 ] || exit 0 \ -%{nil} - -%build %%build \ -[ %{_with install} -eq 1 ] || exit 0 \ -[ %{_with build} -eq 1 ] || exit 0 \ -%{nil} - -#--------------------------------------------------------------------- -# Expanded at beginning of %install scriptlet. -# - -%__spec_install_pre %{___build_pre}\ -if [ %{_with install} -eq 1 ]; then\ - [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf "${RPM_BUILD_ROOT}"\ - mkdir -p `dirname "$RPM_BUILD_ROOT"`\ - mkdir "$RPM_BUILD_ROOT"\ -fi - -#--------------------------------------------------------------------- -# Expanded at end of %install scriptlet. - -%__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_strip_shared /usr/lib/rpm/brp-strip-shared %{__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 -# __brp_mangle_shebangs_exclude - shebangs to exclude -# __brp_mangle_shebangs_exclude_file - file from which to get shebangs to exclude -# __brp_mangle_shebangs_exclude_from - files to ignore -# __brp_mangle_shebangs_exclude_from_file - file from which to get files to ignore -%__brp_mangle_shebangs /usr/lib/rpm/redhat/brp-mangle-shebangs %{?__brp_mangle_shebangs_exclude:--shebangs "%{?__brp_mangle_shebangs_exclude}"} %{?__brp_mangle_shebangs_exclude_file:--shebangs-from "%{__brp_mangle_shebangs_exclude_file}"} %{?__brp_mangle_shebangs_exclude_from:--files "%{?__brp_mangle_shebangs_exclude_from}"} %{?__brp_mangle_shebangs_exclude_from_file:--files-from "%{__brp_mangle_shebangs_exclude_from_file}"} - -%__os_install_post \ - %{?__spec_helper_post}%{?!__spec_helper_post:/usr/share/spec-helper/spec-helper} \ - %{!?__debug_package:\ - %{?__brp_strip} \ - %{?__brp_strip_comment_note} \ - %{?__brp_strip_static_archive} \ - %{?__brp_strip_shared} \ - } \ - %{?py_auto_byte_compile:%{?__brp_python_bytecompile}} \ - %{?__brp_python_hardlink} \ - %{?__brp_mangle_shebangs} \ -%{nil} - -%install %{?_enable_debug_packages:%{?buildsubdir:%{debug_package}}}\ -%%install\ -[ %{_with install} -eq 1 ] || exit 0 \ -%{nil} - -%check %%check \ -[ %{_with check} -eq 1 ] || exit 0 \ -%{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 w5.xzdio - -# Automatically trim changelog entries after 2 years -%_changelog_trimtime %{lua:print(os.time() - 2 * 365 * 86400)} diff --git a/configure.ac b/configure.ac index 4dfaf6f..d850552 100644 --- a/configure.ac +++ b/configure.ac @@ -1,9 +1,8 @@ # -*- Autoconf -*- # Process this file with autoconf to produce a configure script. - -AC_PREREQ(2.59) -AC_INIT(rpm-mageia-setup, 2.38, https://bugs.mageia.org/) +AC_PREREQ([2.69]) +AC_INIT([rpm-mageia-setup],[2.75.1],[https://bugs.mageia.org/]) AC_CANONICAL_TARGET AM_INIT_AUTOMAKE(1.9 -Wno-portability foreign no-dist-gzip dist-xz) AC_CONFIG_SRCDIR @@ -12,7 +11,7 @@ AC_CONFIG_MACRO_DIR([m4]) # Checks for programs. AC_PROG_CC AC_PROG_INSTALL -AC_PROG_LIBTOOL +LT_INIT AC_CONFIG_FILES([ Makefile ]) @@ -20,6 +19,7 @@ AC_CONFIG_FILES([ dnl See if we have pkgconfig for rpm, resort to old behavior if not PKG_CHECK_MODULES([RPM], [rpm], [ AC_DEFINE_UNQUOTED([HAVE_RPM],1,[Define if RPM backend is available]) + AC_CHECK_HEADERS([rpm/rpmlib.h]) CPPFLAGS="$RPM_CFLAGS $CPPFLAGS" LDFLAGS="$RPM_LIBS $LDFLAGS" ], [ @@ -33,7 +33,7 @@ PKG_CHECK_MODULES([RPM], [rpm], [ ) AC_CHECK_LIB([rpmio], [rpmLoadMacroFile]) -AC_HEADER_STDC + AC_CHECK_HEADERS([string.h]) CANONTARGETCPU=${target_cpu} @@ -42,7 +42,7 @@ ARMV7CANONTARGETCPU="armv5tl" ARMV8CANONTARGETCPU="armv8l" case "${target_cpu}" in - *86|athlon|k6|pentium*) + *86|athlon|k6|pentium*) RPMALLARCH="i386 i486 i586 i686 k6 athlon pentium3 pentium4" CANONTARGETCPU=i586 ;; @@ -103,6 +103,13 @@ case "${target_cpu}" in CANONTARGETGNU=-gnueabi ARMV7CANONTARGETCPU="armv7hl" ARMV8CANONTARGETCPU="armv7hl" + ;; + armv8*) + RPMALLARCH="armv7hl" + CANONTARGETCPU=armv7hl + CANONTARGETGNU=-gnueabi + ARMV7CANONTARGETCPU="armv7hl" + ARMV8CANONTARGETCPU="armv7hl" esac RPMALLARCH="${RPMALLARCH} noarch" AC_SUBST(RPMALLARCH) @@ -177,12 +184,11 @@ RPMVENDORDIR="${RPMCONFDIR}/${RPMCANONVENDOR}" AC_SUBST(RPMVENDORDIR) RPMSYSCONFDIR="/etc/rpm" -AC_ARG_WITH(rpmsysconfdir, [ --with-rpmsysconfdir=dir location of etc ]) -if test $with_rpmsysconfdir; then - RPMSYSCONFDIR=$with_rpmsysconfdir -fi AC_SUBST(RPMSYSCONFDIR) +RPMMACROSD="/usr/lib/rpm/macros.d" +AC_SUBST(RPMMACROSD) + AC_ARG_WITH(rpmplatform, [ --with-rpmplatform use /etc/rpm/platform ]) AM_CONDITIONAL([RPMPLATFORM],[test $with_rpmplatform]) @@ -6,7 +6,7 @@ while read instfile ; do filelist="$filelist $instfile" done -for i in `echo $filelist | tr '[:blank:]' "\n" | egrep '(/usr)?/lib(|64)(/gcc(-lib)?/.+)?/[^/]+\.so$'`; do +for i in `echo $filelist | tr '[:blank:]' "\n" | grep -E '(/usr)?/lib(|64)(/gcc(-lib)?/.+)?/[^/]+\.so$'`; do objd=`objdump -p ${i} | grep SONAME` [ -h ${i} -a -n "${objd}" ] && \ lib64=`if file -L $i 2>/dev/null | grep "ELF 64-bit" >/dev/null; then echo "(64bit)"; fi` && \ @@ -9,7 +9,7 @@ done # for objdump: export LC_ALL=C -for i in `echo $filelist | tr '[:blank:]' "\n" | egrep "(/usr)?/lib(|64)/[^/]+\.so$"`; do +for i in `echo $filelist | tr '[:blank:]' "\n" | grep -E "(/usr)?/lib(|64)/[^/]+\.so$"`; do objd=`objdump -p ${i} | grep SONAME` lib64=`if file -L $i 2>/dev/null | grep "ELF 64-bit" >/dev/null; then echo "(64bit)"; fi` && \ if [ -h ${i} -a -n "${objd}" ]; then @@ -24,6 +24,6 @@ for i in `echo $filelist | tr '[:blank:]' "\n" | egrep "(/usr)?/lib(|64)/[^/]+\. } ' fi -done | egrep -v 'devel\(linux-gate|linux-vdso32|linux-vdso64|lib(c|pthread|rt)(\(64bit\))?\)' | sort -u +done | grep -E -v 'devel\(linux-gate|linux-vdso32|linux-vdso64|lib(c|pthread|rt)(\(64bit\))?\)' | sort -u diff --git a/find-provides.in b/find-provides.in index 598e099..4feab0a 100755 --- a/find-provides.in +++ b/find-provides.in @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/bash # This script reads filenames from STDIN and outputs any relevant provides # information that needs to be included in the package. diff --git a/find-requires.in b/find-requires.in index b15c42c..2cdbe13 100755 --- a/find-requires.in +++ b/find-requires.in @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/bash # # Auto-generate requirements for ELF executables and library diff --git a/fix-libtool-from-moving-options-after-libs b/fix-libtool-from-moving-options-after-libs index e8db899..134a2e3 100755 --- a/fix-libtool-from-moving-options-after-libs +++ b/fix-libtool-from-moving-options-after-libs @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/sh CONFIGURE_TOP="${1:-.}" if [ -e $CONFIGURE_TOP/configure ] && grep -q -F '$deplibs $compiler_flags' $CONFIGURE_TOP/configure; then diff --git a/force-as-needed-for-shared-lib-in-libtool b/force-as-needed-for-shared-lib-in-libtool index 2694273..27b691c 100755 --- a/force-as-needed-for-shared-lib-in-libtool +++ b/force-as-needed-for-shared-lib-in-libtool @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/sh # replaces # tmp_sharedflag='-shared' ;; diff --git a/git-repository--after-tarball b/git-repository--after-tarball deleted file mode 100755 index b9aa92f..0000000 --- a/git-repository--after-tarball +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/sh -ex - -# usage: git-repository--after-tarball [<tarballs>] -# with optional environment variables: -# - GIT_URL="git://xxx/foo.git [branch]" -# - GIT_REPOSITORY_CACHE=/zzz/foo.git -# -# the GIT_REPOSITORY_CACHE can be used with or without GIT_URL -# - if GIT_URL is given, GIT_REPOSITORY_CACHE will be a "bare" clone of GIT_URL -# - otherwise, GIT_REPOSITORY_CACHE can be created using: -# % git clone --bare BUILD/foo-1 $GIT_REPOSITORY_CACHE -# where foo-1 is the previous version - - -tarballs="$*" - - -git_clone_in_cwd() { - URL=$1 - [ -n "$2" ] && BRANCH="origin/$2" - - git clone $URL .git-tmp - - cd .git-tmp - git checkout $BRANCH - cd .. - - mv .git-tmp/.git . - rm -r .git-tmp -} - -our_git_clone() { - URL=$1 - HEAD=$2 - - if [ -n "$GIT_REPOSITORY_CACHE" ]; then - if [ -d "$GIT_REPOSITORY_CACHE" ]; then - cd "$GIT_REPOSITORY_CACHE" - git fetch $GIT_URL - cd - - else - git clone --bare $URL "$GIT_REPOSITORY_CACHE" - fi - git_clone_in_cwd "$GIT_REPOSITORY_CACHE" $HEAD - else - git_clone_in_cwd $URL $HEAD - fi -} - -set_GIT_AUTHOR_DATE() { - # taking date of first tarball, sorry for the other tarballs ;) - tarball=$1 - export GIT_AUTHOR_DATE=`stat -c '%y' "$RPM_SOURCE_DIR/$tarball"` -} - -if [ ! -e .git ]; then - if [ -n "$GIT_URL" ]; then - our_git_clone $GIT_URL - elif [ -n "$GIT_REPOSITORY_CACHE" -a -d "$GIT_REPOSITORY_CACHE" ]; then - git_clone_in_cwd "$GIT_REPOSITORY_CACHE" vanilla - else - git init - fi -fi -git add . -set_GIT_AUTHOR_DATE $tarballs -git commit -q -a --author="unknown author <mageia-dev@mageia.org>" -m "imported $tarballs" -git branch -f vanilla -git branch -f patches-applied -git checkout patches-applied diff --git a/git-repository--apply-patch b/git-repository--apply-patch deleted file mode 100755 index 1e1b3cb..0000000 --- a/git-repository--apply-patch +++ /dev/null @@ -1,158 +0,0 @@ -#!/usr/bin/perl - -# this script can be used instead of "/usr/bin/patch [options] -i xxx.patch" - - -use strict; -use warnings; - -my @argv = @ARGV; -my $verbose; - -my @patches; -while ($argv[-1] =~ /\.(patch|diff)$/) { - unshift @patches, pop @argv; -} - -@patches or die "git-repository--apply-patch can not work with compressed patches\n"; # happens when the patch is passed through stdin - -my @opts; -while (@argv) { - my $s = shift @argv; - if ($s eq '-b') { - # we don't want .xxx files - } elsif ($s eq '--suffix') { - # we don't want .xxx files - shift @argv; - } elsif ($s eq '-i') { - # ignore "-i" - } else { - push @opts, $s; - } -} - -# we really don't want .orig when using git (even when there are hunks) -push @opts, '--no-backup-if-mismatch'; - -foreach my $patch_file (@patches) { - my @header = get_patch_header($patch_file); - - if (grep { /^Subject:/ } @header) { - my $patch_file_ = fix_git_patch($patch_file); - system_("git am " . ($patch_file_ || $patch_file)); - $patch_file_ and unlink $patch_file_; - } else { - system_("patch @opts -i $patch_file"); - - my ($patch_name) = $patch_file =~ m!([^/]*)\.(patch|diff)$!; - - system_('git add .'); - git_commit(commit_line_from_patch_name($patch_name) . - (@header ? "\n\n" . join('', cleanup_patch_header(@header)) : ''), - # use the date of the patch for the commit: - (stat($patch_file))[9] . " +0000"); - } -} - -sub system_ { - my ($cmd) = @_; - print "$cmd\n" if $verbose; - system($cmd) == 0 or die "$cmd failed\n"; -} - -sub git_commit { - my ($msg, $date) = @_; - - $ENV{GIT_AUTHOR_DATE} = $date; - open(my $F, '| git commit -q --author="unknown author <mageia-dev@mageia.org>" --file=-'); - print $F $msg; - close $F or die "git commit failed\n"; -} - -sub commit_line_from_patch_name { - my ($name) = @_; - - # remove prefix (eg: "libtool-1.5.26-xxx" => "xxx") - my $re_name = qr([a-z][\w+]*([_-][a-z][\w+]*)*)i; - my $re_rc = qr((rc\d*|RC\d+|beta\d*|pre\d*|p\d+|test)); - my $re_special_version = qr([a-z]([._-]$re_rc?)?|[._-]?$re_rc?|[a-z]); - $name =~ s/^ $re_name [._-] \d+ (\.\d+)+ $re_special_version [._-]//x; - - if (my $pkg_name = $ENV{PKG_NAME}) { - $name =~ s/^\Q$pkg_name\E[_-]//; - } - - # replace "-" (resp. "_") with spaces if there is no spaces nor "_" (resp. "-") - if ($name !~ /[\s_]/ && $name !~ /--/) { - $name =~ s/-/ /g; - } elsif ($name !~ /[\s-]/ && $name !~ /__/) { - $name =~ s/_/ /g; - } - $name; -} - -sub get_patch_header { - my ($file) = @_; - open(my $F, '<', $file) or die "can not open $file: $!\n"; - - my @header; - while (my $s = <$F>) { - last if $s =~ /^--- /; - push @header, $s; - } - pop @header while @header && $header[-1] !~ /^\s*$/; - - @header; -} - -sub cleanup_patch_header { - my (@header) = @_; - - my @r; - foreach (@header) { - s/^##\s// or last; - push @r, $_; - } - @r == @header and return @r; - - @header; -} - -# "git format-patch" and "git am" do not agree how to handle commit logs when -# the first line is not separated from the rest. -# eg: -# -# > Subject: [PATCH 01/34] Delay NSS initialization until actually used -# > - since NSS is allergic (ie becomes non-functional) after forking, delay -# > it's initialization until really needed, ie lazy init in rpmDigestInit() -# -# workarounding by transforming header to: -# -# > Subject: [PATCH 01/34] Delay NSS initialization until actually used -# > -# > - since NSS is allergic (ie becomes non-functional) after forking, delay -# > it's initialization until really needed, ie lazy init in rpmDigestInit() -sub fix_git_patch { - my ($file) = @_; - open(my $F, '<', $file) or die "can not open $file: $!\n"; - - my ($last_line, @l); - while (my $s = <$F>) { - push @l, $s; - - if ($s !~ /^\S+:\s/ && $last_line && $last_line =~ /^Subject:/) { - # argh, we are in the header, but the value is weird - # applying the fix - $l[-1] = "\n" . $l[-1]; - push @l, <$F>; - output("$file.tmp", @l); - return "$file.tmp"; - } elsif ($s =~ /^\s*$/ || $s =~ /^--- /) { - last; - } - $last_line = $s; - } - undef; -} - -sub output { my $f = shift; open(my $F, '>', $f) or die "output in file $f failed: $!\n"; print $F $_ foreach @_; 1 } diff --git a/info-file.req b/info-file.req deleted file mode 100755 index 857a65e..0000000 --- a/info-file.req +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -# -# Automatically emits requires on info-install for *.info files -# -echo info-install diff --git a/info.attr b/info.attr deleted file mode 100644 index 078daee..0000000 --- a/info.attr +++ /dev/null @@ -1,3 +0,0 @@ -%__info_requires %{_rpmconfigdir}/mageia/info-file.req -%__info_scriptlet posttrans -%__info_path ^%{_datadir}/info/.*\\.info.*$ diff --git a/macros.gnome.in b/macros.gnome.in new file mode 100644 index 0000000..cb38bd0 --- /dev/null +++ b/macros.gnome.in @@ -0,0 +1,22 @@ +%tarball_version %{lua: +ver = string.gsub(rpm.expand("%{version}"), "~", ".") +print(ver) +} + +%url_ver %{lua: +ver = rpm.expand("%{version}") +majmin, count1 = string.gsub(ver, "^(%d+%.%d+).*", "%1", 1) +if count1 == 0 then + ver = string.gsub(ver, "~.*", "") + print(ver) + return +end +maj, count2 = string.gsub(majmin, "^(%d+).*", "%1", 1); +if count2 == 0 then + print(majmin) +elseif tonumber(majmin) < 40 then + print(majmin) +else + print(maj) +end +} @@ -16,6 +16,7 @@ %_gnu @CANONTARGETGNU@ %_target_platform %{_target_cpu}-%{_real_vendor}-%{_target_os}%{?_gnu} +%_host_cpu @CANONTARGETCPU@ %_host %{_host_cpu}-%{_real_vendor}-%{_host_os}%{?_gnu} @@ -50,3 +51,483 @@ # activate filetriggers (cf http://wiki.mandriva.com/en/Rpm_filetriggers) %_filetriggers_dir /var/lib/rpm/filetriggers +# Various programs used in rpm scripts +%_update_icon_cache_bin %{_bindir}/gtk-update-icon-cache +%_gconftool_bin %{_bindir}/gconftool-2 + +#============================================================================== +# ---- Required rpmrc macros. +# Macros that used to be initialized as a side effect of rpmrc parsing. +# These are the default values that can be overridden by other +# (e.g. per-platform, per-system, per-packager, per-package) macros. +# + +%ix86 i386 i486 i586 i686 pentium3 pentium4 athlon k6 + +# Multilibs +%_multilibpatt (/%{_lib}|/usr/%{_lib}(|/gconv)|/usr/local/%{_lib}|/usr/X11R6/%{_lib}|/opt/%{_lib})/[^/]*\\.([oa]|la|so[0-9.]*)$ + +%_arch_tag_suffix %([ "%{?_lib}" = "lib64" ] && echo "()(64bit)") +%arch_tagged() %{1}%{_arch_tag_suffix} %{?2:%{2} %{3}%{?!3:%{error:undefined 3rd argument in arch_tagged}}} + +# Games macros +%_gamesdir games +%_gamesbindir %{_prefix}/%{_gamesdir} +%_gamesdatadir %{_datadir}/%{_gamesdir} + +# Menu directories +%_menudir %{_prefix}/lib/menu +%_iconsdir %{_datadir}/icons +%_miconsdir %{_datadir}/icons/mini +%_liconsdir %{_datadir}/icons/large + +%_xfontdir %_datadir/fonts + +%_webconfdir %{_sysconfdir}/httpd/conf +%_webappconfdir %_webconfdir/sites.d + +# compatibility +%webappconfdir %_webappconfdir + +# For Appdata metainfo +%_metainfodir %{_datadir}/metainfo + +#============================================================================== +# ---- Build configuration macros. +# +# Package version macro. +# The type of package to produce, for compatibility with legacy +# versions of rpm. +# +# Script gets packaged file list on input. +# Returns list of multiarch files that are not marked as such, +# i.e. files in $RPM_BUILD_ROOT that have arch-dependent values +# +# Note: Disable (by commenting out) for legacy compatibility. +#%__check_multiarch_files @RPMLIBDIR@/check-multiarch-files %{buildroot} + +# For rebuilding gcj-db +%_rebuildgcjdb_bin %{_bindir}/rebuild-gcj-db +%update_gcjdb if [ -x %{_rebuildgcjdb_bin} ]; then %{_rebuildgcjdb_bin} || true ; fi \ +%{nil} + +%clean_gcjdb if [ -x %{_rebuildgcjdb_bin} ]; then %{_rebuildgcjdb_bin} || true ; fi \ +%{nil} + +# Rebuild icon cache +# +# following themes are handled through filetriggers: +%icon_cache_through_filetrigger_hicolor 1 +%icon_cache_through_filetrigger_gnome 1 +%icon_cache_through_filetrigger_oxygen 1 + +%update_icon_cache() %{expand: %%{!?icon_cache_through_filetrigger_%1:if [ -x %%{_update_icon_cache_bin} ]; then \ +%%{_update_icon_cache_bin} --force --quiet %%{_iconsdir}/%%{1} || true; fi \ +%%{nil}}} + +%clean_icon_cache() %{expand: %%{!?icon_cache_through_filetrigger_%1:if [ -x %%{_update_icon_cache_bin} -a -r %%{_iconsdir}/%%{1}/index.theme ]; then \ +%%{_update_icon_cache_bin} --force --quiet %%{_iconsdir}/%%{1} || true ; fi \ +%%{nil}}} + +# GConf schemas: +# uninstall still need to be done in %preun: +%preun_uninstall_gconf_schemas() if [ "$1" = "0" -a -x %{_gconftool_bin} ]; then \ +SCHEMAS="" \ +for SCHEMA in %{*} ; do \ + SCHEMAS="$SCHEMAS %{_sysconfdir}/gconf/schemas/$SCHEMA.schemas" \ +done \ +GCONF_CONFIG_SOURCE=`%{_gconftool_bin} --get-default-source` %{_gconftool_bin} --makefile-uninstall-rule $SCHEMAS > /dev/null || true ; fi \ +%{nil} + +# Mageia Linux version +# (user may copy the following line in specfile) +%mgaversion %distro_release + +%distsuffix @DISTSUFFIX@ + +%__dist_ident %{?distsuffix:%distsuffix}%{?!distsuffix:.mga}%{?distro_release:%distro_release} + +%__distro_section %{?distro_section:%distro_section}%{?!distro_section:core} + +%mkrel(c:) %{-c: 0.%{-c*}.}%{1}%{?subrel:.%subrel}%{?dist:%dist}%{?!dist:%__dist_ident}%([ "%{__distro_section}" != "core" ] && echo .%__distro_section) + +%_logdir %{_var}/log +%_localstatedir /var + +%_pkgdocdir %{_docdir}/%{name} +%_docdir_fmt %%{NAME} + +# Include minimal debug information in build binaries. +# Requires _enable_debug_packages. +# +%_enable_debug_packages 1 +%_include_minidebuginfo 1 +%_include_gdb_index 1 +%_debugsource_packages 1 +%_debuginfo_subpackages 1 + +#------------------------------------------------------------------------------ +# definions merged from manbo-setup-build +# + +# Default extension to use (for info files) +%_extension .xz + +%__install_info /sbin/install-info + +%_install_info() if [[ -f %{_infodir}/%{1}%{_extension} ]]; then %{__install_info} %{_infodir}/%{1}%{_extension} --dir=%{_infodir}/dir; fi \ +%{nil} + +# (nb: keep the "alone on its line ';'") +%_remove_install_info() if [ "$1" = "0" ]; then if [[ -f %{_infodir}/%{1}%{_extension} ]]; then %{__install_info} %{_infodir}/%{1}%{_extension} --dir=%{_infodir}/dir --remove ; fi; fi \ +%{nil} + +# Macro: %{mklibname <name> [<major> [<minor>]] [-s] [-d]} +# - %{mklibname test} => lib64test, on a lib64 platform +# - %{mklibname test 1 -d} => libtest1-devel +# - %{mklibname test 1 -d 0 -s} => libtest1_0-static-devel +%mklibname(ds) %{_lib}%{1}%{?2:%{2}}%{?3:_%{3}}%{-s:-static}%{-d:-devel} + +# Dynamic EVRD tags macro for use with versioned provides/requires in place of +# '%{version}-%{release}', ie. to automatically add distepoch or epoch if present +%EVRD %{?epoch:%{epoch}:}%{?version:%{version}}%{?release:-%{release}}%{?distepoch::%{distepoch}} + +#============================================================================== +# ---- compiler flags. + +# C compiler flags. This is traditionally called CFLAGS in makefiles. +# Historically also available as %%{optflags}, and %%build sets the +# environment variable RPM_OPT_FLAGS to this value. +%build_cflags %{optflags} + +# C++ compiler flags. This is traditionally called CXXFLAGS in makefiles. +%build_cxxflags %{optflags} + +# Fortran compiler flags. Makefiles use both FFLAGS and FCFLAGS as +# the corresponding variable names. +%build_fflags %{optflags} %{?_fmoddir:-I%_fmoddir} + +# Vala compiler flags. This is used to set VALAFLAGS. +%build_valaflags -g + +# Some linkers default to a build-id algoritim that is not supported by rpmbuild, +# so we need to specify the right algorithm to use. +%_build_id_flags -Wl,--build-id=sha1 + +# Link editor flags. This is usually called LDFLAGS in makefiles. +# (Some makefiles use LFLAGS instead.) The default value assumes that +# the flags, while intended for ld, are still passed through the gcc +# compiler driver. At the beginning of %%build, the environment +# variable RPM_LD_FLAGS to this value. +%build_ldflags %{?!_disable_ld_as_needed: -Wl,--as-needed}%{?!_disable_ld_no_undefined: -Wl,--no-undefined}%{?!_disable_ld_relro: -Wl,-z,relro%{?!_disable_ld_now: -Wl,-z,now}}%{?!_disable_ld_O1: -Wl,-O1}%{?!_disable_ld_build_id: %_build_id_flags}%{?!_disable_ld_enable_new_dtags: -Wl,--enable-new-dtags} + +# For compatibility +%ldflags %build_ldflags + +# Expands to shell code to seot the compiler/linker environment +# variables CFLAGS, CXXFLAGS, FFLAGS, FCFLAGS, VALAFLAGS, LDFLAGS if they have +# not been set already. RPM_OPT_FLAGS and RPM_LD_FLAGS have already +# been set implicitly at the start of the %%build section. +# LT_SYS_LIBRARY_PATH is used by libtool script. +%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 ; \ + VALAFLAGS="${VALAFLAGS:-%{build_valaflags}}" ; export VALAFLAGS ; \ + RUSTFLAGS="${RUSTFLAGS:-%{build_rustflags}}" ; export RUSTFLAGS ; \ + LDFLAGS="${LDFLAGS:-%{build_ldflags}}" ; export LDFLAGS ; \ + LT_SYS_LIBRARY_PATH="${LT_SYS_LIBRARY_PATH:-%_libdir:}" ; export LT_SYS_LIBRARY_PATH + +# For compatibility +%setup_compile_flags \ + %{warn:%%setup_compile_flags is deprecated, use %%set_build_flags instead} \ + %set_build_flags + +%debugcflags %{?_enable_debug_packages:-g} + +%_fortify_level 2 +%_fortify_cflags %[ 0%{?_fortify_level} > 0 ? "-Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=%{_fortify_level}" : "" ] + +# cf http://wiki.mandriva.com/en/Development/Packaging/Problems#format_not_a_string_literal_and_no_format_arguments +%Werror_cflags -Wformat -Werror=format-security + +%_ssp_cflags -fstack-protector-strong +%__common_cflags -O2 %{debugcflags} -pipe %{Werror_cflags} %{?_fortify_cflags}%{?_legacy_common_support: -fcommon} +%__common_cflags_with_ssp %{__common_cflags} %{?_ssp_cflags} + +# Servers opt flags. +# Also set the env variables for backward compatibility (mdv #32050). +%serverbuild %define _ssp_cflags -fstack-protector-all \ +export CFLAGS="%optflags"; export CXXFLAGS="%optflags"; export RPM_OPT_FLAGS="%optflags" \ +%{nil} + +%make \ + %{warn:%%make is deprecated, use %%make_build instead} \ + %{__make} -O %_smp_mflags + +%makeinstall_std \ + %{warn:%%makeinstall_std is deprecated, use %%make_install instead} \ + make DESTDIR=%{?buildroot:%{buildroot}} install + +%__fix_libtool_ltmain_from_overlinking @RPMVENDORDIR@/fix-libtool-ltmain-from-overlinking +%__fix_libtool_from_moving_options_after_libs @RPMVENDORDIR@/fix-libtool-from-moving-options-after-libs +%__fix_dlsearch_path_in_libtool_for_multilib @RPMVENDORDIR@/fix-dlsearch-path-in-libtool-for-multilib + +# Update config.{guess,sub} +%_configure_gnuconfig_hack 1 + +%before_configure \ + %set_build_flags \ + CONFIGURE_TOP="${CONFIGURE_TOP:-.}"; \ + if [ "%_configure_gnuconfig_hack" = "1" ]; then \ + for i in $(find ${CONFIGURE_TOP} -name config.guess -o -name config.sub); do \ + [ -f %{_rpmconfigdir}/%{_real_vendor}/$(basename $i) ] && cp -af %{_rpmconfigdir}/%{_real_vendor}/$(basename $i) $i; \ + done; \ + fi; \ + %{?!_disable_ld_as_needed:@RPMVENDORDIR@/force-as-needed-for-shared-lib-in-libtool ;} \ + %{?!_disable_ld_no_undefined:@RPMVENDORDIR@/drop-ld-no-undefined-for-shared-lib-modules-in-libtool ;} \ + %{__fix_libtool_ltmain_from_overlinking} ; \ + %{__fix_libtool_from_moving_options_after_libs} $CONFIGURE_TOP ; \ + %{__fix_dlsearch_path_in_libtool_for_multilib} $CONFIGURE_TOP %{_lib} + +# This is an improved version of %configure (originally from PLD team). +%_configure $CONFIGURE_TOP/configure +%configure \ + %{before_configure}; \ + %{_configure} --host=%{_host} --build=%{_build} \\\ + --program-prefix=%{?_program_prefix} \\\ + --disable-dependency-tracking \\\ + --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} + +%configure2_5x \ + %{warn:%%configure2_5x is deprecated, use %%configure instead} \ + %configure + +# Maximum number of CPU's to use when building, 0 for unlimited. +%_smp_ncpus_max 0 + +# Deprecated names. For backwards compatibility only. +%__global_cflags %{build_cflags} +%__global_cxxflags %{build_cxxflags} +%__global_fflags %{build_fflags} +%__global_fcflags %{build_fflags} +%__global_ldflags %{build_ldflags} + +#============================================================================== +# ---- Build policy macros. +# +# +#--------------------------------------------------------------------- +# Expanded at beginning of %install scriptlet. +# + + +#============================================================================== +# ---- specfile macros. +# Macro(s) here can be used reliably for reproducible builds. +# (Note: Above is the goal, below are the macros under development) +# + +#------------------------------------------------------------------------------ +# Useful perl macros +# (initially from Artur Frysiak <wiget@t17.ds.pwr.wroc.pl>) +# (modified by Pixel <pixel@mandriva.com>) +# +# [...] +# Group: Development/Perl +# [...] +# %build +# perl Makefile.PL INSTALLDIRS=vendor +# %make +# [...] +# %install +# rm -rf $RPM_BUILD_ROOT +# make install PREFIX="$RPM_BUILD_ROOT/%{prefix}" +# [...] +# %files +# %defattr(644,root,root,755) +# %{perl_vendorlib}/CGI +# or +# %{perl_vendorarch}/DBI +# %{perl_vendorarch}/auto/DBI +# %{_mandir}/*/* +# + +%perl_convert_version() %(perl -Mversion -le ' + $x = "%{1}"; + $y = $x; + $x =~ s/[[:alpha:]]*$//; + $y =~ s/^$x//; + $x =~ s/\D*$//; + $v = version->new($x)->normal; + $v =~ s/^v//; + print "$v$y"; +') + +#-------------------------------------------------------------------------------- +# Macro from conectiva + +%rename() \ +Obsoletes: %{1} < %{?2:%2}%{?!2:%{?epoch:%epoch}%{?!epoch:0}:%{version}-%{release}} \ +Provides: %{1} = %{?2:%2}%{?!2:%{?epoch:%epoch}%{?!epoch:0}:%{version}-%{release}} + +# Shorthand for %{defined with_...} +# macros provided by rpm 4.4, but buggy :( +%_with() %{expand: %%{?_with_%1:1} %%{!?_with_%1: %%{?_without_%1:0} %%{!?_without_%1: %%{?with_%1:%%{with_%1}} %%{!?with_%1: %%{?without_%1:!%%{without_%1}} %%{!?without_%1: %%{?2:%%2} %%{!?2:1} } } } } } +%_without() !%{expand: %%{with %1 %{?2:%2}}} + +#------------------------------------------------------------------------------ +# Java Macros +# + +%gcj_support 0 +%gcj_native \ +%if %{gcj_support} \ +BuildRequires: java-gcj-compat-devel \ +%else \ +BuildArch: noarch \ +%endif + +%aot_compile_rpm_bin %{_bindir}/aot-compile-rpm + +%gcj_compile \ +%if %{gcj_support} \ +%aot_compile_rpm_bin \ +%endif + +%gcj_files \ +%if %{gcj_support} \ +%dir %{_libdir}/gcj/%{name} \ +%attr(-,root,root) %{_libdir}/gcj/%{name}/* \ +%endif + +%remove_java_binaries \ +find . -name "*.jar" -delete + +%create_jar_links() \ +pushd %{buildroot}%{_javadir}; \ +for jar in *-%{version}.jar; do ln -sf ${jar} ${jar/-%{version}/}; done \ +popd + +#------------------------------------------------------------------------------ +# Ocaml macro +# + +%ocaml_sitelib %(if [ -x /usr/bin/ocamlc ]; then ocamlc -where;fi)/site-lib + +#------------------------------------------------------------------------------ +# Systemd and general service related macros +# + +%_tmpfilescreate() /usr/bin/systemd-tmpfiles --create %{1}.conf \ +%{nil} + +# Minimum versions for various packaging helpers. +# These is defined here to easy upgrading from previous distros when the various +# service helpers change and thus those pacakges need to be installed first to +# ensure a smooth upgrade +%rpmhelper_required_version 0.24.11 +%systemd_required_version 195 + +#------------------------------------------------------------------------------ +# Redefine RPM sections to allow jumping over them using "--without <section>". +# This an interesting alternative to --short-circuit. +# The following are mostly equivalent: +# % rpmbuild -bi --short-circuit foo.spec && rpmbuild -bb --short-circuit foo.spec +# % rpmbuild -bb --without build foo.spec + +%prep %%prep \ +[ %{_with prep} -eq 1 ] || exit 0 \ +[ %{_with build} -eq 1 ] || exit 0 \ +[ %{_with install} -eq 1 ] || exit 0 \ +%{nil} + +%build %%build \ +[ %{_with install} -eq 1 ] || exit 0 \ +[ %{_with build} -eq 1 ] || exit 0 \ +%{nil} + +#--------------------------------------------------------------------- +# Expanded at beginning of %install scriptlet. +# + +%__spec_install_pre %{___build_pre}\ +if [ %{_with install} -eq 1 ]; then\ + [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf "${RPM_BUILD_ROOT}"\ + mkdir -p `dirname "$RPM_BUILD_ROOT"`\ + mkdir "$RPM_BUILD_ROOT"\ +fi + +#--------------------------------------------------------------------- +# Expanded at end of %install scriptlet. + +%__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_check_rpaths /usr/lib/rpm/check-rpaths +%__brp_remove_la_files /usr/lib/rpm/brp-remove-la-files +# __brp_mangle_shebangs_exclude - shebangs to exclude +# __brp_mangle_shebangs_exclude_file - file from which to get shebangs to exclude +# __brp_mangle_shebangs_exclude_from - files to ignore +# __brp_mangle_shebangs_exclude_from_file - file from which to get files to ignore +%__brp_mangle_shebangs /usr/lib/rpm/redhat/brp-mangle-shebangs %{?__brp_mangle_shebangs_exclude:--shebangs "%{?__brp_mangle_shebangs_exclude}"} %{?__brp_mangle_shebangs_exclude_file:--shebangs-from "%{__brp_mangle_shebangs_exclude_file}"} %{?__brp_mangle_shebangs_exclude_from:--files "%{?__brp_mangle_shebangs_exclude_from}"} %{?__brp_mangle_shebangs_exclude_from_file:--files-from "%{__brp_mangle_shebangs_exclude_from_file}"} + +%__arch_install_post /usr/lib/rpm/check-buildroot + +%__os_install_post \ + %{?__spec_helper_post}%{?!__spec_helper_post:/usr/share/spec-helper/spec-helper} \ + %{!?__debug_package:\ + %{?__brp_strip} \ + %{?__brp_strip_comment_note} \ + %{?__brp_strip_static_archive} \ + } \ + %{?__brp_check_rpaths} \ + %{?__brp_remove_la_files} \ + %{?__brp_mangle_shebangs} \ + %{__os_install_post_python} \ +%{nil} + +%__spec_install_post\ + %{?__debug_package:%{__debug_install_post}}\ + %{__arch_install_post}\ + %{__os_install_post}\ +%{nil} + +%install %{?_enable_debug_packages:%{?buildsubdir:%{debug_package}}}\ +%%install\ +[ %{_with install} -eq 1 ] || exit 0 \ +%{nil} + +%check %%check \ +[ %{_with check} -eq 1 ] || exit 0 \ +%{nil} + +# +# Should missing buildids terminate a build? +%_missing_build_ids_terminate_build 1 + +# If enabled, dilute user() and group() requires into recommends +%_use_weak_usergroup_deps 1 + +# Use SHA-256 for FILEDIGESTS instead of default MD5 +%_source_filedigest_algorithm 8 +%_binary_filedigest_algorithm 8 + +# Use Zstandard compression for binary payloads +%_binary_payload w19.zstdio + +# Automatically trim changelog entries after 2 years +%_changelog_trimtime %{lua:print(os.time() - 2 * 365 * 86400)} diff --git a/rpm-spec-mode.el b/rpm-spec-mode.el index 9b2e946..d0bde54 100644 --- a/rpm-spec-mode.el +++ b/rpm-spec-mode.el @@ -1,11 +1,10 @@ ;;; rpm-spec-mode.el --- RPM spec file editing commands for Emacs/XEmacs +;; Copyright (C) 1997-2015 Stig Bjørlykke, <stig@bjorlykke.org> -;; Copyright (C) 1997-2002 Stig Bjørlykke, <stigb@tihlde.org> - -;; Author: Stig Bjørlykke, <stigb@tihlde.org> +;; Author: Stig Bjørlykke, <stig@bjorlykke.org> ;; Keywords: unix, languages -;; Version: 0.12 +;; Version: 0.16 ;; This file is part of XEmacs. @@ -21,8 +20,8 @@ ;; You should have received a copy of the GNU General Public License ;; along with XEmacs; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -;; MA 02111-1307, USA. +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301 USA. ;;; Synched up with: not in GNU Emacs. @@ -34,12 +33,15 @@ ;; Tim Powers <timp@redhat.com> and Trond Eivind Glomsrød ;; <teg@redhat.com> for Red Hat adaptions and some fixes. ;; Chmouel Boudjnah <chmouel@mandrakesoft.com> for Mandrake fixes. +;; Ville Skyttä <ville.skytta@iki.fi> for some fixes. +;; Adam Spiers <elisp@adamspiers.org> for GNU emacs compilation +;; and other misc fixes. ;;; ToDo: ;; - rewrite function names. ;; - autofill changelog entries. -;; - customize rpm-tags-list and rpm-group-tags-list. +;; - customize rpm-tags-list, rpm-obsolete-tags-list and rpm-group-tags-list. ;; - get values from `rpm --showrc'. ;; - ssh/rsh for compile. ;; - finish integrating the new navigation functions in with existing stuff. @@ -50,7 +52,7 @@ ;; This mode is used for editing spec files used for building RPM packages. ;; ;; Most recent version is available from: -;; <URL:http://www.tihlde.org/~stigb/rpm-spec-mode.el> +;; <https://github.com/bjorlykke/rpm-spec-mode> ;; ;; Put this in your .emacs file to enable autoloading of rpm-spec-mode, ;; and auto-recognition of ".spec" files: @@ -62,13 +64,11 @@ ;; ;;; Code: -(require 'cl) +(require 'compile) -(defconst rpm-spec-mode-version "0.12" "Version of `rpm-spec-mode'.") +(defconst rpm-spec-mode-version "0.16" "Version of `rpm-spec-mode'.") -;Fix for GNU/Emacs -(if (not(featurep 'xemacs)) - (fset 'define-obsolete-variable-alias 'make-obsolete)) +(eval-and-compile (defvar running-xemacs nil)) (defgroup rpm-spec nil "RPM spec mode with Emacs/XEmacs enhancements." @@ -76,7 +76,7 @@ :group 'languages) (defcustom rpm-spec-build-command "rpmbuild" - "Command for building a RPM package." + "Command for building an RPM package." :type 'string :group 'rpm-spec) @@ -92,11 +92,6 @@ in \"%build\" and \"%install\" stage." :type 'boolean :group 'rpm-spec) -(defcustom rpm-spec-no-deps nil - "Do not verify the dependencies." - :type 'boolean - :group 'rpm-spec) - (defcustom rpm-spec-timecheck "0" "Set the \"timecheck\" age (0 to disable). The timecheck value expresses, in seconds, the maximum age of a file @@ -106,7 +101,7 @@ timecheck age." :group 'rpm-spec) (defcustom rpm-spec-buildroot "" - "Override the BuildRoot tag with directory <dir>." + "When building, override the BuildRoot tag with directory <dir>." :type 'string :group 'rpm-spec) @@ -117,7 +112,7 @@ Set the macros _target, _target_arch and _target_os accordingly" :group 'rpm-spec) (define-obsolete-variable-alias - 'rpm-completion-ignore-case 'rpm-spec-completion-ignore-case) + 'rpm-completion-ignore-case 'rpm-spec-completion-ignore-case "0.12") (defcustom rpm-spec-completion-ignore-case t "*Non-nil means that case differences are ignored during completion. @@ -136,11 +131,20 @@ This is used during Tempo template completion." :type 'boolean :group 'rpm-spec) +(define-obsolete-variable-alias + 'rpm-spec-test 'rpm-spec-nobuild "0.12") + (defcustom rpm-spec-nobuild nil "Do not execute any build stages. Useful for testing out spec files." :type 'boolean :group 'rpm-spec) +(defcustom rpm-spec-quiet nil + "Print as little as possible. +Normally only error messages will be displayed." + :type 'boolean + :group 'rpm-spec) + (defcustom rpm-spec-sign-gpg nil "Embed a GPG signature in the package. This signature can be used to verify the integrity and the origin of @@ -153,37 +157,22 @@ the package." :type 'boolean :group 'rpm-spec) -(defcustom rpm-spec-old-rpm nil - "Set if using `rpm' as command for building packages." - :type 'boolean - :group 'rpm-spec) - (define-obsolete-variable-alias - 'rpm-initialize-sections 'rpm-spec-initialize-sections) + 'rpm-initialize-sections 'rpm-spec-initialize-sections "0.12") (defcustom rpm-spec-initialize-sections t "Automatically add empty section headings to new spec files." :type 'boolean :group 'rpm-spec) -(defcustom rpm-spec-use-tabs nil - "Use tabs instead of a space to indent tags." - :type 'boolean - :group 'rpm-spec) - (define-obsolete-variable-alias - 'rpm-insert-version 'rpm-spec-insert-changelog-version) + 'rpm-insert-version 'rpm-spec-insert-changelog-version "0.12") (defcustom rpm-spec-insert-changelog-version t "Automatically add version in a new change log entry." :type 'boolean :group 'rpm-spec) -(defcustom rpm-spec-insert-changelog-version-with-shell t - "Automatically add version with shell in a new change log entry." - :type 'boolean - :group 'rpm-spec) - (defcustom rpm-spec-user-full-name nil "*Full name of the user. This is used in the change log and the Packager tag. It defaults to the @@ -200,8 +189,50 @@ value returned by function `user-mail-address'." string) :group 'rpm-spec) +(defcustom rpm-spec-indent-heading-values nil + "*Indent values for all tags in the \"heading\" of the spec file." + :type 'boolean + :group 'rpm-spec) + +(defcustom rpm-spec-default-release "1" + "*Default value for the Release tag in new spec files." + :type 'string + :group 'rpm-spec) + +(defcustom rpm-spec-default-epoch nil + "*If non-nil, default value for the Epoch tag in new spec files." + :type '(choice (const :tag "No Epoch" nil) integer) + :group 'rpm-spec) + +(defcustom rpm-spec-default-buildroot + "%{_tmppath}/%{name}-%{version}-%{release}-root" + "*Default value for the BuildRoot tag in new spec files." + :type 'integer + :group 'rpm-spec) + +(defcustom rpm-spec-default-build-section "" + "*Default %build section in new spec files." + :type 'string + :group 'rpm-spec) + +(defcustom rpm-spec-default-install-section "rm -rf $RPM_BUILD_ROOT\n" + "*Default %install section in new spec files." + :type 'string + :group 'rpm-spec) + +(defcustom rpm-spec-default-clean-section "rm -rf $RPM_BUILD_ROOT\n" + "*Default %clean section in new spec files." + :type 'string + :group 'rpm-spec) + +(defcustom rpm-spec-auto-topdir nil + "*Automatically detect an rpm build directory tree and define _topdir." + :type 'boolean + :group 'rpm-spec) + (defgroup rpm-spec-faces nil "Font lock faces for `rpm-spec-mode'." + :prefix "rpm-spec-" :group 'rpm-spec :group 'faces) @@ -209,88 +240,110 @@ value returned by function `user-mail-address'." ;; variables used by navigation functions. (defconst rpm-sections - '("preamble" "description" "prep" "setup" "build" "install" "clean" + '("preamble" "description" "prep" "setup" "build" "install" "check" "clean" "changelog" "files") "Partial list of section names.") (defvar rpm-section-list '(("preamble") ("description") ("prep") ("setup") ("build") ("install") - ("clean") ("changelog") ("files")) + ("check") ("clean") ("changelog") ("files")) "Partial list of section names.") (defconst rpm-scripts '("pre" "post" "preun" "postun" - "trigger" "triggerin" "triggerun" "triggerpostun") + "trigger" "triggerin" "triggerprein" "triggerun" "triggerpostun" + "pretrans" "posttrans" "verifyscript" "filetriggerin" "filetrigger" + "filetriggerun" "filetriggerpostun" "transfiletriggerin" "transfiletrigger" + "transfiletriggerun" "transfiletriggerun" "transfiletriggerpostun") "List of rpm scripts.") (defconst rpm-section-seperate "^%\\(\\w+\\)\\s-") (defconst rpm-section-regexp (eval-when-compile (concat "^%" (regexp-opt - ;; From RPM 4.1 sources, file build/parseSpec.c: partList[]. - '("build" "changelog" "clean" "description" "files" "install" - "package" "post" "postun" "pre" "prep" "preun" "trigger" - "triggerin" "triggerpostun" "triggerun" "verifyscript") t) + ;; From RPM 4.12.90 sources, file build/parseSpec.c: partList[]. + '("package" "prep" "build" "install" "check" "clean" "preun" + "postun" "pretrans" "posttrans" "pre" "post" "files" "changelog" + "description" "triggerpostun" "triggerprein" "triggerun" + "triggerin" "trigger" "verifyscript" "sepolicy" "filetriggerin" + "filetrigger" "filetriggerun" "filetriggerpostun" + "transfiletriggerin" "transfiletrigger" "transfiletriggerun" + "transfiletriggerun" "transfiletriggerpostun") t) "\\b")) "Regular expression to match beginning of a section.") ;;------------------------------------------------------------ (defface rpm-spec-tag-face - '(( ((class color) (background light)) (:foreground "blue") ) + '(( ((class color) (background light)) (:foreground "blue3") ) ( ((class color) (background dark)) (:foreground "blue") )) - "*The face used for tags." + "*Face for tags." + :group 'rpm-spec-faces) + +(defface rpm-spec-obsolete-tag-face + '(( ((class color)) (:foreground "white" :background "red") )) + "*Face for obsolete tags." :group 'rpm-spec-faces) (defface rpm-spec-macro-face '(( ((class color) (background light)) (:foreground "purple") ) ( ((class color) (background dark)) (:foreground "yellow") )) - "*The face used for macros." + "*Face for RPM macros and variables." :group 'rpm-spec-faces) (defface rpm-spec-var-face '(( ((class color) (background light)) (:foreground "maroon") ) ( ((class color) (background dark)) (:foreground "maroon") )) - "*The face used for environment variables." + "*Face for environment variables." :group 'rpm-spec-faces) (defface rpm-spec-doc-face - '(( ((class color) (background light)) (:foreground "magenta") ) + '(( ((class color) (background light)) (:foreground "magenta3") ) ( ((class color) (background dark)) (:foreground "magenta") )) - "*The face used for document files." + "*Face for %doc and %license entries in %files." :group 'rpm-spec-faces) (defface rpm-spec-dir-face - '(( ((class color) (background light)) (:foreground "green") ) + '(( ((class color) (background light)) (:foreground "green4") ) ( ((class color) (background dark)) (:foreground "green") )) - "*The face used for directories." + "*Face for %dir entries in %files." :group 'rpm-spec-faces) (defface rpm-spec-package-face - '(( ((class color) (background light)) (:foreground "red") ) + '(( ((class color) (background light)) (:foreground "red3") ) ( ((class color) (background dark)) (:foreground "red") )) - "*The face used for files." + "*Face for package tag." :group 'rpm-spec-faces) (defface rpm-spec-ghost-face - '(( ((class color) (background light)) (:foreground "red") ) + '(( ((class color) (background light)) (:foreground "gray50") ) ( ((class color) (background dark)) (:foreground "red") )) - "*The face used for ghost tags." + "*Face for %ghost and %config entries in %files." + :group 'rpm-spec-faces) + +(defface rpm-spec-section-face + '(( ((class color) (background light)) (:foreground "purple" :underline t) ) + ( ((class color) (background dark)) (:foreground "yellow" :underline t) )) + "*Face for section markers." :group 'rpm-spec-faces) ;;; GNU emacs font-lock needs these... (defvar rpm-spec-macro-face - 'rpm-spec-macro-face "*Face for macros.") + 'rpm-spec-macro-face "*Face for RPM macros and variables.") (defvar rpm-spec-var-face 'rpm-spec-var-face "*Face for environment variables.") (defvar rpm-spec-tag-face 'rpm-spec-tag-face "*Face for tags.") +(defvar rpm-spec-obsolete-tag-face + 'rpm-spec-tag-face "*Face for obsolete tags.") (defvar rpm-spec-package-face 'rpm-spec-package-face "*Face for package tag.") (defvar rpm-spec-dir-face - 'rpm-spec-dir-face "*Face for directory entries.") + 'rpm-spec-dir-face "*Face for %dir entries in %files.") (defvar rpm-spec-doc-face - 'rpm-spec-doc-face "*Face for documentation entries.") + 'rpm-spec-doc-face "*Face for %doc and %license entries in %files.") (defvar rpm-spec-ghost-face - 'rpm-spec-ghost-face "*Face for \"%ghost\" files.") + 'rpm-spec-ghost-face "*Face for %ghost and %config entries in %files.") +(defvar rpm-spec-section-face + 'rpm-spec-section-face "*Face for section markers.") (defvar rpm-default-umask "-" "*Default umask for files, specified with \"%attr\".") @@ -302,157 +355,128 @@ value returned by function `user-mail-address'." ;;------------------------------------------------------------ (defvar rpm-no-gpg nil "Tell rpm not to sign package.") +(defvar rpm-spec-nobuild-option "--nobuild" "Option for no build.") (defvar rpm-tags-list - ;; From RPM 4.1 sources, file build/parsePreamble.c: preambleList[].") - '(("AutoProv") - ("AutoReq") - ("AutoReqProv") - ("BuildArch") - ("BuildArchitectures") - ("BuildConflicts") - ("BuildPreReq") - ("BuildRequires") - ("BuildRoot") - ("Conflicts") + ;; From RPM 4.12.90 sources, file build/parsePreamble.c: preambleList[]: + '(("Name") + ("Version") + ("Release") + ("Epoch") + ("Summary") ("License") - ("%description") ("Distribution") ("DistURL") - ("DocDir") - ("Epoch") + ("Vendor") + ("Group") + ("Packager") + ("URL") + ("VCS") + ("Source") + ("Patch") + ("NoSource") + ("NoPatch") ("ExcludeArch") - ("ExcludeOS") ("ExclusiveArch") + ("ExcludeOS") ("ExclusiveOS") - ("%files") - ("Group") ("Icon") - ("%ifarch") - ("License") - ("Name") - ("NoPatch") - ("NoSource") - ("Obsoletes") - ("%package") - ("Packager") - ("Patch") - ("Prefix") - ("Prefixes") - ("PreReq") ("Provides") - ("Release") ("Requires") - ("RHNPlatform") - ("Serial") - ("Source") - ("Summary") - ("URL") - ("Vendor") - ("Version")) + ("Recommends") + ("Suggests") + ("Supplements") + ("Enhances") + ("PreReq") + ("Conflicts") + ("Obsoletes") + ("Prefixes") + ("Prefix") + ("BuildRoot") + ("BuildArchitectures") + ("BuildArch") + ("BuildConflicts") + ("BuildPreReq") + ("BuildRequires") + ("AutoReqProv") + ("AutoReq") + ("AutoProv") + ("DocDir") + ("DistTag") + ("BugURL") + ("OrderWithRequires") + ("RemovePathPostFixes") + ;; ...plus some from rpm5.org: + ("CVSId") + ("SVNId") + ("BuildSuggests") + ("BuildEnhances") + ("Variants") + ("Variant") + ("XMajor") + ("XMinor") + ("RepoTag") + ("Keywords") + ("Keyword") + ("BuildPlatforms") + ;; ...plus a few macros that aren't tags but useful here. + ("%description") + ("%files") + ("%ifarch") + ("%package") + ) "List of elements that are valid tags.") -;; echo "(defvar rpm-group-tags-list" -;; echo " ;; Auto generated from Mageia GROUPS file" -;; printf "\t%s\n" "'(" -;; cat /usr/share/doc/*/GROUPS | while read i; do -;; printf "\t %s%s%s\n" '("' "$i" '")' -;; done -;; printf "\t%s\n\t%s" ")" '"List of elements that are valid group tags.")' +(defvar rpm-tags-regexp + (concat "\\(\\<" (regexp-opt (mapcar 'car rpm-tags-list)) + "\\|\\(Patch\\|Source\\)[0-9]+\\>\\)") + "Regular expression for matching valid tags.") + +(defvar rpm-obsolete-tags-list + ;; From RPM sources, file build/parsePreamble.c: preambleList[]. + '(("Copyright") ;; 4.4.2 + ("RHNPlatform") ;; 4.4.2, 4.4.9 + ("Serial") ;; 4.4.2, 4.4.9 + ) + "List of elements that are obsolete tags in some versions of rpm.") + +(defvar rpm-obsolete-tags-regexp + (regexp-opt (mapcar 'car rpm-obsolete-tags-list) 'words) + "Regular expression for matching obsolete tags.") (defvar rpm-group-tags-list - ;; Auto generated from Mageia GROUPS file - '( - ("Accessibility") - ("Archiving/Backup") - ("Archiving/Cd burning") - ("Archiving/Compression") - ("Archiving/Other") - ("Books/Computer books") - ("Books/Faqs") - ("Books/Howtos") - ("Books/Literature") - ("Books/Other") - ("Communications") - ("Databases") - ("Development/C") - ("Development/C++") - ("Development/Databases") - ("Development/GNOME and GTK+") - ("Development/Java") - ("Development/KDE and Qt") - ("Development/Kernel") - ("Development/Other") - ("Development/Perl") - ("Development/PHP") - ("Development/Python") - ("Development/Ruby") - ("Editors") - ("Education") - ("Emulators") - ("File tools") - ("Games/Adventure") - ("Games/Arcade") - ("Games/Boards") - ("Games/Cards") - ("Games/Other") - ("Games/Puzzles") - ("Games/Sports") - ("Games/Strategy") - ("Graphical desktop/Enlightenment") - ("Graphical desktop/FVWM based") - ("Graphical desktop/GNOME") - ("Graphical desktop/Icewm") - ("Graphical desktop/KDE") - ("Graphical desktop/Other") - ("Graphical desktop/Sawfish") - ("Graphical desktop/WindowMaker") - ("Graphical desktop/Xfce") - ("Graphics") - ("Monitoring") - ("Networking/Chat") - ("Networking/File transfer") - ("Networking/IRC") - ("Networking/Instant messaging") - ("Networking/Mail") - ("Networking/News") - ("Networking/Other") - ("Networking/Remote access") - ("Networking/WWW") - ("Office") - ("Publishing") - ("Sciences/Astronomy") - ("Sciences/Biology") - ("Sciences/Chemistry") - ("Sciences/Computer science") - ("Sciences/Geosciences") - ("Sciences/Mathematics") - ("Sciences/Other") - ("Sciences/Physics") - ("Shells") - ("Sound") - ("System/Base") - ("System/Configuration/Boot and Init") - ("System/Configuration/Hardware") - ("System/Configuration/Networking") - ("System/Configuration/Other") - ("System/Configuration/Packaging") - ("System/Configuration/Printing") - ("System/Fonts/Console") - ("System/Fonts/True type") - ("System/Fonts/Type1") - ("System/Fonts/X11 bitmap") - ("System/Internationalization") - ("System/Kernel and hardware") - ("System/Libraries") - ("System/Servers") - ("System/X11") - ("Terminals") - ("Text tools") - ("Toys") - ("Video") - ) - "List of elements that are valid group tags.") + ;; From RPM 4.4.9 sources, file GROUPS. + '(("Amusements/Games") + ("Amusements/Graphics") + ("Applications/Archiving") + ("Applications/Communications") + ("Applications/Databases") + ("Applications/Editors") + ("Applications/Emulators") + ("Applications/Engineering") + ("Applications/File") + ("Applications/Internet") + ("Applications/Multimedia") + ("Applications/Productivity") + ("Applications/Publishing") + ("Applications/System") + ("Applications/Text") + ("Development/Debuggers") + ("Development/Languages") + ("Development/Libraries") + ("Development/System") + ("Development/Tools") + ("Documentation") + ("System Environment/Base") + ("System Environment/Daemons") + ("System Environment/Kernel") + ("System Environment/Libraries") + ("System Environment/Shells") + ("User Interface/Desktops") + ("User Interface/X") + ("User Interface/X Hardware Support") + ) + "List of elements that are valid group tags.") (defvar rpm-spec-mode-syntax-table nil "Syntax table in use in `rpm-spec-mode' buffers.") @@ -474,6 +498,8 @@ value returned by function `user-mail-address'." (modify-syntax-entry ?| "." rpm-spec-mode-syntax-table) (modify-syntax-entry ?\' "." rpm-spec-mode-syntax-table)) +(eval-when-compile (or running-xemacs (defun set-keymap-name (a b)))) + (defvar rpm-spec-mode-map nil "Keymap used in `rpm-spec-mode'.") (unless rpm-spec-mode-map @@ -482,6 +508,7 @@ value returned by function `user-mail-address'." (set-keymap-name rpm-spec-mode-map 'rpm-spec-mode-map)) (define-key rpm-spec-mode-map "\C-c\C-c" 'rpm-change-tag) (define-key rpm-spec-mode-map "\C-c\C-e" 'rpm-add-change-log-entry) + (define-key rpm-spec-mode-map "\C-c\C-w" 'rpm-goto-add-change-log-entry) (define-key rpm-spec-mode-map "\C-c\C-i" 'rpm-insert-tag) (define-key rpm-spec-mode-map "\C-c\C-n" 'rpm-forward-section) (define-key rpm-spec-mode-map "\C-c\C-o" 'rpm-goto-section) @@ -510,10 +537,10 @@ value returned by function `user-mail-address'." (define-key rpm-spec-mode-map "\C-c\C-xi" 'rpm-change-timecheck-option) (define-key rpm-spec-mode-map "\C-c\C-xn" 'rpm-toggle-nobuild) (define-key rpm-spec-mode-map "\C-c\C-xo" 'rpm-files-owner) - (define-key rpm-spec-mode-map "\C-c\C-xp" 'rpm-change-target-option) (define-key rpm-spec-mode-map "\C-c\C-xr" 'rpm-toggle-rmsource) - (define-key rpm-spec-mode-map "\C-cxd" 'rpm-toggle-no-deps) + (define-key rpm-spec-mode-map "\C-c\C-xq" 'rpm-toggle-quiet) (define-key rpm-spec-mode-map "\C-c\C-xs" 'rpm-toggle-short-circuit) + (define-key rpm-spec-mode-map "\C-c\C-xt" 'rpm-change-target-option) (define-key rpm-spec-mode-map "\C-c\C-xu" 'rpm-files-umask) ;;(define-key rpm-spec-mode-map "\C-q" 'indent-spec-exp) ;;(define-key rpm-spec-mode-map "\t" 'sh-indent-line) @@ -550,14 +577,14 @@ value returned by function `user-mail-address'." ("Build Options" ["Short circuit" rpm-toggle-short-circuit :style toggle :selected rpm-spec-short-circuit] - ["No deps" rpm-toggle-no-deps - :style toggle :selected rpm-spec-no-deps] ["Remove source" rpm-toggle-rmsource :style toggle :selected rpm-spec-rmsource] ["Clean" rpm-toggle-clean :style toggle :selected rpm-spec-clean] ["No build" rpm-toggle-nobuild :style toggle :selected rpm-spec-nobuild] + ["Quiet" rpm-toggle-quiet + :style toggle :selected rpm-spec-quiet] ["GPG sign" rpm-toggle-sign-gpg :style toggle :selected rpm-spec-sign-gpg] ["Ignore dependencies" rpm-toggle-nodeps @@ -580,33 +607,41 @@ value returned by function `user-mail-address'." ))) (defvar rpm-spec-font-lock-keywords - '( - ("%[a-zA-Z0-9-_]+" 0 rpm-spec-macro-face) - ("^\\([a-zA-Z0-9]+\\)\\(\([a-zA-Z0-9,]+\)\\):" - (1 rpm-spec-tag-face) - (2 rpm-spec-ghost-face)) - ("^\\([a-zA-Z0-9]+\\):" 1 rpm-spec-tag-face) - ("%\\(de\\(fine\\|scription\\)\\|files\\|package\\)[ \t]+\\([^-][^ \t\n]*\\)" + (list + (cons rpm-section-regexp rpm-spec-section-face) + '("%[a-zA-Z0-9_]+" 0 rpm-spec-macro-face) + (cons (concat "^" rpm-obsolete-tags-regexp "\\(\([a-zA-Z0-9,_]+\)\\)[ \t]*:") + '((1 'rpm-spec-obsolete-tag-face) + (2 'rpm-spec-ghost-face))) + (cons (concat "^" rpm-tags-regexp "\\(\([a-zA-Z0-9,_]+\)\\)[ \t]*:") + '((1 'rpm-spec-tag-face) + (3 'rpm-spec-ghost-face))) + (cons (concat "^" rpm-obsolete-tags-regexp "[ \t]*:") + '(1 'rpm-spec-obsolete-tag-face)) + (cons (concat "^" rpm-tags-regexp "[ \t]*:") + '(1 'rpm-spec-tag-face)) + '("%\\(de\\(fine\\|scription\\)\\|files\\|global\\|package\\)[ \t]+\\([^-][^ \t\n]*\\)" (3 rpm-spec-package-face)) - ("%p\\(ost\\|re\\)\\(un\\)?[ \t]+\\([^-][^ \t\n]*\\)" + '("^%p\\(ost\\|re\\)\\(un\\|trans\\)?[ \t]+\\([^-][^ \t\n]*\\)" (3 rpm-spec-package-face)) - ("%configure " 0 rpm-spec-macro-face) - ("%dir[ \t]+\\([^ \t\n]+\\)[ \t]*" 1 rpm-spec-dir-face) - ("%doc\\(dir\\)?[ \t]+\\(.*\\)\n" 2 rpm-spec-doc-face) - ("%\\(ghost\\|config\\)[ \t]+\\(.*\\)\n" 2 rpm-spec-ghost-face) - ("^%.+-[a-zA-Z][ \t]+\\([a-zA-Z0-9\.-]+\\)" 1 rpm-spec-doc-face) - ("^\\(.+\\)(\\([a-zA-Z]\\{2,2\\}\\)):" + '("%configure " 0 rpm-spec-macro-face) + '("%dir[ \t]+\\([^ \t\n]+\\)[ \t]*" 1 rpm-spec-dir-face) + '("%\\(doc\\(dir\\)?\\|license\\)[ \t]+\\(.*\\)\n" 3 rpm-spec-doc-face) + '("%\\(ghost\\|config\\([ \t]*(.*)\\)?\\)[ \t]+\\(.*\\)\n" + 3 rpm-spec-ghost-face) + '("^%.+-[a-zA-Z][ \t]+\\([a-zA-Z0-9\.-]+\\)" 1 rpm-spec-doc-face) + '("^\\(.+\\)(\\([a-zA-Z]\\{2,2\\}\\)):" (1 rpm-spec-tag-face) (2 rpm-spec-doc-face)) - ("^\\*\\(.*[0-9] \\)\\(.*\\)\\(<.*>\\)\\(.*\\)\n" + '("^\\*\\(.*[0-9] \\)\\(.*\\)<\\(.*\\)>\\(.*\\)\n" (1 rpm-spec-dir-face) (2 rpm-spec-package-face) (3 rpm-spec-tag-face) - (4 font-lock-warning-face)) - ("%{[^{}]*}" 0 rpm-spec-macro-face) - ("$[a-zA-Z0-9_]+" 0 rpm-spec-var-face) - ("${[a-zA-Z0-9_]+}" 0 rpm-spec-var-face) - ) + (4 rpm-spec-ghost-face)) + '("%{[^{}]*}" 0 rpm-spec-macro-face) + '("$[a-zA-Z0-9_]+" 0 rpm-spec-var-face) + '("${[a-zA-Z0-9_]+}" 0 rpm-spec-var-face) + ) "Additional expressions to highlight in `rpm-spec-mode'.") ;;Initialize font lock for xemacs @@ -618,6 +653,8 @@ value returned by function `user-mail-address'." ;;------------------------------------------------------------ +(add-hook 'rpm-spec-mode-new-file-hook 'rpm-spec-initialize) + ;;;###autoload (defun rpm-spec-mode () "Major mode for editing RPM spec files. @@ -645,13 +682,13 @@ with no args, if that value is non-nil." "Post menu for `rpm-spec-mode'." rpm-spec-mode-menu) (easy-menu-add rpm-spec-mode-menu) - (if (= (buffer-size) 0) - (rpm-spec-initialize)) + (if (and (= (buffer-size) 0) rpm-spec-initialize-sections) + (run-hooks 'rpm-spec-mode-new-file-hook)) - (if (executable-find "rpmbuild") - (setq rpm-spec-build-command "rpmbuild") - (setq rpm-spec-old-rpm t) - (setq rpm-spec-build-command "rpm")) + (if (not (executable-find "rpmbuild")) + (progn + (setq rpm-spec-build-command "rpm") + (setq rpm-spec-nobuild-option "--test"))) (make-local-variable 'paragraph-start) (setq paragraph-start (concat "$\\|" page-delimiter)) @@ -680,50 +717,56 @@ with no args, if that value is non-nil." (defun rpm-command-filter (process string) "Filter to process normal output." - (save-excursion - (set-buffer (process-buffer process)) + (with-current-buffer (process-buffer process) (save-excursion (goto-char (process-mark process)) (insert-before-markers string) (set-marker (process-mark process) (point))))) -; insert one space, or the number of tabs if rpm-spec-use-tabs is true -(defun rpm-insert-space-or-tabs (tabs) - (if rpm-spec-use-tabs - (if (> tabs 0) - (concat "\t" (rpm-insert-space-or-tabs (1- tabs))) - "") - " ")) - ;;------------------------------------------------------------ +(defvar rpm-change-log-uses-utc nil + "*If non-nil, \\[rpm-add-change-log-entry] will use Universal time (UTC). +If this is nil, it uses local time as returned by `current-time'. + +This variable is global by default, but you can make it buffer-local.") + +(defsubst rpm-change-log-date-string () + "Return the date string for today, inserted by \\[rpm-add-change-log-entry]. +If `rpm-change-log-uses-utc' is nil, \"today\" means the local time zone." + (format-time-string "%a %b %e %Y" nil rpm-change-log-uses-utc)) + +(defun rpm-goto-add-change-log-header () + "Find change log and add header (if needed) for today" + (rpm-goto-section "changelog") + (let* ((address (rpm-spec-user-mail-address)) + (fullname (or rpm-spec-user-full-name (user-full-name))) + (system-time-locale "C") + (string (concat "* " (rpm-change-log-date-string) " " + fullname " <" address ">" + (and rpm-spec-insert-changelog-version + (concat " - " (rpm-find-spec-version t)))))) + (if (not (search-forward string nil t)) + (insert "\n" string "\n") + (forward-line 2)))) + (defun rpm-add-change-log-entry (&optional change-log-entry) "Find change log and add an entry for today." - (interactive "P") - (goto-char (point-min)) - (if (search-forward-regexp "^%changelog[ \t]*$" nil t) - (let* ((address (or rpm-spec-user-mail-address user-mail-address)) - (fullname (or rpm-spec-user-full-name user-full-name)) - (string (concat "* " (substring (current-time-string) 0 11) - (substring (current-time-string) -4) " " - fullname " <" address "> " - (or - (and rpm-spec-insert-changelog-version - (or (and rpm-spec-insert-changelog-version-with-shell - (rpm-find-spec-version-with-shell)) - (rpm-find-spec-version)))) - ""))) - (if (not (search-forward string nil t)) - (insert "\n" string "\n") - (progn (next-line 1) - (beginning-of-line))) - (unless (eq (point) (1- (point-max))) - (insert "\n") - (previous-line 1)) - (insert "- ") - (if change-log-entry - (insert (concat (format "%s." change-log-entry))))) - (message "No \"%%changelog\" entry found..."))) + (interactive "sChange log entry: ") + (save-excursion + (rpm-goto-add-change-log-header) + (while (looking-at "^-") + (forward-line)) + (insert "- " change-log-entry "\n"))) + +(defun rpm-goto-add-change-log-entry () + "Goto change log and add an header for today (if needed)." + (interactive) + (rpm-goto-add-change-log-header) + (while (looking-at "^-") + (forward-line)) + (insert "- \n") + (end-of-line '0)) ;;------------------------------------------------------------ @@ -785,22 +828,23 @@ controls whether case is significant." (beginning-of-line) (if (not what) (setq what (rpm-completing-read "Tag: " rpm-tags-list))) - (if (string-match "^%" what) - (setq read-text (concat "Packagename for " what ": ") - insert-text (concat what " ")) - (setq read-text (concat what ": ") - insert-text (concat what ": "))) - (cond - ((string-equal what "Group") - (rpm-insert-group)) - ((string-equal what "Source") - (rpm-insert-n "Source")) - ((string-equal what "Patch") - (rpm-insert-n "Patch")) - (t - (if file-completion - (insert insert-text (read-file-name (concat read-text) "" "" nil) "\n") - (insert insert-text (read-from-minibuffer (concat read-text)) "\n"))))) + (let (read-text insert-text) + (if (string-match "^%" what) + (setq read-text (concat "Packagename for " what ": ") + insert-text (concat what " ")) + (setq read-text (concat what ": ") + insert-text (concat what ": "))) + (cond + ((string-equal what "Group") + (call-interactively 'rpm-insert-group)) + ((string-equal what "Source") + (rpm-insert-n "Source")) + ((string-equal what "Patch") + (rpm-insert-n "Patch")) + (t + (if file-completion + (insert insert-text (read-file-name (concat read-text) "" "" nil) "\n") + (insert insert-text (read-from-minibuffer (concat read-text)) "\n")))))) (defun rpm-topdir () (or @@ -816,7 +860,7 @@ controls whether case is significant." (save-excursion (goto-char (point-max)) (if (search-backward-regexp (concat "^" what "\\([0-9]*\\):") nil t) - (let ((release (1+ (string-to-int (match-string 1))))) + (let ((release (1+ (string-to-number (match-string 1))))) (forward-line 1) (let ((default-directory (concat (rpm-topdir) "/SOURCES/"))) (insert what (int-to-string release) ": " @@ -843,7 +887,7 @@ controls whether case is significant." (replace-match (concat what ": " (read-from-minibuffer (concat "New " what ": ") (match-string 1)))) - (message (concat what " tag not found..."))))))) + (message "%s tag not found..." what)))))) (defun rpm-change-n (what &optional arg) "Change given tag with possible number." @@ -857,25 +901,24 @@ controls whether case is significant." (concat what number ": " (read-file-name (concat "New " what number " file: ") "" "" nil (match-string 1))))) - (message (concat what " number \"" number "\" not found...")))))) + (message "%s number \"%s\" not found..." what number))))) (defun rpm-insert-group (group) "Insert Group tag." (interactive (list (rpm-completing-read "Group: " rpm-group-tags-list))) (beginning-of-line) - (insert "Group:" (rpm-insert-space-or-tabs 2) group "\n")) + (insert "Group: " group "\n")) (defun rpm-change-group (&optional arg) "Update Group tag." (interactive "p") (save-excursion (goto-char (point-min)) - (if (search-forward-regexp "^Group:[ \t]*\\(.*\\)$" nil t) + (if (search-forward-regexp "^Group: \\(.*\\)$" nil t) (replace-match - (concat "Group:" - (rpm-insert-space-or-tabs 2) - (rpm-completing-read "Group: " rpm-group-tags-list - nil nil (match-string 1)))) + (concat "Group: " + (insert (rpm-completing-read "Group: " rpm-group-tags-list + nil nil (match-string 1))))) (message "Group tag not found...")))) (defun rpm-insert-tag (&optional arg) @@ -894,10 +937,8 @@ controls whether case is significant." "Insert Packager tag." (interactive "p") (beginning-of-line) - (insert "Packager:" - (rpm-insert-space-or-tabs 1) - (or rpm-spec-user-full-name (user-full-name)) - " <" (or rpm-spec-user-mail-address (user-mail-address)) ">\n")) + (insert "Packager: " (or rpm-spec-user-full-name (user-full-name)) + " <" (rpm-spec-user-mail-address) ">\n")) (defun rpm-change-packager (&optional arg) "Update Packager tag." @@ -992,14 +1033,17 @@ leave point at previous location." (defun rpm-build (buildoptions) "Build this RPM package." - (setq rpm-buffer-name - (concat "*" rpm-spec-build-command " " - (file-name-nondirectory buffer-file-name) "*")) - (rpm-process-check rpm-buffer-name) - (if (get-buffer rpm-buffer-name) - (kill-buffer rpm-buffer-name)) - (create-file-buffer rpm-buffer-name) - (display-buffer rpm-buffer-name) + (if (and (buffer-modified-p) + (y-or-n-p (format "Buffer %s modified, save it? " (buffer-name)))) + (save-buffer)) + (let ((rpm-buffer-name + (concat "*" rpm-spec-build-command " " buildoptions " " + (file-name-nondirectory buffer-file-name) "*"))) + (rpm-process-check rpm-buffer-name) + (if (get-buffer rpm-buffer-name) + (kill-buffer rpm-buffer-name)) + (create-file-buffer rpm-buffer-name) + (display-buffer rpm-buffer-name)) (setq buildoptions (list buildoptions buffer-file-name)) (if (or rpm-spec-short-circuit rpm-spec-nobuild) (setq rpm-no-gpg t)) @@ -1009,8 +1053,6 @@ leave point at previous location." (setq buildoptions (cons "--clean" buildoptions))) (if rpm-spec-short-circuit (setq buildoptions (cons "--short-circuit" buildoptions))) - (if rpm-spec-no-deps - (setq buildoptions (cons "--nodeps" buildoptions))) (if (and (not (equal rpm-spec-timecheck "0")) (not (equal rpm-spec-timecheck ""))) (setq buildoptions (cons "--timecheck" (cons rpm-spec-timecheck @@ -1022,34 +1064,55 @@ leave point at previous location." (setq buildoptions (cons "--target" (cons rpm-spec-target buildoptions)))) (if rpm-spec-nobuild - (setq buildoptions (cons (if rpm-spec-old-rpm "--test" "--nobuild") - buildoptions))) + (setq buildoptions (cons rpm-spec-nobuild-option buildoptions))) + (if rpm-spec-quiet + (setq buildoptions (cons "--quiet" buildoptions))) (if rpm-spec-nodeps (setq buildoptions (cons "--nodeps" buildoptions))) (if (and rpm-spec-sign-gpg (not rpm-no-gpg)) (setq buildoptions (cons "--sign" buildoptions))) - (save-excursion - (set-buffer (get-buffer rpm-buffer-name)) - (goto-char (point-max))) - (let ((process - (apply 'start-process rpm-spec-build-command rpm-buffer-name - rpm-spec-build-command buildoptions))) - (if (and rpm-spec-sign-gpg (not rpm-no-gpg)) - (let ((rpm-passwd-cache (read-passwd "GPG passphrase: "))) - (process-send-string process (concat rpm-passwd-cache "\n")))) - (set-process-filter process 'rpm-command-filter))) + + (if rpm-spec-auto-topdir + (if (string-match ".*/SPECS/$" default-directory) + (let ((topdir (expand-file-name default-directory))) + (setq buildoptions + (cons + (concat "--define \"_topdir " + (replace-regexp-in-string "/SPECS/$" "" topdir) + "\"") + buildoptions))))) + + (progn + (defun list->string (lst) + (if (cdr lst) + (concat (car lst) " " (list->string (cdr lst))) + (car lst))) + (compilation-start (list->string (cons rpm-spec-build-command buildoptions)) 'rpmbuild-mode)) + + (if (and rpm-spec-sign-gpg (not rpm-no-gpg)) + (let ((build-proc (get-buffer-process + (get-buffer + (compilation-buffer-name "rpmbuild" nil nil)))) + (rpm-passwd-cache (read-passwd "GPG passphrase: "))) + (process-send-string build-proc (concat rpm-passwd-cache "\n"))))) (defun rpm-build-prepare (&optional arg) "Run a `rpmbuild -bp'." (interactive "p") - (setq rpm-no-gpg t) - (rpm-build "-bp")) + (if rpm-spec-short-circuit + (message "Cannot run `%s -bp' with --short-circuit" + rpm-spec-build-command) + (setq rpm-no-gpg t) + (rpm-build "-bp"))) (defun rpm-list-check (&optional arg) "Run a `rpmbuild -bl'." (interactive "p") - (setq rpm-no-gpg t) - (rpm-build "-bl")) + (if rpm-spec-short-circuit + (message "Cannot run `%s -bl' with --short-circuit" + rpm-spec-build-command) + (setq rpm-no-gpg t) + (rpm-build "-bl"))) (defun rpm-build-compile (&optional arg) "Run a `rpmbuild -bc'." @@ -1066,20 +1129,29 @@ leave point at previous location." (defun rpm-build-binary (&optional arg) "Run a `rpmbuild -bb'." (interactive "p") - (setq rpm-no-gpg nil) - (rpm-build "-bb")) + (if rpm-spec-short-circuit + (message "Cannot run `%s -bb' with --short-circuit" + rpm-spec-build-command) + (setq rpm-no-gpg nil) + (rpm-build "-bb"))) (defun rpm-build-source (&optional arg) "Run a `rpmbuild -bs'." (interactive "p") - (setq rpm-no-gpg nil) - (rpm-build "-bs")) + (if rpm-spec-short-circuit + (message "Cannot run `%s -bs' with --short-circuit" + rpm-spec-build-command) + (setq rpm-no-gpg nil) + (rpm-build "-bs"))) (defun rpm-build-all (&optional arg) "Run a `rpmbuild -ba'." (interactive "p") - (setq rpm-no-gpg nil) - (rpm-build "-ba")) + (if rpm-spec-short-circuit + (message "Cannot run `%s -ba' with --short-circuit" + rpm-spec-build-command) + (setq rpm-no-gpg nil) + (rpm-build "-ba"))) (defun rpm-process-check (buffer) "Check if BUFFER has a running process. @@ -1102,14 +1174,6 @@ command." (message (concat "Turned `--short-circuit' " (if rpm-spec-short-circuit "on" "off") "."))) -(defun rpm-toggle-no-deps (&optional arg) - "Toggle rpm-spec-no-deps." - (interactive "p") - (setq rpm-spec-no-deps (not rpm-spec-no-deps)) - (rpm-update-mode-name) - (message (concat "Turned `--nodeps' " - (if rpm-spec-no-deps "on" "off") "."))) - (defun rpm-toggle-rmsource (&optional arg) "Toggle `rpm-spec-rmsource'." (interactive "p") @@ -1131,9 +1195,17 @@ command." (interactive "p") (setq rpm-spec-nobuild (not rpm-spec-nobuild)) (rpm-update-mode-name) - (message (concat "Turned `" (if rpm-spec-old-rpm "--test" "--nobuild") "' " + (message (concat "Turned `" rpm-spec-nobuild-option "' " (if rpm-spec-nobuild "on" "off") "."))) +(defun rpm-toggle-quiet (&optional arg) + "Toggle `rpm-spec-quiet'." + (interactive "p") + (setq rpm-spec-quiet (not rpm-spec-quiet)) + (rpm-update-mode-name) + (message (concat "Turned `--quiet' " + (if rpm-spec-quiet "on" "off") "."))) + (defun rpm-toggle-sign-gpg (&optional arg) "Toggle `rpm-spec-sign-gpg'." (interactive "p") @@ -1161,17 +1233,17 @@ command." (defun rpm-update-mode-name () "Update `mode-name' according to values set." (setq mode-name "RPM-SPEC") - (setq modes (concat (if rpm-spec-add-attr "A") - (if rpm-spec-clean "C") - (if rpm-spec-nodeps "D") - (if rpm-spec-sign-gpg "G") - (if rpm-spec-nobuild "N") - (if rpm-spec-rmsource "R") - (if rpm-spec-short-circuit "S") - (if rpm-spec-no-deps "D") - )) - (if (not (equal modes "")) - (setq mode-name (concat mode-name ":" modes)))) + (let ((modes (concat (if rpm-spec-add-attr "A") + (if rpm-spec-clean "C") + (if rpm-spec-nodeps "D") + (if rpm-spec-sign-gpg "G") + (if rpm-spec-nobuild "N") + (if rpm-spec-rmsource "R") + (if rpm-spec-short-circuit "S") + (if rpm-spec-quiet "Q") + ))) + (if (not (equal modes "")) + (setq mode-name (concat mode-name ":" modes))))) ;;------------------------------------------------------------ @@ -1216,14 +1288,18 @@ command." (interactive "p") (save-excursion (goto-char (point-min)) - (if (search-forward-regexp "^Release:\\([ \t]*\\)\\(\\([^.\n]+\\.\\)*\\)\\([0-9]+\\)\\(.*\\)" nil t) - (let ((release (1+ (string-to-int (match-string 4))))) - (setq release (concat (match-string 1) (match-string 2) (int-to-string release) (match-string 5))) - (replace-match (concat "Release:" release)) - (message (concat "Release tag changed to " release "."))) - (if (search-forward-regexp "^Release:[ \t]*%{?\\([^}]*\\)}?$" nil t) - (rpm-increase-release-with-macros) - (message "No Release tag found..."))))) + (if (search-forward-regexp + ;; Try to find the last digit-only group of a dot-separated release string + (concat "^\\(Release[ \t]*:[ \t]*\\)" + "\\(.*[ \t\\.}]\\)\\([0-9]+\\)\\([ \t\\.%].*\\|$\\)") nil t) + (let ((release (1+ (string-to-number (match-string 3))))) + (setq release + (concat (match-string 2) (int-to-string release) (match-string 4))) + (replace-match (concat (match-string 1) release)) + (message "Release tag changed to %s." release)) + (if (search-forward-regexp "^Release[ \t]*:[ \t]*%{?\\([^}]*\\)}?$" nil t) + (rpm-increase-release-with-macros) + (message "No Release tag to increase found..."))))) ;;------------------------------------------------------------ @@ -1231,22 +1307,32 @@ command." "Get the value of FIELD, searching up to buffer position MAX. See `search-forward-regexp'." (save-excursion - (ignore-errors + (condition-case nil (let ((str (progn (goto-char (point-min)) - (search-forward-regexp (concat - field ":[ \t]*\\(.*?\\)[ \t]*$") max) + (search-forward-regexp + (concat "^" field ":[ \t]*\\(.*?\\)[ \t]*$") max) (match-string 1)))) - (if (string-match "%{?\\([^}]*\\)}?$" str) - (progn - (goto-char (point-min)) - (search-forward-regexp - (concat "%define[ \t]+" (substring str (match-beginning 1) - (match-end 1)) - "[ \t]+\\(.*\\)")) - (match-string 1)) - str))))) + ;; Try to expand macros + (if (string-match "\\(%{?\\(\\?\\)?\\)\\([a-zA-Z0-9_]*\\)\\(}?\\)" str) + (let ((start-string (substring str 0 (match-beginning 1))) + (end-string (substring str (match-end 4)))) + (if (progn + (goto-char (point-min)) + (search-forward-regexp + (concat "%\\(define\\|global\\)[ \t]+" + (match-string 3 str) + "[ \t]+\\(.*\\)") nil t)) + ;; Got it - replace. + (concat start-string (match-string 2) end-string) + (if (match-string 2 str) + ;; Conditionally evaluated macro - remove it. + (concat start-string end-string) + ;; Leave as is. + str))) + str)) + (error nil)))) (defun rpm-find-spec-version (&optional with-epoch) "Get the version string. @@ -1264,85 +1350,107 @@ if one is present in the file." version (and release (concat "-" release))))))) -(defun rpm--with-temp-file (prefix f) - (let ((file (make-temp-file prefix))) - (unwind-protect - (funcall f file) - (delete-file file)))) - -(defun rpm-find-spec-version-with-shell () - "Find the version and release with the rpm command - more robust but slower than the lisp version" - (rpm--with-temp-file "spec" (lambda (tmpfile) - (write-region (point-min) (point-max) tmpfile nil 1) - (let ((relver)) - (with-temp-buffer - (apply 'call-process "rpm" nil t nil - (list "-q" "--qf" "'%{VERSION}-%{RELEASE}\\n'" "--specfile" tmpfile)) - (goto-char (point-min)) - (if (re-search-forward "\\([0-9]+.+\\)" nil t) - (setq relver (match-string 1))) - ) - relver) - ))) - (defun rpm-increase-release-with-macros () (save-excursion (let ((str (progn (goto-char (point-min)) - (search-forward-regexp (concat "Release:[ \t]*\\(.+\\).*$") nil) - (match-string 1))) - (increase-macro (lambda (macros) - (goto-char (point-min)) - (if (search-forward-regexp - (concat "%define[ \t]+" macros - "\\([ \t]+\\)\\(\\([^.\n]+\\.\\)*\\)\\([0-9]+\\)\\(.*\\)") nil t) - (let ((dinrel (concat macros (match-string 1) (match-string 2) - (int-to-string (1+ (string-to-int - (match-string 4)))) - (match-string 5)))) - (replace-match (concat "%define " dinrel)) - (message (concat "Release tag changed to " dinrel ".")) - t))))) - - (if (string-match "%{?\\([^}]*\\)}?$" str) - (let ((macros (substring str (match-beginning 1) (match-end 1)))) - (or (funcall increase-macro macros) - (and (search-forward-regexp - (concat "%define[ \t]+" macros "[ \t]+%mkrel[ \t]+%{rel}") nil t) - (funcall increase-macro "rel")) - (and (search-forward-regexp "\\(%mkrel[ \t]+\\)\\([0-9]+\\)$" nil t) - (replace-match (concat (match-string 1) (int-to-string (1+ (string-to-int (match-string 2))))))) - )))))) + (search-forward-regexp "^Release[ \t]*:[ \t]*\\(.+\\).*$" nil) + (match-string 1)))) + (let ((inrel + (if (string-match "%{?\\([^}]*\\)}?$" str) + (progn + (goto-char (point-min)) + (let ((macros (substring str (match-beginning 1) + (match-end 1)))) + (search-forward-regexp + (concat "%define[ \t]+" macros + "[ \t]+\\(\\([0-9]\\|\\.\\)+\\)\\(.*\\)")) + (concat macros " " (int-to-string (1+ (string-to-number + (match-string 1)))) + (match-string 3)))) + str))) + (let ((dinrel inrel)) + (replace-match (concat "%define " dinrel)) + (message "Release tag changed to %s." dinrel)))))) ;;------------------------------------------------------------ (defun rpm-spec-initialize () "Create a default spec file if one does not exist or is empty." - (let (file name version (release "1")) + (let (file name version (release rpm-spec-default-release)) (setq file (if (buffer-file-name) (file-name-nondirectory (buffer-file-name)) (buffer-name))) - (string-match "\\(.*\\).spec" file) - (setq name (match-string 1 file)) + (cond + ((eq (string-match "\\(.*\\)-\\([^-]*\\)-\\([^-]*\\).spec" file) 0) + (setq name (match-string 1 file)) + (setq version (match-string 2 file)) + (setq release (match-string 3 file))) + ((eq (string-match "\\(.*\\)-\\([^-]*\\).spec" file) 0) + (setq name (match-string 1 file)) + (setq version (match-string 2 file))) + ((eq (string-match "\\(.*\\).spec" file) 0) + (setq name (match-string 1 file)))) + + (if rpm-spec-indent-heading-values + (insert + "Summary: " + "\nName: " (or name "") + "\nVersion: " (or version "") + "\nRelease: " (or release "") + (if rpm-spec-default-epoch + (concat "\nEpoch: " + (int-to-string rpm-spec-default-epoch)) + "") + "\nLicense: " + "\nGroup: " + "\nURL: " + "\nSource0: %{name}-%{version}.tar.gz" + "\nBuildRoot: " rpm-spec-default-buildroot) + (insert + "Summary: " + "\nName: " (or name "") + "\nVersion: " (or version "") + "\nRelease: " (or release "") + (if rpm-spec-default-epoch + (concat "\nEpoch: " (int-to-string rpm-spec-default-epoch)) + "") + "\nLicense: " + "\nGroup: " + "\nURL: " + "\nSource0: %{name}-%{version}.tar.gz" + "\nBuildRoot: " rpm-spec-default-buildroot)) (insert - "%define name " (or name "") - "\n%define version " (or version "") - "\n%define release %mkrel " (or release "") - "\n\nSummary:" (rpm-insert-space-or-tabs 1) - "\nName:" (rpm-insert-space-or-tabs 2) "%{name}" - "\nVersion:" (rpm-insert-space-or-tabs 1) "%{version}" - "\nRelease:" (rpm-insert-space-or-tabs 1) "%{release}" - "\nSource0:" (rpm-insert-space-or-tabs 1) "%{name}-%{version}.tar.bz2" - "\nLicense:" (rpm-insert-space-or-tabs 1) - "\nGroup:" (rpm-insert-space-or-tabs 2) - "\nUrl:" (rpm-insert-space-or-tabs 2) - "\n\n%description\n" - "\n%prep\n%setup -q\n\n%build\n\n%install" - "\n\n%files\n")) - (goto-char (point-min))) + "\n\n%description\n" + "\n%prep" + "\n%setup -q" + "\n\n%build\n" + (or rpm-spec-default-build-section "") + "\n%install\n" + (or rpm-spec-default-install-section "") + "\n%clean\n" + (or rpm-spec-default-clean-section "") + "\n\n%files" + "\n%defattr(-,root,root,-)" + "\n%doc\n" + "\n\n%changelog\n") + + (end-of-line 1) + (rpm-add-change-log-entry "Initial build."))) + +;;------------------------------------------------------------ + +(defun rpm-spec-user-mail-address () + "User mail address helper." + (cond + (rpm-spec-user-mail-address + rpm-spec-user-mail-address) + ((fboundp 'user-mail-address) + (user-mail-address)) + (t + user-mail-address))) ;;------------------------------------------------------------ @@ -1352,11 +1460,13 @@ if one is present in the file." (message (concat "rpm-spec-mode version " rpm-spec-mode-version - " by Stig Bjørlykke, <stigb@tihlde.org>"))) + " by Stig Bjørlykke, <stig@bjorlykke.org>"))) -;;;###autoload -(add-to-list 'auto-mode-alist '("\\.spec$" . rpm-spec-mode)) +;;;###autoload(add-to-list 'auto-mode-alist '("\\.spec\\(\\.in\\)?$" . rpm-spec-mode)) (provide 'rpm-spec-mode) +;;;###autoload +(define-compilation-mode rpmbuild-mode "RPM build" "" + (set (make-local-variable 'compilation-disable-input) t)) ;;; rpm-spec-mode.el ends here @@ -4,125 +4,49 @@ ############################################################# # Values for RPM_OPT_FLAGS for various platforms -optflags: i386 %{__common_cflags_with_ssp} -fomit-frame-pointer -march=i386 -fasynchronous-unwind-tables -optflags: i486 %{__common_cflags_with_ssp} -fomit-frame-pointer -march=i486 -fasynchronous-unwind-tables -optflags: k6 %{__common_cflags_with_ssp} -fomit-frame-pointer -march=k6 -fasynchronous-unwind-tables -optflags: i586 %{__common_cflags_with_ssp} -fomit-frame-pointer -march=i586 -mtune=generic -fasynchronous-unwind-tables -optflags: i686 %{__common_cflags_with_ssp} -fomit-frame-pointer -march=i686 -fasynchronous-unwind-tables -optflags: athlon %{__common_cflags_with_ssp} -fomit-frame-pointer -march=athlon -fasynchronous-unwind-tables -optflags: pentium3 %{__common_cflags_with_ssp} -fomit-frame-pointer -march=pentium3 -fasynchronous-unwind-tables -optflags: pentium4 %{__common_cflags_with_ssp} -fomit-frame-pointer -march=pentium4 -fasynchronous-unwind-tables - -optflags: x86_64 %{__common_cflags_with_ssp} -fasynchronous-unwind-tables -optflags: amd64 %{__common_cflags_with_ssp} -optflags: ia32e %{__common_cflags_with_ssp} - -optflags: ia64 %{__common_cflags} +optflags: i386 %{__common_cflags_with_ssp} -fomit-frame-pointer -m32 -march=i386 -fasynchronous-unwind-tables -fstack-clash-protection +optflags: i486 %{__common_cflags_with_ssp} -fomit-frame-pointer -m32 -march=i486 -fasynchronous-unwind-tables -fstack-clash-protection +optflags: i586 %{__common_cflags_with_ssp} -fomit-frame-pointer -m32 -march=i586 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection +optflags: i686 %{__common_cflags_with_ssp} -fomit-frame-pointer -m32 -march=i686 -msse2 -mtune=generic -mfpmath=sse -mstackrealign -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection=full +optflags: athlon %{__common_cflags_with_ssp} -fomit-frame-pointer -m32 -march=athlon -fasynchronous-unwind-tables -fstack-clash-protection +optflags: x86_64 %{__common_cflags_with_ssp} -m64 -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection=full - # XXX Please note that -mieee has been added in rpm-3.0.5. -optflags: alpha %{__common_cflags} -mieee -mcpu=ev5 -optflags: alphaev5 %{__common_cflags} -mieee -mcpu=ev5 -optflags: alphaev56 %{__common_cflags} -mieee -mcpu=ev56 -optflags: alphapca56 %{__common_cflags} -mieee -mcpu=pca56 -optflags: alphaev6 %{__common_cflags} -mieee -mcpu=ev6 -optflags: alphaev67 %{__common_cflags} -mieee -mcpu=ev67 - -optflags: sparc %{__common_cflags} -m32 -mtune=ultrasparc -optflags: sparcv9 %{__common_cflags} -m32 -mcpu=ultrasparc -optflags: sparc64 %{__common_cflags} -m64 -mcpu=ultrasparc - -optflags: m68k %{__common_cflags} -fomit-frame-pointer - -optflags: ppc %{__common_cflags_with_ssp} -fsigned-char -mcpu=750 -mtune=7450 -optflags: ppciseries %{__common_cflags_with_ssp} -fsigned-char -optflags: ppcpseries %{__common_cflags_with_ssp} -fsigned-char -optflags: ppc32 %{__common_cflags_with_ssp} -m32 -fsigned-char -mcpu=power4 -mtune=cell -optflags: ppc64 %{__common_cflags_with_ssp} -m64 -fsigned-char -mcpu=power4 -mtune=cell - -optflags: parisc %{__common_cflags} -mpa-risc-1-0 -optflags: hppa1.0 %{__common_cflags} -mpa-risc-1-0 -optflags: hppa1.1 %{__common_cflags} -mpa-risc-1-0 -optflags: hppa1.2 %{__common_cflags} -mpa-risc-1-0 -optflags: hppa2.0 %{__common_cflags} -mpa-risc-1-0 - -optflags: mips %{__common_cflags} -march=mips3 -optflags: mipsel %{__common_cflags} -march=mips3 -optflags: mips32el %{__common_cflags} -march=mips3 -mabi=n32 -optflags: mips64el %{__common_cflags} -march=mips3 -mabi=64 - -optflags: armv3l %{__common_cflags} -march=armv3 -optflags: armv4b %{__common_cflags} -march=armv4 -optflags: armv4l %{__common_cflags} -march=armv4 -optflags: armv4t %{__common_cflags} -march=armv4t -optflags: armv5t %{__common_cflags} -march=armv5t -# Cortex A8 -optflags: armv7 %{__common_cflags} -march=armv7-a -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp - -optflags: armv4tl %{__common_cflags} -march=armv4t -optflags: armv5tl %{__common_cflags} -march=armv5t # Cortex A8 -optflags: armv7l %{__common_cflags} -march=armv7-a -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp +optflags: armv7 %{__common_cflags_with_ssp} -march=armv7-a -mfpu=neon -mtune=cortex-a8 -mabi=aapcs-linux -mfloat-abi=softfp +optflags: armv7l %{__common_cflags_with_ssp} -march=armv7-a -mfpu=neon -mtune=cortex-a8 -mabi=aapcs-linux -mfloat-abi=softfp -optflags: armv7hl %{__common_cflags} -march=armv7-a -mfloat-abi=hard -mfpu=vfpv3-d16 -optflags: armv7hnl %{__common_cflags} -march=armv7-a -mfloat-abi=hard -mfpu=neon +optflags: armv7hl %{__common_cflags_with_ssp} -march=armv7-a -mfpu=vfpv3-d16 -mtune=generic-armv7-a -mabi=aapcs-linux -mfloat-abi=hard +optflags: armv7hnl %{__common_cflags_with_ssp} -march=armv7-a -mfpu=neon -mabi=aapcs-linux -mfloat-abi=hard -optflags: aarch64 %{__common_cflags_with_ssp} -fasynchronous-unwind-tables - -optflags: atarist %{__common_cflags} -fomit-frame-pointer -optflags: atariste %{__common_cflags} -fomit-frame-pointer -optflags: ataritt %{__common_cflags} -fomit-frame-pointer -optflags: falcon %{__common_cflags} -fomit-frame-pointer -optflags: atariclone %{__common_cflags} -fomit-frame-pointer -optflags: milan %{__common_cflags} -fomit-frame-pointer -optflags: hades %{__common_cflags} -fomit-frame-pointer - -optflags: s390 %{__common_cflags_with_ssp} -optflags: s390x %{__common_cflags_with_ssp} +optflags: aarch64 %{__common_cflags_with_ssp} -mbranch-protection=standard -fasynchronous-unwind-tables -fstack-clash-protection ############################################################# # Canonical arch names and numbers -arch_canon: sparc64:sparc64 10 -arch_canon: sun4u: sparc64 10 - arch_canon: x86_64: x86_64 19 ############################################################# -# Canonical OS names and numbers - -############################################################# # For a given uname().machine, the default build arch -buildarchtranslate: athlon: i586 -buildarchtranslate: pentium4: i586 -buildarchtranslate: pentium3: i586 -buildarchtranslate: i686: i586 -buildarchtranslate: k6: i586 +buildarchtranslate: athlon: i686 +buildarchtranslate: geode: i686 +buildarchtranslate: pentium4: i686 +buildarchtranslate: pentium3: i686 +buildarchtranslate: i686: i686 buildarchtranslate: i586: i586 buildarchtranslate: i486: i486 buildarchtranslate: i386: i386 -buildarchtranslate: i386: i386 -buildarchtranslate: armv5tel: armv5tl -buildarchtranslate: armv5t: armv5t buildarchtranslate: armv7: armv5t buildarchtranslate: armv7l: @ARMV7CANONTARGETCPU@ buildarchtranslate: armv7hl: armv7hl buildarchtranslate: armv7hnl: armv7hl buildarchtranslate: armv8l: @ARMV8CANONTARGETCPU@ +buildarchtranslate: armv8hl: @ARMV8CANONTARGETCPU@ +buildarchtranslate: armv8hnl: @ARMV8CANONTARGETCPU@ +buildarchtranslate: armv8hcnl: @ARMV8CANONTARGETCPU@ ############################################################# # Architecture compatibility -arch_compat: k6: i586 - -arch_compat: osfmach3_i686: i686 osfmach3_i586 -arch_compat: osfmach3_i586: i586 osfmach3_i486 -arch_compat: osfmach3_i486: i486 osfmach3_i386 -arch_compat: osfmach3_i386: i486 - arch_compat: armv8l: armv7hl - -buildarch_compat: k6: i486 - -macrofiles: @RPMLIBDIR@/macros:@RPMLIBDIR@/%{_target}/macros:@RPMVENDORDIR@/macros:@RPMVENDORDIR@/%{_target}/macros:@RPMSYSCONFDIR@/macros:@RPMSYSCONFDIR@/%{_target}/macros:@RPMSYSCONFDIR@/macros.cdb:@RPMSYSCONFDIR@/macros.d/*.macros:~/.rpmmacros @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/sh allerrs=0 diff --git a/tests/macros.sh b/tests/macros.sh index 972ceca..44f0df9 100755 --- a/tests/macros.sh +++ b/tests/macros.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/sh RPMEVAL=./rpmeval |