From 32c16657685bbce7f8a3db34692dba2145417be8 Mon Sep 17 00:00:00 2001 From: emmett1 Date: Sat, 14 Oct 2017 00:33:05 +0800 Subject: [PATCH] updated --- buildpkg | 130 ++++++++++++++++++++++++++++++++++-------------- functions | 1 + scratchpkg.conf | 10 ++-- 3 files changed, 100 insertions(+), 41 deletions(-) diff --git a/buildpkg b/buildpkg index 87e5989..e8690c0 100755 --- a/buildpkg +++ b/buildpkg @@ -191,6 +191,10 @@ loadspkgbuild() { if [ -f $BUILD_SCRIPT ]; then getpkginfo + if [ "${#options[@]}" -gt 0 ]; then + OPTIONS=($(echo ${options[@]})) + getoptions + fi else msgerr "No $BUILD_SCRIPT found." exitscript1 @@ -231,16 +235,36 @@ packaging() { pushd $PKG - if [ -f usr/share/info/dir ]; then - rm usr/share/info/dir + #if [ -f usr/share/info/dir ]; then + #rm usr/share/info/dir + #fi + + if [ "$REMOVE_EMPTYDIRS" ]; then + removeemptydirs fi - if [ ! "$NO_STRIP" ]; then + if [ "$REMOVE_DOCS" ]; then + removedocs + fi + + if [ "$PURGE_FILES" ]; then + purgefiles + fi + + if [ "$REMOVE_LIBTOOL" ]; then + removelibtool + fi + + if [ "$STRIP_PKG" ]; then strip_files fi - compressinfomanpages - purgefiles + if [ "$COMPRESS_MAN" ]; then + compressinfomanpages + fi + + #compressinfomanpages + #purgefiles echo "# Generated by buildpkg" > .pkginfo echo "# `date`" >> .pkginfo @@ -284,28 +308,51 @@ packaging() { } +removeemptydirs() { + + msg2 "Removing empty directories..." + find . -type d -empty -delete + +} + +removedocs() { + + msg2 "Removing docs..." + for dir in ${DOC_DIRS[@]}; do + [ -d $dir ] && rm -fr $dir + done + +} + +removelibtool() { + + msg2 "Removing libtool files..." + find . -name "*.la" -delete + +} + purgefiles() { - for option in ${PURGE_FILE[@]}; do - if [ -e $option ]; then - msg2 "Purging $option..." - rm -fr $option - fi - done + for option in ${PURGE_FILES[@]}; do + if [ -e $option ]; then + msg2 "Purging $option..." + rm -fr $option + fi + done } strip_files() { - msg2 "Stripping binaries..." - find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null - msg2 "Stripping libraries..." - find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null + msg2 "Stripping binaries & libraries..." + find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null + find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null + } compressinfomanpages() { + msg2 "Compressing man & info pages..." if [ -d usr/share/man ]; then - msg2 "Compressing man pages..." ( cd usr/share/man find . -type f ! -name "*.gz" -exec gzip -9 -f {} \; for i in $(find . -type l) ; do ln -s $(readlink $i).gz $i.gz ; rm $i ; done @@ -313,7 +360,6 @@ compressinfomanpages() { fi if [ -d usr/share/info ]; then - msg2 "Compressing info pages..." ( cd usr/share/info find . -name "*.info*" -exec gzip -9 {} \; ) @@ -477,26 +523,34 @@ getoptions() { for opt in ${OPTIONS[@]}; do case $opt in - libtool|!libtool) - [ "${opt::1}" = '!' ] && REMOVE_LIBTOOL=yes - ;; - emptydirs|!emptydirs) - [ "${opt::1}" = '!' ] && REMOVE_EMPTYDIRS=yes - ;; - strip|!strip) - [ "${opt::1}" = '!' ] && NO_STRIP=yes - ;; - docs|!docs) - [ "${opt::1}" = '!' ] || REMOVE_DOCS=yes - ;; - zipman|!zipman) - [ "${opt::1}" = '!' ] || COMPRESS_MAN=yes - ;; - buildflags|!buildflags) - [ "${opt::1}" = '!' ] && CFLAGS=""; CXXFLAGS="" - ;; - makeflags|!makeflags) - [ "${opt::1}" = '!' ] && MAKEFLAGS="" + libtool) + REMOVE_LIBTOOL="" ;; + !libtool) + REMOVE_LIBTOOL=yes ;; + emptydirs) + REMOVE_EMPTYDIRS="" ;; + !emptydirs) + REMOVE_EMPTYDIRS=yes ;; + strip) + STRIP_PKG=yes ;; + !strip) + STRIP_PKG="" ;; + docs) + REMOVE_DOCS="" ;; + !docs) + REMOVE_DOCS=yes ;; + zipman) + COMPRESS_MAN=yes ;; + !zipman) + COMPRESS_MAN="" ;; + purge) + PURGE_FILES=yes ;; + !purge) + PURGE_FILES="" ;; + !buildflags) + CFLAGS=""; CXXFLAGS="" ;; + !makeflags) + MAKEFLAGS="" esac done @@ -655,6 +709,8 @@ main() { loadconfigfile + getoptions + parse_options "$@" ### DISABLE COLOR ### diff --git a/functions b/functions index a936746..b61748d 100644 --- a/functions +++ b/functions @@ -149,6 +149,7 @@ getpkginfo() { depends=$(cat $BUILD_SCRIPT | grep ^'# depends' | sed 's/\://' | cut -d ' ' -f 3-) makedepends=$(cat $BUILD_SCRIPT | grep ^'# makedepends' | sed 's/\://' | cut -d ' ' -f 3-) noextract=$(cat $BUILD_SCRIPT | grep ^'# noextract' | sed 's/\://' | cut -d ' ' -f 3-) + options=$(cat $BUILD_SCRIPT | grep ^'# options' | sed 's/\://' | cut -d ' ' -f 3-) . $BUILD_SCRIPT diff --git a/scratchpkg.conf b/scratchpkg.conf index 4496bf6..8926e4d 100644 --- a/scratchpkg.conf +++ b/scratchpkg.conf @@ -13,8 +13,10 @@ PORT_REPO=(/usr/ports/base /usr/ports/xorg /usr/ports/extra) -#PURGE_FILE=(usr/share/locale -# usr/share/doc -# usr/share/gtk-doc) - NO_EXTRACT=(usr/share/locale) + +OPTIONS=(!libtool emptydirs strip docs purge zipman buildflags makeflags) + +PURGE_FILES=(usr/share/info/dir usr/info/dir) +DOC_DIRS=(usr/{,local/}{,share/}{doc,gtk-doc} opt/*/{doc,gtk-doc}) +MAN_DIRS=({usr{,/local}{,/share},opt/*}/{man,info})