#!/bin/sh # pacinstall 0.2 by Andreas Textor (textor.andreas@googlemail.com) # resembles checkinstall, for Arch Linux # See pacinstall -h or pacinstall --help for help # # This script is based on inst2rpm by Jon A. Christopher, # which is included with installwatch until version 0.5.6 # Changelog: 0.1 - first version # 0.2 - fixed handling of files with spaces in their names # help function displayhelp { cat << EOF pacinstall 0.2 by Andreas Textor Resembles checkinstall, for Arch Linux (http://archlinux.org/) Just call pacinstall instead of "make install" when installing software from source. An arch package will be created and installed using pacman. You need to have installwatch installed, download it here: http://asic-linux.com.mx/~izto/checkinstall/installwatch.html EOF } # check for parameters and id if [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$1" = "help" ]; then displayhelp exit fi if [ `whoami` != "root" ]; then echo "WARNING! You are not root. Errors during the installition are expected." echo -n "If you still want to continue, type "yes" (otherwise press CTRL+C): " read tmp if [ x"$tmp" != "xyes" ]; then exit fi fi # check for installwatch INSTALLWATCH=`which installwatch 2>/dev/null` if [ x$INSTALLWATCH = x ]; then echo "installwatch not found in PATH, exiting." echo "Get it from: http://asic-linux.com.mx/~izto/checkinstall/installwatch.html" exit fi # set up values and temp-directory MPWD="`pwd`" a="${MPWD##*/}" VERSION="${a##*-}" PACKAGE="${a%%-*}" URL= SUMMARY= LICENSE="GPL" ARCH="i686" DEPENDS= FAKEROOT=/tmp/pacinstall PKGINFO=$FAKEROOT/.PKGINFO FILEINFO=$FAKEROOT/.FILELIST INSTALLWATCHLOG=/tmp/installwatchlog.$$ FILELIST=/tmp/filelist.$$ if [ -d $FAKEROOT ]; then rm -rf $FAKEROOT fi mkdir $FAKEROOT # get values echo -n "New package name: ($PACKAGE): "; read tmp if [ x"$tmp" != x ]; then PACKAGE="$tmp" fi echo -n "Version: ($VERSION): "; read tmp if [ x"$tmp" != x ]; then VERSION="$tmp" fi echo -n "URL: ($URL): "; read tmp if [ x"$tmp" != x ]; then URL="$tmp" fi echo -n "Summary: ($SUMMARY): "; read tmp if [ x"$tmp" != x ]; then SUMMARY="$tmp" fi echo -n "License: ($LICENSE): "; read tmp if [ x"$tmp" != x ]; then LICENSE="$tmp" fi echo -n "Architecture: ($ARCH): "; read tmp if [ x"$tmp" != x ]; then ARCH="$tmp" fi echo -n "Depends (space separated): ($DEPENDS): "; read tmp if [ x"$tmp" != x ]; then DEPENDS="$tmp" fi echo echo "Installing using installwatch..." installwatch -o $INSTALLWATCHLOG make install echo "Copying files to temp directory..." awk -F'\t' '$2=="open"||$2=="link" {print $3} ; $2=="rename" {print $4}' < $INSTALLWATCHLOG | grep ^/ | \ egrep -v '/dev|$HOME' | sort | uniq > $FILELIST for i in `cat $FILELIST`; do tdir="${FAKEROOT}/${i%/*}" mkdir -p "$tdir" cp "$i" "$tdir" done /bin/rm $FILELIST echo "Create PKGINFO and FILEINFO..." # write PKGINFO file [ -e $PKGINFO ] && rm $PKGINFO cat > $PKGINFO << EOF # Generated by pacinstall pkgname = $PACKAGE pkgver = $VERSION pkgdesc = $SUMMARY url = $URL builddate = `LC_ALL=C date "+%a %b %d %H:%M:%S %Y"` packager = Pacinstall size = `/bin/du -sb $FAKEROOT|awk '{ print $1 }'` arch = $ARCH license = $LICENSE EOF if [ x"$DEPENDS" != x ]; then for i in $DEPENDS; do echo "depend = $i" >> $PKGINFO done fi # write FILEINFO file cd $FAKEROOT [ -e $FILEINFO ] && rm $FILEINFO for i in *; do find $i >> $FILEINFO done PKG="$MPWD/$PACKAGE-$VERSION.pkg.tar.gz" echo "Creating Package `basename $PKG`..." cd "$FAKEROOT" tar cfvz "$PKG" .PKGINFO .FILELIST * echo "$PKG written." # install the package via pacman, to let pacman know about the new files echo "Installing $PKG..." pacman -Uf "$PKG" # clean up /bin/rm -rf $FAKEROOT /bin/rm $INSTALLWATCHLOG