#!/bin/bash opt_array() { if [[ -n "${options[@]}" ]]; then for num in $(seq 0 $((${#options[@]} - 1))); do opt=${options[num]} if [ "$opt" = "$1" ]; then return 0 elif [ "$opt" = "!$1" ]; then return 1 fi done fi if [[ -n "${OPTIONS[@]}" ]]; then for num in $(seq 0 $((${#OPTIONS[@]} - 1))); do opt=${OPTIONS[num]} if [ "$opt" = "$1" ]; then return 0 elif [ "$opt" = "!$1" ]; then return 1 fi done fi return 100 } check_options() { opt_array $1 case $? in 0) [ "$2" = "y" ] return ;; 1) [ "$2" = "n" ] return esac return 100 } removedocs() { msg2 "Removing docs..." for dir in ${DOC_DIRS[@]}; do [ -d $dir ] && rm -fr $dir done } removeemptydirs() { msg2 "Removing empty directories..." find . -type d -empty -delete } removelibtool() { msg2 "Removing libtool files..." find . ! -type d -name "*.la" -delete } purgefiles() { msg2 "Purging unwanted files..." for option in ${PURGE_FILES[@]}; do if [ -e $option ]; then rm -fr $option fi done } strip_files() { msg2 "Stripping binaries & libraries..." find . -type f 2>/dev/null | while read -r binary ; do case "$(file -bi "$binary")" in *application/x-sharedlib*) # Libraries (.so) strip --strip-unneeded "$binary" ;; *application/x-archive*) # Libraries (.a) strip --strip-debug "$binary" ;; *application/x-object*) case "$binary" in *.ko) # Kernel module strip --strip-unneeded "$binary" ;; *) continue;; esac;; *application/x-executable*) # Binaries strip --strip-all "$binary" ;; *) continue ;; esac done } compressinfomanpages() { msg2 "Compressing man & info pages..." for mandir in ${MAN_DIRS[@]}; do if [ -d $mandir ]; then (cd $mandir find . -type f ! -name "*.gz" -exec gzip -9 -f {} \; 2>/dev/null for i in $(find . -type l) ; do ln -s $(readlink $i).gz $i.gz ; rm $i ; done ) fi done if [ -d usr/share/info ]; then (cd usr/share/info find . -type f ! -name "*.gz" -exec gzip -9 -f {} \; 2>/dev/null ) fi }