From 87745c018b27d6fba5fe93a81594298d306cdda4 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Wed, 2 Nov 2011 13:29:07 +0100 Subject: [PATCH] Move removing static libs from QA to pakfire. --- po/pakfire.pot | 2 +- python/pakfire/builder.py | 13 ++++++++++ python/pakfire/constants.py | 1 + scripts/Makefile | 1 + .../quality-agent.d/001-remove-static-libs | 25 ------------------- scripts/remove-static-libs | 25 +++++++++++++++++++ 6 files changed, 41 insertions(+), 26 deletions(-) delete mode 100755 scripts/quality-agent.d/001-remove-static-libs create mode 100755 scripts/remove-static-libs diff --git a/po/pakfire.pot b/po/pakfire.pot index 3bd08653a..3e7eae62f 100644 --- a/po/pakfire.pot +++ b/po/pakfire.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-10-25 21:03+0200\n" +"POT-Creation-Date: 2011-11-02 11:14+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/python/pakfire/builder.py b/python/pakfire/builder.py index ea3928340..5769cd863 100644 --- a/python/pakfire/builder.py +++ b/python/pakfire/builder.py @@ -685,6 +685,9 @@ class Builder(object): for stage in ("prepare", "build", "test", "install"): self.build_stage(stage) + # Run post-build stuff. + self.post_remove_static_libs() + # Package the result. # Make all these little package from the build environment. logging.info(_("Creating packages:")) @@ -717,6 +720,16 @@ class Builder(object): if os.path.exists(buildscript): os.unlink(buildscript) + def post_remove_static_libs(self): + keep_libs = self.pkg.lexer.build.get_var("keep_libraries") + keep_libs = keep_libs.split() + + try: + self.do("%s/remove-static-libs %s %s" % \ + (SCRIPT_DIR, self.buildroot, " ".join(keep_libs))) + except Error, e: + logging.warning(_("Could not remove static libraries: %s") % e) + def cleanup(self): if os.path.exists(self.buildroot): util.rm(self.buildroot) diff --git a/python/pakfire/constants.py b/python/pakfire/constants.py index 3735418dc..76a9f0883 100644 --- a/python/pakfire/constants.py +++ b/python/pakfire/constants.py @@ -28,6 +28,7 @@ from __version__ import PAKFIRE_VERSION PAKFIRE_LEAST_COMPATIBLE_VERSION = PAKFIRE_VERSION SYSCONFDIR = "/etc" +SCRIPT_DIR = "/usr/lib/pakfire" CONFIG_DIR = os.path.join(SYSCONFDIR, "pakfire.repos.d") CONFIG_FILE = os.path.join(SYSCONFDIR, "pakfire.conf") diff --git a/scripts/Makefile b/scripts/Makefile index b67dabf09..665a3b7da 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -10,6 +10,7 @@ SCRIPTS_SHELL = \ pakfire-multicall.py \ py-compile \ quality-agent \ + remove-static-libs \ $(wildcard functions-*) \ $(wildcard *.prov) \ $(wildcard *.req) diff --git a/scripts/quality-agent.d/001-remove-static-libs b/scripts/quality-agent.d/001-remove-static-libs deleted file mode 100755 index 0356f638d..000000000 --- a/scripts/quality-agent.d/001-remove-static-libs +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -. $(dirname ${0})/qa-include - -DESC="Removing unwanted files: *.a *.la" - -function check() { - for file in $(find ${BUILDROOT} -name "*.a" -or -name "*.la"); do - - # Don't remove libc_nonshared.a. It is used by gcc/ld. - [ "${file##*/}" = "libc_nonshared.a" ] && continue - [ "${file##*/}" = "libpthread_nonshared.a" ] && continue - [ "${file##*/}" = "libgcc.a" ] && continue - [ "${file##*/}" = "libgcc_eh.a" ] && continue - [ "${file##*/}" = "libfl_pic.a" ] && continue - [ "${file##*/}" = "libpython2.6.a" ] && continue - [ "${file##*/}" = "libiberty.a" ] && continue - - log DEBUG " Removing: ${file}" - rm -f ${file} || exit $? - done -} - -run - diff --git a/scripts/remove-static-libs b/scripts/remove-static-libs new file mode 100755 index 000000000..3e37f708e --- /dev/null +++ b/scripts/remove-static-libs @@ -0,0 +1,25 @@ +#!/bin/bash + +echo "Removing unwanted static libraries..." + +BUILDROOT=${1} +shift + +for file in $(find ${BUILDROOT} -name "*.a" -or -name "*.la"); do + file=${file//${BUILDROOT}/} + + keep=0 + for skip in $@; do + if [ "${skip}" = "${file}" ]; then + keep=1 + break + fi + done + + if [ ${keep} -eq 0 ]; then + echo " Removing ${file}..." + rm -f ${BUILDROOT}/${file} + fi +done + +exit 0 -- 2.39.5