This commit is contained in:
emmett1
2017-10-14 00:33:05 +08:00
parent 3a4244c285
commit 32c1665768
3 changed files with 100 additions and 41 deletions

130
buildpkg
View File

@@ -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 ###

View File

@@ -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

View File

@@ -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})