#!/bin/sh # pacinstall 0.2 - Keeps track of file system changes during 'make install' # of software and installs it as a package in pacman. # Copyright (C) 2011 Andreas Textor (textor.andreas@googlemail.com) # # 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 3 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, see . # 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 or get it from AUR: http://aur.archlinux.org/packages.php?ID=1145 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 installation 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" echo "or get it from AUR: http://aur.archlinux.org/packages.php?ID=1145" 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