--- makepkg.orig 2008-04-21 18:14:03.000000000 +0200 +++ makepkg 2008-04-22 00:15:16.000000000 +0200 @@ -38,6 +38,8 @@ startdir="$PWD" srcdir="$startdir/src" pkgdir="$startdir/pkg" +# we need an extra dir to collect the docs +docdir="$startdir/doc" # Options ASROOT=0 @@ -141,7 +143,7 @@ # If it's a clean exit and -c/--clean has been passed... msg "$(gettext "Cleaning up...")" cd "$startdir" - rm -rf pkg src + rm -rf pkg src doc if [ "$pkgname" != "" ]; then # Can't do this unless the BUILDSCRIPT has been sourced. rm -f "${pkgname}-${pkgver}-${pkgrel}-${CARCH}.log*" @@ -710,11 +712,12 @@ cd "$pkgdir" msg "$(gettext "Tidying install...")" - if [ "$(check_option docs)" = "n" ]; then - msg2 "$(gettext "Removing info/doc files...")" - #fix flyspray bug #5021 - rm -rf ${DOC_DIRS[@]} - fi + # move the docs into $docdir + for dir in ${DOC_DIRS[@]}; do + [ -d $dir ] && mkdir -p $docdir/$(dirname $dir) && mv $dir $docdir/$(dirname $dir) + do + # if there's nothing to read, we can remove $docdir + [ "$(find $docdir -type f | wc -l)" = "0" ] && rm -r $docdir msg2 "$(gettext "Compressing man pages...")" local manpage mandirs ext file link hardlinks hl @@ -789,6 +792,9 @@ local packager="Unknown Packager" fi local size=$(du -sb | awk '{print $1}') + # additional info on doc size + local docsize=0 + [ -d "$docdir" ] && local docsize=$(du -sb "$docdir" | awk '{print $1}') # write the .PKGINFO file msg2 "$(gettext "Generating .PKGINFO file...")" @@ -804,6 +810,7 @@ echo "builddate = $builddate" >>.PKGINFO echo "packager = $packager" >>.PKGINFO echo "size = $size" >>.PKGINFO + echo "docsize = $docsize" >>.PKGINFO if [ "$CARCH" != "" ]; then echo "arch = $CARCH" >>.PKGINFO fi @@ -870,6 +877,22 @@ error "$(gettext "Failed to create package file.")" exit 1 # TODO: error code fi + + # make the doc package (if the docdir is still present) + if [ -d "$docdir" ]; then + cd "$docdir" + msg "$(gettext "Creating doc package...")" + msg2 "$(gettext "Compressing doc package...")" + + local doc_file="$PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}${DOCEXT}" + + if ! bsdtar -czf "$doc_file" $(ls); then + error "$(gettext "Failed to create doc package file.")" + exit 1 # TODO: error code + fi + else + msg "$(gettext "No extra docs for this package.")" + fi } create_xdelta() { @@ -977,6 +1000,9 @@ install_package() { [ "$INSTALL" = "0" ] && return msg "$(gettext "Installing package ${pkgname} with pacman -U...")" + # if docs is set in makepkg.conf, just add --withdoc to pacman + # TODO: we need to implement this option in pacman to install the .doc.tar.gz + [ "$(check_option docs)" = "y" ] && PACMAN_OPTS="$PACMAN_OPTS --withdocs" if [ "$ASROOT" = "0" ]; then sudo pacman $PACMAN_OPTS -U $PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT} || exit $? else @@ -1122,6 +1148,8 @@ _PKGDEST=${PKGDEST} _SRCDEST=${SRCDEST} +# this one sould be set in makepkg.conf, but we could set a fallback default here +#DOCEXT='.doc.tar.gz' # Source makepkg.conf; fail if it is not found if [ -r "$confdir/makepkg.conf" ]; then source "$confdir/makepkg.conf" @@ -1466,6 +1494,11 @@ rm -rf "$pkgdir" fi mkdir -p "$pkgdir" + if [ -d "$docdir" -a "$REPKG" = "0" ]; then + msg "$(gettext "Removing existing doc/ directory...")" + rm -rf "$docdir" + fi + mkdir -p "$docdir" cd "$startdir" if [ $EUID -eq 0 ]; then