# HG changeset patch # User Christian Mesh # Date 1336748780 18000 # Node ID 16290349d8954503295c90034e116f281131f39f # Parent f22c79a37a740146471482eeb6e920ca146810dd added some stuff to libspk diff -r f22c79a37a74 -r 16290349d895 rootfs/lib/libspk.sh --- a/rootfs/lib/libspk.sh Fri May 11 09:58:16 2012 -0500 +++ b/rootfs/lib/libspk.sh Fri May 11 10:06:20 2012 -0500 @@ -1,4 +1,70 @@ #!/bin/sh # LibSpk - SliTaz Package Managment Library # +# Just some guesses as to what should be in libspk +# # Authors : See the AUTHORS filesi + +TMP_DIR=/tmp/$RANDOM + +# takes a file or directory and returns the base directory +base_path() { + local path=$1 + echo ${path%$(basename $path)} +} + +# converts /tmp/pkg.tazpkg to pkg +package_name() { + local name=$(basename $1) + echo ${name%.tazpkg} +} + +# checks to see if file is proper tazpkg +is_valid_tazpkg() { + local file=$1 + local file_dir=$(base_path $file) + [ -a $file ] && [ "$file" != "$(package_name $file)" ] +} + +valid_tazpkg() { + local file=$1 + if ! is_valid_tazpkg $file; then + gettext "$file is not a tazpkg. Exiting"; newline + exit 1 + fi +} + +# Display receipt information. +receipt_info() { + cat << EOT +$(gettext "Version :") ${VERSION}${EXTRAVERSION} +$(gettext "Short desc :") $SHORT_DESC +$(gettext "Category :") $CATEGORY +EOT +} + +# Unset all receipt variables. +unset_receipt() { + unset PACKAGE VERSION EXTRAVERSION SHORT_DESC HOST_ARCH TARBALL \ + DEPENDS BUILD_DEPENDS WANTED WGET_URL PROVIDE CROSS_BUG +} + +# Used by: list +count_installed() { + count=$(ls $installed | wc -l) + gettext "Installed packages"; echo ": $count" +} + +# Used by: list +count_mirrored() { + count=$(cat $pkgsmd5 | wc -l) + gettext "Mirrored packages"; echo ": $count" +} + + + + + +newline() { + echo +}