#!/bin/bash # mymakepkg.sh # Copyright (C) 2005 Olivier Mehani # # $Id: mymakepkg 71 2008-06-29 01:34:39Z shtrom $ # Build Slackware packages from the DESTDIR of a specifically installed soft. # # 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, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # MYUSER=shtrom if [ $UID != 0 ]; then echo "this script must be run as root" exit 1 fi if [ $# != 1 ]; then echo "usage: $0 package-name" exit 2 fi PKGNAME=../$1.tgz LOGFILE=../$1.log echo > ${LOGFILE} exec 3>${LOGFILE} echo "creating ${PKGNAME} (log is $LOGFILE)..." if [ -e ${PKGNAME} ]; then echo -n "package $PKGNAME already exists, overwrite ? [y/N] " read ans if [ "$ans" != "y" -a "$ans" != "Y" ]; then echo "cancelled" exit 1 fi echo "overwriting old package..." rm -f ${PKGNAME} fi echo "changing permissions..." chown -R root.root . for dir in ./usr/bin ./usr/sbin ./usr/X11/bin ./usr/X11/sbin ./usr/X11R6/bin ./usr/X11R6/sbin ; do if [ -d $dir ]; then echo " $dir" chgrp -R bin $dir fi done if [ -d ./var/www ]; then chown -R root.www-data ./var/www chmod g+s ./var/www fi echo "stripping binaries..." find . -name *.so -exec strip \{\} 2>&3 \; find . -name *.so.* -exec strip \{\} 2>&3 \; find . -type f -perm +111 -exec strip \{\} 2>&3 \; if find . -name *.so 2>/dev/null | grep -q "\.so$"; then if [ -e ./install/doinst.sh ] && grep -q "ldconfig" ./install/doinst.sh; then echo "the install script already updates shared library links" else echo "updating installation script to update shared library links..." cat >> ./install/doinst.sh <<- 'EOF' ( echo "Updating shared library links..." ; /sbin/ldconfig ) EOF fi fi if [ -d ./usr/share/man ]; then echo "moving manpages from /usr/share to /usr..." mkdir -p ./usr/man mv ./usr/share/man/* ./usr/man rmdir ./usr/share/man fi if [ -d ./usr/man ]; then echo "gzipping manpages..." find ./usr/man -type f -exec gzip \{\} 2>&3 \; if [ -e ./install/doinst.sh ] && grep -q "makewhatis" ./install/doinst.sh; then echo "the install script already updates the whatis database" else echo "updating installation script to update the whatis database..." cat >> ./install/doinst.sh <<- 'EOF' ( echo "Updating whatis database..." ; cd usr/man ; makewhatis -u `pwd` 2>&1) EOF fi fi if [ -d ./usr/info ]; then echo "gzipping infopages..." find ./usr/info -type f -name "*info" -exec gzip \{\} 2>&3 \; find ./usr/info -type f -name "*info-?" -exec gzip \{\} 2>&3 \; echo "removing infodir..." rm ./usr/info/dir 2>&3 if [ -e ./install/doinst.sh ] && grep -q "infodir" ./install/doinst.sh; then echo "the install script already recreates infodir properly" else echo "updating installation script to recreate infodir..." cat >> ./install/doinst.sh <<- 'EOF' ( echo "Updating infodir..." ; cd usr/info ; rm dir ; for file in * ; do install-info $file dir 2>/dev/null ; done ) EOF fi fi for file in `find . -name *.new`; do file=${file/.\//} origfile=${file/.new/} if [ -e ./install/doinst.sh ] && grep -q $file ./install/doinst.sh; then echo "the install script already handles $origfile properly..." else echo "updating installation script not to overwrite $origfile..." cat >> ./install/doinst.sh <<- EOF ( test ! -e $origfile && mv $file $origfile || echo "Not replacing $origfile" ) EOF fi done echo "packaging..." /sbin/makepkg -l y -p -c n ${PKGNAME} >&3 2>&1 echo "resetting rights..." chown -R $MYUSER.users . chown -R $MYUSER.users ${PKGNAME} echo "done"