Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Makefile.am63
-rw-r--r--scripts/libmakepkg/.gitignore14
-rw-r--r--scripts/libmakepkg/lint_package.sh.in45
-rw-r--r--scripts/libmakepkg/lint_package/build_references.sh.in38
-rw-r--r--scripts/libmakepkg/lint_package/missing_backup.sh.in38
-rw-r--r--scripts/libmakepkg/tidy.sh.in52
-rw-r--r--scripts/libmakepkg/tidy/docs.sh.in37
-rw-r--r--scripts/libmakepkg/tidy/emptydirs.sh.in38
-rw-r--r--scripts/libmakepkg/tidy/libtool.sh.in38
-rw-r--r--scripts/libmakepkg/tidy/optipng.sh.in44
-rw-r--r--scripts/libmakepkg/tidy/purge.sh.in45
-rw-r--r--scripts/libmakepkg/tidy/staticlibs.sh.in43
-rw-r--r--scripts/libmakepkg/tidy/strip.sh.in117
-rw-r--r--scripts/libmakepkg/tidy/upx.sh.in46
-rw-r--r--scripts/libmakepkg/tidy/zipman.sh.in61
-rw-r--r--scripts/libmakepkg/util.sh.in28
-rw-r--r--scripts/libmakepkg/util/message.sh49
-rw-r--r--scripts/libmakepkg/util/option.sh108
-rwxr-xr-xscripts/makepkg-template.pl.in8
-rw-r--r--scripts/makepkg-wrapper.sh.in2
-rw-r--r--scripts/makepkg.sh.in327
-rw-r--r--scripts/pacman-db-upgrade.sh.in4
-rw-r--r--scripts/pacman-key.sh.in4
-rw-r--r--scripts/pacman-optimize.sh.in4
-rw-r--r--scripts/pkgdelta.sh.in2
-rw-r--r--scripts/po/POTFILES.in14
-rw-r--r--scripts/repo-add.sh.in67
27 files changed, 987 insertions, 349 deletions
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 4ef3ce0e..57468f93 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -28,7 +28,8 @@ EXTRA_DIST = \
pacman-optimize.sh.in \
pkgdelta.sh.in \
repo-add.sh.in \
- $(LIBRARY)
+ $(LIBRARY) \
+ $(LIBMAKEPKG_DIST)
LIBRARY = \
library/output_format.sh \
@@ -37,10 +38,39 @@ LIBRARY = \
library/size_to_human.sh \
library/term_colors.sh
-# Files that should be removed, but which Automake does not know.
-MOSTLYCLEANFILES = $(bin_SCRIPTS)
+libmakepkgdir = $(datarootdir)/makepkg
+
+LIBMAKEPKGDIRS = \
+ lint_package \
+ tidy \
+ util
+
+LIBMAKEPKG = \
+ libmakepkg/util/message.sh \
+ libmakepkg/util/option.sh
+
+LIBMAKEPKG_IN = \
+ libmakepkg/lint_package.sh \
+ libmakepkg/lint_package/build_references.sh \
+ libmakepkg/lint_package/missing_backup.sh \
+ libmakepkg/tidy.sh \
+ libmakepkg/tidy/docs.sh \
+ libmakepkg/tidy/emptydirs.sh \
+ libmakepkg/tidy/libtool.sh \
+ libmakepkg/tidy/optipng.sh \
+ libmakepkg/tidy/purge.sh \
+ libmakepkg/tidy/staticlibs.sh \
+ libmakepkg/tidy/strip.sh \
+ libmakepkg/tidy/upx.sh \
+ libmakepkg/tidy/zipman.sh \
+ libmakepkg/util.sh
+
+LIBMAKEPKG_DIST = \
+ $(LIBMAKEPKG) \
+ $(addsuffix .in, $(LIBMAKEPKG_IN))
-libmakepkgdir = $(libdir)/makepkg
+# Files that should be removed, but which Automake does not know.
+MOSTLYCLEANFILES = $(bin_SCRIPTS) $(LIBMAKEPKG_IN)
clean-local:
$(AM_V_at)$(RM) -r .lib
@@ -87,10 +117,18 @@ $(OURSCRIPTS): Makefile
$(AM_V_at)chmod +x,a-w $@
@$(BASH_SHELL) -O extglob -n $@
+$(LIBMAKEPKG_IN): %: %.in Makefile
+ $(AM_V_at)$(RM) $@
+ $(AM_V_at)$(MKDIR_P) $(dir $@)
+ $(AM_V_GEN)test -f $(srcdir)/$@.in && $(edit) $(srcdir)/$@.in >$@
+ $(AM_V_at)chmod a-w $@
+ @$(BASH_SHELL) -O extglob -n $@
+
makepkg: \
$(srcdir)/makepkg.sh.in \
$(srcdir)/makepkg-wrapper.sh.in \
- $(srcdir)/library/parseopts.sh
+ $(srcdir)/library/parseopts.sh \
+ $(LIBMAKEPKG_IN)
makepkg-template: \
$(srcdir)/makepkg-template.pl.in \
@@ -150,6 +188,15 @@ install-exec-hook:
cd $(DESTDIR)$(bindir) && \
$(RM) makepkg makepkg-wrapper
$(INSTALL) .lib/makepkg $(DESTDIR)$(bindir)/makepkg
+ for dir in $(LIBMAKEPKGDIRS); do \
+ $(MKDIR_P) $(DESTDIR)$(libmakepkgdir)/$$dir; \
+ done
+ for lib in $(LIBMAKEPKG); do \
+ $(INSTALL) $(srcdir)/$$lib $(DESTDIR)$(libmakepkgdir)/$${lib#libmakepkg}; \
+ done
+ for lib in $(LIBMAKEPKG_IN); do \
+ $(INSTALL) $$lib $(DESTDIR)$(libmakepkgdir)/$${lib#libmakepkg}; \
+ done
cd $(DESTDIR)$(bindir) && \
$(RM) repo-elephant && \
( $(LN_S) repo-add repo-elephant || \
@@ -164,5 +211,11 @@ install-exec-hook:
uninstall-hook:
cd $(DESTDIR)$(bindir) && \
$(RM) repo-remove repo-elephant
+ for lib in $(LIBMAKEPKG) $(LIBMAKEPKG_IN); do \
+ $(RM) $(DESTDIR)$(libmakepkgdir)/$${lib#libmakepkg}; \
+ done
+ for dir in $(LIBMAKEPKGDIRS); do \
+ $(RM) -r $(DESTDIR)$(libmakepkgdir)/$$dir; \
+ done
# vim:set noet:
diff --git a/scripts/libmakepkg/.gitignore b/scripts/libmakepkg/.gitignore
new file mode 100644
index 00000000..6101db46
--- /dev/null
+++ b/scripts/libmakepkg/.gitignore
@@ -0,0 +1,14 @@
+lint_package.sh
+lint_package/build_references.sh
+lint_package/missing_backup.sh
+tidy.sh
+tidy/docs.sh
+tidy/emptydirs.sh
+tidy/libtool.sh
+tidy/optipng.sh
+tidy/purge.sh
+tidy/staticlibs.sh
+tidy/strip.sh
+tidy/upx.sh
+tidy/zipman.sh
+util.sh
diff --git a/scripts/libmakepkg/lint_package.sh.in b/scripts/libmakepkg/lint_package.sh.in
new file mode 100644
index 00000000..e5e23bbd
--- /dev/null
+++ b/scripts/libmakepkg/lint_package.sh.in
@@ -0,0 +1,45 @@
+#!/bin/bash
+#
+# lint_package.sh - functions for checking for packaging errors
+#
+# Copyright (c) 2015 Pacman Development Team <pacman-dev@archlinux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+[ -n "$LIBMAKEPKG_LINT_PACKAGE_SH" ] && return
+LIBMAKEPKG_LINT_PACKAGE_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+
+
+declare -a lint_package_functions
+
+for lib in "$LIBRARY/lint_package/"*.sh; do
+ source "$lib"
+done
+
+readonly -a lint_package_functions
+
+
+lint_package() {
+ cd_safe "$pkgdir"
+ msg "$(gettext "Checking for packaging issue...")"
+
+ for func in ${lint_package_functions[@]}; do
+ $func
+ done
+}
diff --git a/scripts/libmakepkg/lint_package/build_references.sh.in b/scripts/libmakepkg/lint_package/build_references.sh.in
new file mode 100644
index 00000000..6b03e484
--- /dev/null
+++ b/scripts/libmakepkg/lint_package/build_references.sh.in
@@ -0,0 +1,38 @@
+#!/bin/bash
+#
+# build_references.sh - Warn about files containing references to build directories
+#
+# Copyright (c) 2013-2015 Pacman Development Team <pacman-dev@archlinux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+[ -n "$LIBMAKEPKG_LINT_PACKAGE_BUILD_REFERENCES_SH" ] && return
+LIBMAKEPKG_LINT_PACKAGE_BUILD_REFERENCES_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+
+
+lint_package_functions+=('warn_build_references')
+
+warn_build_references() {
+ if find "${pkgdir}" -type f -print0 | xargs -0 grep -q -I "${srcdir}" ; then
+ warning "$(gettext "Package contains reference to %s")" "\$srcdir"
+ fi
+ if find "${pkgdir}" -type f -print0 | xargs -0 grep -q -I "${pkgdirbase}" ; then
+ warning "$(gettext "Package contains reference to %s")" "\$pkgdir"
+ fi
+}
diff --git a/scripts/libmakepkg/lint_package/missing_backup.sh.in b/scripts/libmakepkg/lint_package/missing_backup.sh.in
new file mode 100644
index 00000000..64d5a64a
--- /dev/null
+++ b/scripts/libmakepkg/lint_package/missing_backup.sh.in
@@ -0,0 +1,38 @@
+#!/bin/bash
+#
+# missing_backup.sh - Warn about missing files in the backup array
+#
+# Copyright (c) 2013-2015 Pacman Development Team <pacman-dev@archlinux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+[ -n "$LIBMAKEPKG_LINT_PACKAGE_MISSING_BACKUP_SH" ] && return
+LIBMAKEPKG_LINT_PACKAGE_MISSING_BACKUP_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+
+
+lint_package_functions+=('warn_missing_backup')
+
+warn_missing_backup() {
+ local file
+ for file in "${backup[@]}"; do
+ if [[ ! -f $file ]]; then
+ warning "$(gettext "%s entry file not in package : %s")" "backup" "$file"
+ fi
+ done
+}
diff --git a/scripts/libmakepkg/tidy.sh.in b/scripts/libmakepkg/tidy.sh.in
new file mode 100644
index 00000000..1f439ba2
--- /dev/null
+++ b/scripts/libmakepkg/tidy.sh.in
@@ -0,0 +1,52 @@
+#!/bin/bash
+#
+# tidy.sh - functions for modifying/removing installed files before
+# package creation
+#
+# Copyright (c) 2015 Pacman Development Team <pacman-dev@archlinux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+[ -n "$LIBMAKEPKG_TIDY_SH" ] && return
+LIBMAKEPKG_TIDY_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+
+
+declare -a packaging_options tidy_remove tidy_modify
+
+for lib in "$LIBRARY/tidy/"*.sh; do
+ source "$lib"
+done
+
+readonly -a packaging_options tidy_remove tidy_modify
+
+
+tidy_install() {
+ cd_safe "$pkgdir"
+ msg "$(gettext "Tidying install...")"
+
+ # options that remove unwanted files
+ for func in ${tidy_remove[@]}; do
+ $func
+ done
+
+ # options that modify files
+ for func in ${tidy_modify[@]}; do
+ $func
+ done
+}
diff --git a/scripts/libmakepkg/tidy/docs.sh.in b/scripts/libmakepkg/tidy/docs.sh.in
new file mode 100644
index 00000000..a9791302
--- /dev/null
+++ b/scripts/libmakepkg/tidy/docs.sh.in
@@ -0,0 +1,37 @@
+#!/bin/bash
+#
+# docs.sh - Remove documentation files from the package
+#
+# Copyright (c) 2008-2015 Pacman Development Team <pacman-dev@archlinux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+[ -n "$LIBMAKEPKG_TIDY_DOCS_SH" ] && return
+LIBMAKEPKG_TIDY_DOCS_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/option.sh"
+
+packaging_options+=('docs')
+tidy_remove+=('tidy_docs')
+
+tidy_docs() {
+ if check_option "docs" "n" && [[ -n ${DOC_DIRS[*]} ]]; then
+ msg2 "$(gettext "Removing doc files...")"
+ rm -rf -- ${DOC_DIRS[@]}
+ fi
+}
diff --git a/scripts/libmakepkg/tidy/emptydirs.sh.in b/scripts/libmakepkg/tidy/emptydirs.sh.in
new file mode 100644
index 00000000..c7103e9e
--- /dev/null
+++ b/scripts/libmakepkg/tidy/emptydirs.sh.in
@@ -0,0 +1,38 @@
+#!/bin/bash
+#
+# emptydirs.sh - Remove empty directories from the package
+#
+# Copyright (c) 2013-2015 Pacman Development Team <pacman-dev@archlinux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+[ -n "$LIBMAKEPKG_TIDY_EMPTYDIRS_SH" ] && return
+LIBMAKEPKG_TIDY_EMPTYDIRS_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/option.sh"
+
+
+packaging_options+=('emptydirs')
+tidy_remove+=('tidy_emptydirs')
+
+tidy_emptydirs() {
+ if check_option "emptydirs" "n"; then
+ msg2 "$(gettext "Removing empty directories...")"
+ find . -depth -type d -exec rmdir '{}' + 2>/dev/null
+ fi
+}
diff --git a/scripts/libmakepkg/tidy/libtool.sh.in b/scripts/libmakepkg/tidy/libtool.sh.in
new file mode 100644
index 00000000..b9c62452
--- /dev/null
+++ b/scripts/libmakepkg/tidy/libtool.sh.in
@@ -0,0 +1,38 @@
+#!/bin/bash
+#
+# libtool.sh - Remove libtool files from the package
+#
+# Copyright (c) 2013-2015 Pacman Development Team <pacman-dev@archlinux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+[ -n "$LIBMAKEPKG_TIDY_LIBTOOL_SH" ] && return
+LIBMAKEPKG_TIDY_LIBTOOL_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/option.sh"
+
+
+packaging_options+=('libtool')
+tidy_remove+=('tidy_libtool')
+
+tidy_libtool() {
+ if check_option "libtool" "n"; then
+ msg2 "$(gettext "Removing "%s" files...")" "libtool"
+ find . ! -type d -name "*.la" -exec rm -f -- '{}' +
+ fi
+}
diff --git a/scripts/libmakepkg/tidy/optipng.sh.in b/scripts/libmakepkg/tidy/optipng.sh.in
new file mode 100644
index 00000000..f739a823
--- /dev/null
+++ b/scripts/libmakepkg/tidy/optipng.sh.in
@@ -0,0 +1,44 @@
+#!/bin/bash
+#
+# optipng.sh - Compress PNG files using optpng
+#
+# Copyright (c) 2015 Pacman Development Team <pacman-dev@archlinux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+[ -n "$LIBMAKEPKG_TIDY_OPTIPNG_SH" ] && return
+LIBMAKEPKG_TIDY_OPTIPNG_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/option.sh"
+
+
+packaging_options+=('optipng')
+tidy_modify+=('tidy_optipng')
+
+tidy_optipng() {
+ if check_option "optipng" "y"; then
+ msg2 "$(gettext "Optimizing PNG images...")"
+ local png
+ find . -type f -iname "*.png" 2>/dev/null | while read -r png ; do
+ if [[ $(file --brief --mime-type "$png") = 'image/png' ]]; then
+ optipng "${OPTIPNGFLAGS[@]}" "$png" &>/dev/null ||
+ warning "$(gettext "Could not optimize PNG image : %s")" "${png/$pkgdir\//}"
+ fi
+ done
+ fi
+}
diff --git a/scripts/libmakepkg/tidy/purge.sh.in b/scripts/libmakepkg/tidy/purge.sh.in
new file mode 100644
index 00000000..948f001d
--- /dev/null
+++ b/scripts/libmakepkg/tidy/purge.sh.in
@@ -0,0 +1,45 @@
+#!/bin/bash
+#
+# purge.sh - Remove unwanted files from the package
+#
+# Copyright (c) 2008-2015 Pacman Development Team <pacman-dev@archlinux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+[ -n "$LIBMAKEPKG_TIDY_PURGE_SH" ] && return
+LIBMAKEPKG_TIDY_PURGE_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/option.sh"
+
+
+packaging_options+=('purge')
+tidy_remove+=('tidy_purge')
+
+tidy_purge() {
+ if check_option "purge" "y" && [[ -n ${PURGE_TARGETS[*]} ]]; then
+ msg2 "$(gettext "Purging unwanted files...")"
+ local pt
+ for pt in "${PURGE_TARGETS[@]}"; do
+ if [[ ${pt} = "${pt//\/}" ]]; then
+ find . ! -type d -name "${pt}" -exec rm -f -- '{}' +
+ else
+ rm -f ${pt}
+ fi
+ done
+ fi
+}
diff --git a/scripts/libmakepkg/tidy/staticlibs.sh.in b/scripts/libmakepkg/tidy/staticlibs.sh.in
new file mode 100644
index 00000000..4849aba9
--- /dev/null
+++ b/scripts/libmakepkg/tidy/staticlibs.sh.in
@@ -0,0 +1,43 @@
+#!/bin/bash
+#
+# staticlibs.sh - Remove static library files from the package
+#
+# Copyright (c) 2013-2015 Pacman Development Team <pacman-dev@archlinux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+[ -n "$LIBMAKEPKG_TIDY_STATICLIBS_SH" ] && return
+LIBMAKEPKG_TIDY_STATICLIBS_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/option.sh"
+
+
+packaging_options+=('staticlibs')
+tidy_remove+=('tidy_staticlibs')
+
+tidy_staticlibs() {
+ if check_option "staticlibs" "n"; then
+ msg2 "$(gettext "Removing static library files...")"
+ local l
+ while read -rd '' l; do
+ if [[ -f "${l%.a}.so" || -h "${l%.a}.so" ]]; then
+ rm "$l"
+ fi
+ done < <(find . ! -type d -name "*.a" -print0)
+ fi
+}
diff --git a/scripts/libmakepkg/tidy/strip.sh.in b/scripts/libmakepkg/tidy/strip.sh.in
new file mode 100644
index 00000000..12a7eee3
--- /dev/null
+++ b/scripts/libmakepkg/tidy/strip.sh.in
@@ -0,0 +1,117 @@
+#!/bin/bash
+#
+# strip.sh - Strip debugging symbols from binary files
+#
+# Copyright (c) 2007-2015 Pacman Development Team <pacman-dev@archlinux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+[ -n "$LIBMAKEPKG_TIDY_STRIP_SH" ] && return
+LIBMAKEPKG_TIDY_STRIP_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/option.sh"
+
+
+packaging_options+=('strip' 'debug')
+tidy_modify+=('tidy_strip')
+
+
+build_id() {
+ LANG=C readelf -n $1 | sed -n '/Build ID/ { s/.*: //p; q; }'
+}
+
+strip_file() {
+ local binary=$1; shift
+
+ if check_option "debug" "y"; then
+ local bid=$(build_id "$binary")
+
+ # has this file already been stripped
+ if [[ -n "$bid" ]]; then
+ if [[ -f "$dbgdir/.build-id/${bid:0:2}/${bid:2}.debug" ]]; then
+ return
+ fi
+ elif [[ -f "$dbgdir/$binary.debug" ]]; then
+ return
+ fi
+
+ mkdir -p "$dbgdir/${binary%/*}"
+ objcopy --only-keep-debug "$binary" "$dbgdir/$binary.debug"
+ objcopy --add-gnu-debuglink="$dbgdir/${binary#/}.debug" "$binary"
+
+ # create any needed hardlinks
+ while read -rd '' file ; do
+ if [[ "${binary}" -ef "${file}" && ! -f "$dbgdir/${file}.debug" ]]; then
+ mkdir -p "$dbgdir/${file%/*}"
+ ln "$dbgdir/${binary}.debug" "$dbgdir/${file}.debug"
+ fi
+ done < <(find . -type f -perm -u+w -print0 2>/dev/null)
+
+ if [[ -n "$bid" ]]; then
+ local target
+ mkdir -p "$dbgdir/.build-id/${bid:0:2}"
+
+ target="../../../../../${binary#./}"
+ target="${target/..\/..\/usr\/lib\/}"
+ target="${target/..\/usr\/}"
+ ln -s "$target" "$dbgdir/.build-id/${bid:0:2}/${bid:2}"
+
+ target="../../${binary#./}.debug"
+ ln -s "$target" "$dbgdir/.build-id/${bid:0:2}/${bid:2}.debug"
+ fi
+ fi
+
+ strip $@ "$binary"
+}
+
+
+tidy_strip() {
+ if check_option "strip" "y"; then
+ msg2 "$(gettext "Stripping unneeded symbols from binaries and libraries...")"
+ # make sure library stripping variables are defined to prevent excess stripping
+ [[ -z ${STRIP_SHARED+x} ]] && STRIP_SHARED="-S"
+ [[ -z ${STRIP_STATIC+x} ]] && STRIP_STATIC="-S"
+
+ if check_option "debug" "y"; then
+ dbgdir="$pkgdir-@DEBUGSUFFIX@/usr/lib/debug"
+ mkdir -p "$dbgdir"
+ fi
+
+ local binary strip_flags
+ find . -type f -perm -u+w -print0 2>/dev/null | while read -rd '' binary ; do
+ case "$(file -bi "$binary")" in
+ *application/x-sharedlib*) # Libraries (.so)
+ strip_flags="$STRIP_SHARED";;
+ *application/x-archive*) # Libraries (.a)
+ strip_flags="$STRIP_STATIC";;
+ *application/x-object*)
+ case "$binary" in
+ *.ko) # Kernel module
+ strip_flags="$STRIP_SHARED";;
+ *)
+ continue;;
+ esac;;
+ *application/x-executable*) # Binaries
+ strip_flags="$STRIP_BINARIES";;
+ *)
+ continue ;;
+ esac
+ strip_file "$binary" ${strip_flags}
+ done
+ fi
+}
diff --git a/scripts/libmakepkg/tidy/upx.sh.in b/scripts/libmakepkg/tidy/upx.sh.in
new file mode 100644
index 00000000..49104658
--- /dev/null
+++ b/scripts/libmakepkg/tidy/upx.sh.in
@@ -0,0 +1,46 @@
+#!/bin/bash
+#
+# upx.sh - Compress package binaries with UPX
+#
+# Copyright (c) 2011-2015 Pacman Development Team <pacman-dev@archlinux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+[ -n "$LIBMAKEPKG_TIDY_UPX_SH" ] && return
+LIBMAKEPKG_TIDY_UPX_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/option.sh"
+
+
+packaging_options+=('upx')
+tidy_modify+=('tidy_upx')
+
+tidy_upx() {
+ if check_option "upx" "y"; then
+ msg2 "$(gettext "Compressing binaries with %s...")" "UPX"
+ local binary
+ find . -type f -perm -u+w 2>/dev/null | while read -r binary ; do
+ case "$(file --brief --mime-type "$binary")" in
+ 'application/x-executable' | 'application/x-dosexec')
+ upx "${UPXFLAGS[@]}" "$binary" &>/dev/null ||
+ warning "$(gettext "Could not compress binary : %s")" "${binary/$pkgdir\//}"
+ ;;
+ esac
+ done
+ fi
+}
diff --git a/scripts/libmakepkg/tidy/zipman.sh.in b/scripts/libmakepkg/tidy/zipman.sh.in
new file mode 100644
index 00000000..a08a60fa
--- /dev/null
+++ b/scripts/libmakepkg/tidy/zipman.sh.in
@@ -0,0 +1,61 @@
+#!/bin/bash
+#
+# zipman.sh - Compress man and info pages
+#
+# Copyright (c) 2011-2015 Pacman Development Team <pacman-dev@archlinux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+[ -n "$LIBMAKEPKG_TIDY_ZIPMAN_SH" ] && return
+LIBMAKEPKG_TIDY_ZIPMAN_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/option.sh"
+
+
+packaging_options+=('zipman')
+tidy_modify+=('tidy_zipman')
+
+tidy_zipman() {
+ if check_option "zipman" "y" && [[ -n ${MAN_DIRS[*]} ]]; then
+ msg2 "$(gettext "Compressing man and info pages...")"
+ local file files inode link
+ while read -rd ' ' inode; do
+ read file
+ find ${MAN_DIRS[@]} -type l 2>/dev/null |
+ while read -r link ; do
+ if [[ "${file}" -ef "${link}" ]] ; then
+ rm -f "$link" "${link}.gz"
+ if [[ ${file%/*} = ${link%/*} ]]; then
+ ln -s -- "${file##*/}.gz" "${link}.gz"
+ else
+ ln -s -- "/${file}.gz" "${link}.gz"
+ fi
+ fi
+ done
+ if [[ -z ${files[$inode]} ]]; then
+ files[$inode]=$file
+ gzip -9 -n -f "$file"
+ else
+ rm -f "$file"
+ ln "${files[$inode]}.gz" "${file}.gz"
+ chmod 644 "${file}.gz"
+ fi
+ done < <(find ${MAN_DIRS[@]} -type f \! -name "*.gz" \! -name "*.bz2" \
+ -exec @INODECMD@ '{}' + 2>/dev/null)
+ fi
+}
diff --git a/scripts/libmakepkg/util.sh.in b/scripts/libmakepkg/util.sh.in
new file mode 100644
index 00000000..86c76590
--- /dev/null
+++ b/scripts/libmakepkg/util.sh.in
@@ -0,0 +1,28 @@
+#!/bin/bash
+#
+# util.sh - utility functions for makepkg
+#
+# Copyright (c) 2015 Pacman Development Team <pacman-dev@archlinux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+[ -n "$LIBMAKEPKG_UTIL_SH" ] && return
+LIBMAKEPKG_UTIL_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+for lib in "$LIBRARY/util/"*.sh; do
+ source "$lib"
+done
diff --git a/scripts/libmakepkg/util/message.sh b/scripts/libmakepkg/util/message.sh
new file mode 100644
index 00000000..15208ef8
--- /dev/null
+++ b/scripts/libmakepkg/util/message.sh
@@ -0,0 +1,49 @@
+#!/bin/bash
+#
+# message.sh - functions for outputting messages in makepkg
+#
+# Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ] && return
+LIBMAKEPKG_UTIL_MESSAGE_SH=1
+
+
+plain() {
+ local mesg=$1; shift
+ printf "${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
+}
+
+msg() {
+ local mesg=$1; shift
+ printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
+}
+
+msg2() {
+ local mesg=$1; shift
+ printf "${BLUE} ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
+}
+
+warning() {
+ local mesg=$1; shift
+ printf "${YELLOW}==> $(gettext "WARNING:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
+}
+
+error() {
+ local mesg=$1; shift
+ printf "${RED}==> $(gettext "ERROR:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
+}
diff --git a/scripts/libmakepkg/util/option.sh b/scripts/libmakepkg/util/option.sh
new file mode 100644
index 00000000..fc649288
--- /dev/null
+++ b/scripts/libmakepkg/util/option.sh
@@ -0,0 +1,108 @@
+#!/bin/bash
+#
+# option.sh - functions to test if build/packaging options are enabled
+#
+# Copyright (c) 2009-2015 Pacman Development Team <pacman-dev@archlinux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+[ -n "$LIBMAKEPKG_UTIL_OPTION_SH" ] && return
+LIBMAKEPKG_UTIL_OPTION_SH=1
+
+
+##
+# usage : in_opt_array( $needle, $haystack )
+# return : 0 - enabled
+# 1 - disabled
+# 127 - not found
+##
+in_opt_array() {
+ local needle=$1; shift
+
+ local i opt
+ for (( i = $#; i > 0; i-- )); do
+ opt=${!i}
+ if [[ $opt = "$needle" ]]; then
+ # enabled
+ return 0
+ elif [[ $opt = "!$needle" ]]; then
+ # disabled
+ return 1
+ fi
+ done
+
+ # not found
+ return 127
+}
+
+
+##
+# Checks to see if options are present in makepkg.conf or PKGBUILD;
+# PKGBUILD options always take precedence.
+#
+# usage : check_option( $option, $expected_val )
+# return : 0 - matches expected
+# 1 - does not match expected
+# 127 - not found
+##
+check_option() {
+ in_opt_array "$1" ${options[@]}
+ case $? in
+ 0) # assert enabled
+ [[ $2 = y ]]
+ return ;;
+ 1) # assert disabled
+ [[ $2 = n ]]
+ return
+ esac
+
+ # fall back to makepkg.conf options
+ in_opt_array "$1" ${OPTIONS[@]}
+ case $? in
+ 0) # assert enabled
+ [[ $2 = y ]]
+ return ;;
+ 1) # assert disabled
+ [[ $2 = n ]]
+ return
+ esac
+
+ # not found
+ return 127
+}
+
+
+##
+# Check if option is present in BUILDENV
+#
+# usage : check_buildenv( $option, $expected_val )
+# return : 0 - matches expected
+# 1 - does not match expected
+# 127 - not found
+##
+check_buildenv() {
+ in_opt_array "$1" ${BUILDENV[@]}
+ case $? in
+ 0) # assert enabled
+ [[ $2 = "y" ]]
+ return ;;
+ 1) # assert disabled
+ [[ $2 = "n" ]]
+ return ;;
+ esac
+
+ # not found
+ return 127
+}
diff --git a/scripts/makepkg-template.pl.in b/scripts/makepkg-template.pl.in
index d9da1674..71d2aae2 100755
--- a/scripts/makepkg-template.pl.in
+++ b/scripts/makepkg-template.pl.in
@@ -2,7 +2,7 @@
# makepkg-template - template system for makepkg
# @configure_input@
#
-# Copyright (c) 2013-2014 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2013-2015 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -109,7 +109,7 @@ sub load_template {
my ($version) = (abs_path($path) =~ /-([0-9.]+)[.]template$/);
if (!$version) {
- die sprintf(gettext("Couldn't detect version for template '%s'"), $values->{name});
+ die sprintf(gettext("Couldn't detect version for template '%s'\n"), $values->{name});
}
my $parsed = process_file($path);
@@ -128,7 +128,7 @@ sub process_file {
my $nesting_level = 0;
my $linenumber = 0;
- open (my $fh, "<", $filename) or die sprintf(gettext("failed to open '%s': %s"), $filename, $!);
+ open (my $fh, "<", $filename) or die sprintf(gettext("failed to open '%s': %s\n"), $filename, $!);
my @lines = <$fh>;
close $fh;
@@ -186,7 +186,7 @@ sub version {
my ($exitstatus) = @_;
printf "makepkg-template (pacman) %s\n", '@PACKAGE_VERSION@';
print gettext(
- 'Copyright (c) 2013-2014 Pacman Development Team <pacman-dev@archlinux.org>.'."\n".
+ 'Copyright (c) 2013-2015 Pacman Development Team <pacman-dev@archlinux.org>.'."\n".
'This is free software; see the source for copying conditions.'."\n".
'There is NO WARRANTY, to the extent permitted by law.'."\n");
exit($exitstatus);
diff --git a/scripts/makepkg-wrapper.sh.in b/scripts/makepkg-wrapper.sh.in
index fd83a01f..400db40f 100644
--- a/scripts/makepkg-wrapper.sh.in
+++ b/scripts/makepkg-wrapper.sh.in
@@ -2,7 +2,7 @@
#
# makepkg - a wrapper for running the real makepkg in the source tree
#
-# Copyright (c) 2013-2014 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2013-2015 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 227563ce..acee796e 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -3,7 +3,7 @@
# makepkg - make packages compatible for use with pacman
# @configure_input@
#
-# Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
# Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
# Copyright (c) 2006 by Miklos Vajna <vmiklos@frugalware.org>
@@ -48,13 +48,11 @@ declare -r startdir="$PWD"
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
-packaging_options=('strip' 'docs' 'libtool' 'staticlibs' 'emptydirs' 'zipman'
- 'purge' 'upx' 'debug')
-other_options=('ccache' 'distcc' 'buildflags' 'makeflags')
+build_options=('ccache' 'distcc' 'buildflags' 'makeflags')
splitpkg_overrides=('pkgdesc' 'arch' 'url' 'license' 'groups' 'depends'
'optdepends' 'provides' 'conflicts' 'replaces' 'backup'
'options' 'install' 'changelog')
-readonly -a packaging_options other_options splitpkg_overrides
+readonly -a build_options splitpkg_overrides
known_hash_algos=('md5' 'sha1' 'sha224' 'sha256' 'sha384' 'sha512')
@@ -100,31 +98,10 @@ shopt -s extglob
### SUBROUTINES ###
-plain() {
- local mesg=$1; shift
- printf "${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
-}
-
-msg() {
- local mesg=$1; shift
- printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
-}
-
-msg2() {
- local mesg=$1; shift
- printf "${BLUE} ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
-}
-
-warning() {
- local mesg=$1; shift
- printf "${YELLOW}==> $(gettext "WARNING:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
-}
-
-error() {
- local mesg=$1; shift
- printf "${RED}==> $(gettext "ERROR:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
-}
-
+# Import libmakepkg
+for lib in "$LIBRARY"/*.sh; do
+ source "$lib"
+done
##
# Special exit call for traps, Don't print any error messages when inside,
@@ -913,92 +890,6 @@ get_pkg_arch() {
}
##
-# Checks to see if options are present in makepkg.conf or PKGBUILD;
-# PKGBUILD options always take precedence.
-#
-# usage : check_option( $option, $expected_val )
-# return : 0 - matches expected
-# 1 - does not match expected
-# 127 - not found
-##
-check_option() {
- in_opt_array "$1" ${options[@]}
- case $? in
- 0) # assert enabled
- [[ $2 = y ]]
- return ;;
- 1) # assert disabled
- [[ $2 = n ]]
- return
- esac
-
- # fall back to makepkg.conf options
- in_opt_array "$1" ${OPTIONS[@]}
- case $? in
- 0) # assert enabled
- [[ $2 = y ]]
- return ;;
- 1) # assert disabled
- [[ $2 = n ]]
- return
- esac
-
- # not found
- return 127
-}
-
-
-##
-# Check if option is present in BUILDENV
-#
-# usage : check_buildenv( $option, $expected_val )
-# return : 0 - matches expected
-# 1 - does not match expected
-# 127 - not found
-##
-check_buildenv() {
- in_opt_array "$1" ${BUILDENV[@]}
- case $? in
- 0) # assert enabled
- [[ $2 = "y" ]]
- return ;;
- 1) # assert disabled
- [[ $2 = "n" ]]
- return ;;
- esac
-
- # not found
- return 127
-}
-
-
-##
-# usage : in_opt_array( $needle, $haystack )
-# return : 0 - enabled
-# 1 - disabled
-# 127 - not found
-##
-in_opt_array() {
- local needle=$1; shift
-
- local i opt
- for (( i = $#; i > 0; i-- )); do
- opt=${!i}
- if [[ $opt = "$needle" ]]; then
- # enabled
- return 0
- elif [[ $opt = "!$needle" ]]; then
- # disabled
- return 1
- fi
- done
-
- # not found
- return 127
-}
-
-
-##
# usage : in_array( $needle, $haystack )
# return : 0 - found
# 1 - not found
@@ -1267,22 +1158,23 @@ verify_integrity_one() {
}
verify_integrity_sums() {
- local integ=$1 arch=$2 integrity_sums=() sources=()
+ local integ=$1 arch=$2 integrity_sums=() sources=() srcname
if [[ $arch ]]; then
array_build integrity_sums "${integ}sums_$arch"
- array_build sources "source_$arch"
+ srcname=source_$arch
else
array_build integrity_sums "${integ}sums"
- array_build sources source
+ srcname=source
fi
+ array_build sources "$srcname"
if (( ${#integrity_sums[@]} == 0 && ${#sources[@]} == 0 )); then
return 1
fi
if (( ${#integrity_sums[@]} == ${#sources[@]} )); then
- msg "$(gettext "Validating source files with %s...")" "${integ}sums"
+ msg "$(gettext "Validating %s files with %s...")" "$srcname" "${integ}sums"
local idx errors=0
for (( idx = 0; idx < ${#sources[*]}; idx++ )); do
verify_integrity_one "${sources[idx]}" "$integ" "${integrity_sums[idx]}" || errors=1
@@ -1335,7 +1227,7 @@ check_checksums() {
done
if (( ${#correlation[*]} )); then
- error "$(gettext "Integrity checks are missing.")"
+ error "$(gettext "Integrity checks are missing for: %s")" "${!correlation[*]}"
exit 1 # TODO: error code
fi
}
@@ -1723,185 +1615,6 @@ run_package() {
run_function_safe "$pkgfunc"
}
-build_id() {
- LANG=C readelf -n $1 | sed -n '/Build ID/ { s/.*: //p; q; }'
-}
-
-strip_file() {
- local binary=$1; shift
-
- if check_option "debug" "y"; then
- local bid=$(build_id "$binary")
-
- # has this file already been stripped
- if [[ -n "$bid" ]]; then
- if [[ -f "$dbgdir/.build-id/${bid:0:2}/${bid:2}.debug" ]]; then
- return
- fi
- elif [[ -f "$dbgdir/$binary.debug" ]]; then
- return
- fi
-
- mkdir -p "$dbgdir/${binary%/*}"
- objcopy --only-keep-debug "$binary" "$dbgdir/$binary.debug"
- objcopy --add-gnu-debuglink="$dbgdir/${binary#/}.debug" "$binary"
-
- # create any needed hardlinks
- while read -rd '' file ; do
- if [[ "${binary}" -ef "${file}" && ! -f "$dbgdir/${file}.debug" ]]; then
- mkdir -p "$dbgdir/${file%/*}"
- ln "$dbgdir/${binary}.debug" "$dbgdir/${file}.debug"
- fi
- done < <(find . -type f -perm -u+w -print0 2>/dev/null)
-
- if [[ -n "$bid" ]]; then
- local target
- mkdir -p "$dbgdir/.build-id/${bid:0:2}"
-
- target="../../../../../${binary#./}"
- target="${target/..\/..\/usr\/lib\/}"
- target="${target/..\/usr\/}"
- ln -s "$target" "$dbgdir/.build-id/${bid:0:2}/${bid:2}"
-
- target="../../${binary#./}.debug"
- ln -s "$target" "$dbgdir/.build-id/${bid:0:2}/${bid:2}.debug"
- fi
- fi
-
- strip $@ "$binary"
-}
-
-tidy_install() {
- cd_safe "$pkgdir"
- msg "$(gettext "Tidying install...")"
-
- if check_option "docs" "n" && [[ -n ${DOC_DIRS[*]} ]]; then
- msg2 "$(gettext "Removing doc files...")"
- rm -rf -- ${DOC_DIRS[@]}
- fi
-
- if check_option "purge" "y" && [[ -n ${PURGE_TARGETS[*]} ]]; then
- msg2 "$(gettext "Purging unwanted files...")"
- local pt
- for pt in "${PURGE_TARGETS[@]}"; do
- if [[ ${pt} = "${pt//\/}" ]]; then
- find . ! -type d -name "${pt}" -exec rm -f -- '{}' +
- else
- rm -f ${pt}
- fi
- done
- fi
-
- if check_option "libtool" "n"; then
- msg2 "$(gettext "Removing "%s" files...")" "libtool"
- find . ! -type d -name "*.la" -exec rm -f -- '{}' +
- fi
-
- if check_option "staticlibs" "n"; then
- msg2 "$(gettext "Removing static library files...")"
- local l
- while read -rd '' l; do
- if [[ -f "${l%.a}.so" || -h "${l%.a}.so" ]]; then
- rm "$l"
- fi
- done < <(find . ! -type d -name "*.a" -print0)
- fi
-
- if check_option "emptydirs" "n"; then
- msg2 "$(gettext "Removing empty directories...")"
- find . -depth -type d -exec rmdir '{}' + 2>/dev/null
- fi
-
- # check existence of backup files
- local file
- for file in "${backup[@]}"; do
- if [[ ! -f $file ]]; then
- warning "$(gettext "%s entry file not in package : %s")" "backup" "$file"
- fi
- done
-
- # check for references to the build and package directory
- if find "${pkgdir}" -type f -print0 | xargs -0 grep -q -I "${srcdir}" ; then
- warning "$(gettext "Package contains reference to %s")" "\$srcdir"
- fi
- if find "${pkgdir}" -type f -print0 | xargs -0 grep -q -I "${pkgdirbase}" ; then
- warning "$(gettext "Package contains reference to %s")" "\$pkgdir"
- fi
-
- if check_option "zipman" "y" && [[ -n ${MAN_DIRS[*]} ]]; then
- msg2 "$(gettext "Compressing man and info pages...")"
- local file files inode link
- while read -rd ' ' inode; do
- read file
- find ${MAN_DIRS[@]} -type l 2>/dev/null |
- while read -r link ; do
- if [[ "${file}" -ef "${link}" ]] ; then
- rm -f "$link" "${link}.gz"
- if [[ ${file%/*} = ${link%/*} ]]; then
- ln -s -- "${file##*/}.gz" "${link}.gz"
- else
- ln -s -- "/${file}.gz" "${link}.gz"
- fi
- fi
- done
- if [[ -z ${files[$inode]} ]]; then
- files[$inode]=$file
- gzip -9 -n -f "$file"
- else
- rm -f "$file"
- ln "${files[$inode]}.gz" "${file}.gz"
- chmod 644 "${file}.gz"
- fi
- done < <(find ${MAN_DIRS[@]} -type f \! -name "*.gz" \! -name "*.bz2" \
- -exec @INODECMD@ '{}' + 2>/dev/null)
- fi
-
- if check_option "strip" "y"; then
- msg2 "$(gettext "Stripping unneeded symbols from binaries and libraries...")"
- # make sure library stripping variables are defined to prevent excess stripping
- [[ -z ${STRIP_SHARED+x} ]] && STRIP_SHARED="-S"
- [[ -z ${STRIP_STATIC+x} ]] && STRIP_STATIC="-S"
-
- if check_option "debug" "y"; then
- dbgdir="$pkgdir-@DEBUGSUFFIX@/usr/lib/debug"
- mkdir -p "$dbgdir"
- fi
-
- local binary strip_flags
- find . -type f -perm -u+w -print0 2>/dev/null | while read -rd '' binary ; do
- case "$(file -bi "$binary")" in
- *application/x-sharedlib*) # Libraries (.so)
- strip_flags="$STRIP_SHARED";;
- *application/x-archive*) # Libraries (.a)
- strip_flags="$STRIP_STATIC";;
- *application/x-object*)
- case "$binary" in
- *.ko) # Kernel module
- strip_flags="$STRIP_SHARED";;
- *)
- continue;;
- esac;;
- *application/x-executable*) # Binaries
- strip_flags="$STRIP_BINARIES";;
- *)
- continue ;;
- esac
- strip_file "$binary" ${strip_flags}
- done
- fi
-
- if check_option "upx" "y"; then
- msg2 "$(gettext "Compressing binaries with %s...")" "UPX"
- local binary
- find . -type f -perm -u+w 2>/dev/null | while read -r binary ; do
- if [[ $(file -bi "$binary") = *'application/x-executable'* ]]; then
- upx $UPXFLAGS "$binary" &>/dev/null ||
- warning "$(gettext "Could not compress binary : %s")" "${binary/$pkgdir\//}"
- fi
- done
- fi
-}
-
find_libdepends() {
local d sodepends;
@@ -2754,7 +2467,7 @@ lint_options() {
for i in "${options_list[@]}"; do
# check if option matches a known option or its inverse
- for kopt in "${packaging_options[@]}" "${other_options[@]}"; do
+ for kopt in "${packaging_options[@]}" "${build_options[@]}"; do
if [[ $i = "$kopt" || $i = "!$kopt" ]]; then
# continue to the next $i
continue 2
@@ -2990,6 +2703,14 @@ check_software() {
fi
fi
+ # optipng - PNG image optimization
+ if check_option "optipng" "y"; then
+ if ! type -p optipng >/dev/null; then
+ error "$(gettext "Cannot find the %s binary required for optimizing PNG images.")" "optipng"
+ ret=1
+ fi
+ fi
+
# distcc - compilation with distcc
if check_buildenv "distcc" "y" && ! check_option "distcc" "n"; then
if ! type -p distcc >/dev/null; then
@@ -3105,6 +2826,7 @@ run_split_packaging() {
backup_package_variables
run_package $pkgname
tidy_install
+ lint_package
create_package
create_debug_package
restore_package_variables
@@ -3192,7 +2914,7 @@ usage() {
version() {
printf "makepkg (pacman) %s\n" "$makepkg_version"
printf -- "$(gettext "\
-Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>.\n\
+Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>.\n\
Copyright (C) 2002-2006 Judd Vinet <jvinet@zeroflux.org>.\n\n\
This is free software; see the source for copying conditions.\n\
There is NO WARRANTY, to the extent permitted by law.\n")"
@@ -3562,6 +3284,7 @@ if (( INFAKEROOT )); then
run_package
fi
tidy_install
+ lint_package
create_package
create_debug_package
else
diff --git a/scripts/pacman-db-upgrade.sh.in b/scripts/pacman-db-upgrade.sh.in
index 7d01bce9..a8beb808 100644
--- a/scripts/pacman-db-upgrade.sh.in
+++ b/scripts/pacman-db-upgrade.sh.in
@@ -3,7 +3,7 @@
# pacman-db-upgrade - upgrade the local pacman db to a newer format
# @configure_input@
#
-# Copyright (c) 2010-2014 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2010-2015 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -52,7 +52,7 @@ usage() {
version() {
printf "pacman-db-upgrade (pacman) %s\n" "$myver"
printf -- "$(gettext "\
-Copyright (c) 2010-2014 Pacman Development Team <pacman-dev@archlinux.org>.\n\
+Copyright (c) 2010-2015 Pacman Development Team <pacman-dev@archlinux.org>.\n\
This is free software; see the source for copying conditions.\n\
There is NO WARRANTY, to the extent permitted by law.\n")"
}
diff --git a/scripts/pacman-key.sh.in b/scripts/pacman-key.sh.in
index 5ba0ad8f..82328515 100644
--- a/scripts/pacman-key.sh.in
+++ b/scripts/pacman-key.sh.in
@@ -4,7 +4,7 @@
# Based on apt-key, from Debian
# @configure_input@
#
-# Copyright (c) 2010-2014 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2010-2015 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -92,7 +92,7 @@ usage() {
version() {
printf "pacman-key (pacman) %s\n" "${myver}"
printf -- "$(gettext "\
-Copyright (c) 2010-2014 Pacman Development Team <pacman-dev@archlinux.org>.\n\
+Copyright (c) 2010-2015 Pacman Development Team <pacman-dev@archlinux.org>.\n\
This is free software; see the source for copying conditions.\n\
There is NO WARRANTY, to the extent permitted by law.\n")"
}
diff --git a/scripts/pacman-optimize.sh.in b/scripts/pacman-optimize.sh.in
index 7c809193..3e038fb3 100644
--- a/scripts/pacman-optimize.sh.in
+++ b/scripts/pacman-optimize.sh.in
@@ -3,7 +3,7 @@
# pacman-optimize
# @configure_input@
#
-# Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
#
# This program is free software; you can redistribute it and/or modify
@@ -51,7 +51,7 @@ does not have to move around the disk as much.\n")"
version() {
printf "pacman-optimize (pacman) %s\n" "$myver"
printf -- "$(gettext "\
-Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>.\n\
+Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>.\n\
Copyright (C) 2002-2006 Judd Vinet <jvinet@zeroflux.org>.\n\n\
This is free software; see the source for copying conditions.\n\
There is NO WARRANTY, to the extent permitted by law.\n")"
diff --git a/scripts/pkgdelta.sh.in b/scripts/pkgdelta.sh.in
index be49326e..fe63974d 100644
--- a/scripts/pkgdelta.sh.in
+++ b/scripts/pkgdelta.sh.in
@@ -140,7 +140,7 @@ create_xdelta()
deltafile=$(dirname "$newfile")/$pkgname-${oldver}_to_${newver}-$arch.delta
local ret=0
- xdelta3 -q -f -s "$oldfile" "$newfile" "$deltafile" || ret=$?
+ xdelta3 -q -f -9 -S lzma -s "$oldfile" "$newfile" "$deltafile" || ret=$?
if (( ret )); then
error "$(gettext "Delta could not be created.")"
return 1
diff --git a/scripts/po/POTFILES.in b/scripts/po/POTFILES.in
index f9e8a481..b25e53b6 100644
--- a/scripts/po/POTFILES.in
+++ b/scripts/po/POTFILES.in
@@ -8,5 +8,19 @@ scripts/pacman-key.sh.in
scripts/pacman-optimize.sh.in
scripts/pkgdelta.sh.in
scripts/repo-add.sh.in
+scripts/libmakepkg/lint_package.sh.in
+scripts/libmakepkg/lint_package/build_references.sh.in
+scripts/libmakepkg/lint_package/missing_backup.sh.in
+scripts/libmakepkg/tidy.sh.in
+scripts/libmakepkg/tidy/docs.sh.in
+scripts/libmakepkg/tidy/emptydirs.sh.in
+scripts/libmakepkg/tidy/libtool.sh.in
+scripts/libmakepkg/tidy/optipng.sh.in
+scripts/libmakepkg/tidy/purge.sh.in
+scripts/libmakepkg/tidy/staticlibs.sh.in
+scripts/libmakepkg/tidy/strip.sh.in
+scripts/libmakepkg/tidy/upx.sh.in
+scripts/libmakepkg/tidy/zipman.sh.in
+scripts/libmakepkg/util/message.sh
scripts/library/output_format.sh
scripts/library/parseopts.sh
diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in
index 4325dbfb..bf374443 100644
--- a/scripts/repo-add.sh.in
+++ b/scripts/repo-add.sh.in
@@ -4,7 +4,7 @@
# repo-remove - remove a package entry from a given repo database file
# @configure_input@
#
-# Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -34,6 +34,7 @@ ONLYADDNEW=0
RMEXISTING=0
WITHFILES=0
SIGN=0
+KEY=0
VERIFY=0
REPO_DB_FILE=
LOCKFILE=
@@ -59,7 +60,7 @@ Multiple packages to add can be specified on the command line.\n")"
printf -- "$(gettext "Options:\n")"
printf -- "$(gettext " -d, --delta generate and add delta for package update\n")"
printf -- "$(gettext " -n, --new only add packages that are not already in the database\n")"
- printf -- "$(gettext " -R, --remove remove package file from disk when updating database entry\n")"
+ printf -- "$(gettext " -R, --remove remove old package file from disk after updating database\n")"
printf -- "$(gettext " -f, --files update database's file list\n")"
elif [[ $cmd == "repo-remove" ]] ; then
printf -- "$(gettext "Usage: repo-remove [options] <path-to-db> <packagename|delta> ...\n")"
@@ -93,7 +94,7 @@ version() {
cmd=${0##*/}
printf "%s (pacman) %s\n\n" "$cmd" "$myver"
printf -- "$(gettext "\
-Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>\n\n\
+Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>\n\n\
This is free software; see the source for copying conditions.\n\
There is NO WARRANTY, to the extent permitted by law.\n")"
}
@@ -198,6 +199,17 @@ check_gpg() {
error "$(gettext "Cannot find the gpg binary! Is GnuPG installed?")"
exit 1 # $E_MISSING_PROGRAM
fi
+
+ if (( ! VERIFY )); then
+ if ! gpg --list-key ${GPGKEY} &>/dev/null; then
+ if [[ ! -z $GPGKEY ]]; then
+ error "$(gettext "The key ${GPGKEY} does not exist in your keyring.")"
+ elif (( ! KEY )); then
+ error "$(gettext "There is no key in your keyring.")"
+ fi
+ exit 1
+ fi
+ fi
}
# sign the package database once repackaged
@@ -249,7 +261,7 @@ verify_repo_extension() {
*.@(db|files).tar.xz) TAR_OPT="J" ;;
*.@(db|files).tar.Z) TAR_OPT="Z" ;;
*.@(db|files).tar) TAR_OPT="" ;;
- *) error "$(gettext "'%s' does not have a valid archive extension.")" \
+ *) error "$(gettext "'%s' does not have a valid database archive extension.")" \
"$repofile"
exit 1 ;;
esac
@@ -306,14 +318,13 @@ db_write_entry() {
local oldfilename=$(grep -A1 FILENAME "$pkgentry/desc" | tail -n1)
local oldfile="$(dirname "$1")/$oldfilename"
fi
- elif (( RMEXISTING )); then
- # only remove existing package if we're not doing deltas
+ fi
+ if (( RMEXISTING )); then
+ # gather information needed to remove old file
pkgentry=$(find_pkgentry "$pkgname")
if [[ -n $pkgentry ]]; then
local oldfilename="$(sed -n '/^%FILENAME%$/ {n;p;q;}' "$pkgentry/desc")"
local oldfile="$(dirname "$1")/$oldfilename"
- msg2 "$(gettext "Removing existing package '%s'")" "$oldfilename"
- rm -f ${oldfile} ${oldfile}.sig
fi
fi
fi
@@ -412,6 +423,11 @@ db_write_entry() {
fi
fi
+ if (( RMEXISTING )); then
+ msg2 "$(gettext "Removing old package file '%s'")" "$oldfilename"
+ rm -f ${oldfile} ${oldfile}.sig
+ fi
+
return 0
} # end db_write_entry
@@ -532,7 +548,7 @@ add() {
}
remove() {
- if [[ ${1##*.} == "delta" ]]; then
+ if [[ $1 = *-*-*_to_*-*-*.delta ]]; then
deltafile=$1
msg "$(gettext "Searching for delta '%s'...")" "$deltafile"
if db_remove_delta "$deltafile"; then
@@ -626,28 +642,14 @@ while (( $# )); do
-f|--files) WITHFILES=1;;
--nocolor) USE_COLOR='n';;
-s|--sign)
- check_gpg
SIGN=1
- if ! gpg --list-key ${GPGKEY} &>/dev/null; then
- if [[ ! -z $GPGKEY ]]; then
- error "$(gettext "The key ${GPGKEY} does not exist in your keyring.")"
- else
- error "$(gettext "There is no key in your keyring.")"
- fi
- exit 1
- fi
;;
-k|--key)
- check_gpg
+ KEY=1
shift
GPGKEY=$1
- if ! gpg --list-key ${GPGKEY} &>/dev/null; then
- error "$(gettext "The key ${GPGKEY} does not exist in your keyring.")"
- exit 1
- fi
;;
-v|--verify)
- check_gpg
VERIFY=1
;;
*)
@@ -674,6 +676,10 @@ fi
verify_repo_extension "$REPO_DB_FILE" >/dev/null
check_repo_db
+if (( SIGN || KEY || VERIFY )); then
+ check_gpg
+fi
+
for arg in "${args[@]:1}"; do
case $cmd in
repo-add) add "$arg" ;;
@@ -709,12 +715,13 @@ if (( success )); then
if [[ -f $REPO_DB_FILE ]]; then
ln -f "$REPO_DB_FILE" "$REPO_DB_FILE.old" 2>/dev/null || \
mv -f "$REPO_DB_FILE" "$REPO_DB_FILE.old"
- fi
- if [[ -f $REPO_DB_FILE.sig ]]; then
- ln -f "$REPO_DB_FILE.sig" "$REPO_DB_FILE.old.sig" 2>/dev/null || \
- mv -f "$REPO_DB_FILE.sig" "$REPO_DB_FILE.old.sig"
- else
- rm -f "$REPO_DB_FILE.old.sig"
+
+ if [[ -f $REPO_DB_FILE.sig ]]; then
+ ln -f "$REPO_DB_FILE.sig" "$REPO_DB_FILE.old.sig" 2>/dev/null || \
+ mv -f "$REPO_DB_FILE.sig" "$REPO_DB_FILE.old.sig"
+ else
+ rm -f "$REPO_DB_FILE.old.sig"
+ fi
fi
# rotate the newly-created database and signature into place