spk rev 10

Add a Makefile and imrove spk-rm skeleton
author Christophe Lincoln <pankso@slitaz.org>
date Sat May 12 02:38:21 2012 +0200 (2012-05-12)
parents 7cd8650b22ae
children db99af6fac70
files Makefile lib/libspk.sh spk-rm
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/Makefile	Sat May 12 02:38:21 2012 +0200
     1.3 @@ -0,0 +1,45 @@
     1.4 +# Makefile for Spk.
     1.5 +#
     1.6 +
     1.7 +PACKAGE="spk"
     1.8 +PREFIX?=/usr
     1.9 +LINGUAS?=
    1.10 +
    1.11 +all: help
    1.12 +
    1.13 +# i18n
    1.14 +
    1.15 +pot:
    1.16 +	xgettext -o po/$(PACKAGE).pot -L Shell --package-name="Spk" \
    1.17 +		./spk ./spk-rm
    1.18 +
    1.19 +msgmerge:
    1.20 +	@for l in $(LINGUAS); do \
    1.21 +		echo -n "Updating $$l po file."; \
    1.22 +		msgmerge -U po/$$l.po po/$(PACKAGE).pot; \
    1.23 +	done;
    1.24 +
    1.25 +msgfmt:
    1.26 +	@for l in $(LINGUAS); do \
    1.27 +		echo "Compiling $$l mo file..."; \
    1.28 +		mkdir -p po/mo/$$l/LC_MESSAGES; \
    1.29 +		msgfmt -o po/mo/$$l/LC_MESSAGES/$(PACKAGE).mo po/$$l.po; \
    1.30 +	done;
    1.31 +
    1.32 +# Install
    1.33 +
    1.34 +install-msg: msgfmt
    1.35 +	install -m 0755 -d $(DESTDIR)$(PREFIX)/share/locale
    1.36 +	cp -a po/mo/* $(DESTDIR)$(PREFIX)/share/locale
    1.37 +
    1.38 +install:
    1.39 +	install -m 0755 -d $(DESTDIR)$(PREFIX)/bin
    1.40 +	install -m 0755 -d $(DESTDIR)$(PREFIX)/share/doc/spk
    1.41 +	install -m 0755 spk $(DESTDIR)$(PREFIX)/bin
    1.42 +
    1.43 +# Clean source
    1.44 +
    1.45 +clean:
    1.46 +	rm -rf po/mo
    1.47 +	rm -f po/*~
    1.48 +
     2.1 --- a/lib/libspk.sh	Fri May 11 11:16:09 2012 -0500
     2.2 +++ b/lib/libspk.sh	Sat May 12 02:38:21 2012 +0200
     2.3 @@ -15,7 +15,8 @@
     2.4  installed="$PKGS_DB/installed"
     2.5  pkgsdesc="$PKGS_DB/packages.desc"
     2.6  pkgsmd5="$PKGS_DB/packages.md5"
     2.7 -blocked="$PKGS_DB/blocked-packages.list"
     2.8 +blocked="$PKGS_DB/blocked.list"
     2.9 +activity="$PKGS_DB/activity"
    2.10  
    2.11  #
    2.12  # Functions
    2.13 @@ -86,10 +87,10 @@
    2.14  	local package="$1"
    2.15  	shift 1
    2.16  	local depends="$@"
    2.17 -	
    2.18 +
    2.19  	local deps=0
    2.20  	local missing
    2.21 -	
    2.22 +
    2.23  	#Calculate missing dependencies
    2.24  	for pkgorg in $depends; do
    2.25  		local pkg=$(equivalent_pkg $pkgorg)
    2.26 @@ -100,9 +101,9 @@
    2.27  			gettext "WARNING Dependency loop between \$package and \$pkg."; newline
    2.28  		fi
    2.29  	done
    2.30 -	
    2.31 +
    2.32  	gettext "\$deps missing package(s) to install."; newline
    2.33 -	
    2.34 +
    2.35  	# Return true if missing deps
    2.36  	[ "$deps" != "0" ]
    2.37  }
     3.1 --- a/spk-rm	Fri May 11 11:16:09 2012 -0500
     3.2 +++ b/spk-rm	Sat May 12 02:38:21 2012 +0200
     3.3 @@ -18,40 +18,49 @@
     3.4  	name=$(basename $0)
     3.5  	cat << EOT
     3.6  
     3.7 -$(boldify $(gettext "Usage:")) [package|--option] [pkg2 ... pkgN|--opt2]
     3.8 +$(boldify $(gettext "Usage:")) $name [packages|--options]
     3.9  
    3.10  $(boldify $(gettext "Options:"))
    3.11  
    3.12  $(boldify $(gettext "Examples:"))
    3.13 +  $name nano clex leafpad
    3.14 +  $name nano clex --confirm
    3.15  
    3.16  EOT
    3.17  	exit 0
    3.18  }
    3.19  
    3.20  #
    3.21 -# Commands
    3.22 +# Commands and exit
    3.23  #
    3.24  
    3.25  case "$1" in
    3.26 -	"") usage ;;
    3.27 -	*)
    3.28 -		count=0
    3.29 -		for pkg in $@
    3.30 -		do
    3.31 -			[ -d "$installed/$pkg" ] || continue
    3.32 -			count=$(($count + 1))
    3.33 -			[ "$count" == 1 ] && echo ""
    3.34 -			gettext "Removing"; echo " $pkg"
    3.35 -			separator
    3.36 -			# Handle --confirm
    3.37 -			if [ "$confirm" ]; then
    3.38 -				gettext "Confirm uninstalltion of:"; echo " $pkg"
    3.39 -				if ! yes_no; then
    3.40 -						gettext "Uninstallation canceled"
    3.41 -						echo -e "\n" && exit 0 ;;
    3.42 -				fi
    3.43 -			fi
    3.44 -			gettext "TODO"; echo
    3.45 -		done ;;
    3.46 +	""|usage|help) usage && exit 0 ;;
    3.47  esac
    3.48 +
    3.49 +#
    3.50 +# Handle packages
    3.51 +#
    3.52 +
    3.53 +count=0
    3.54 +check_root
    3.55 +
    3.56 +for pkg in $@
    3.57 +do
    3.58 +	[ -d "$installed/$pkg" ] || continue
    3.59 +	count=$(($count + 1))
    3.60 +	[ "$count" == 1 ] && echo ""
    3.61 +	gettext "Removing"; echo " $pkg"
    3.62 +	separator
    3.63 +	# Handle --confirm
    3.64 +	if [ "$confirm" ]; then
    3.65 +		gettext "Confirm uninstallation of"; echo -n " $pkg:"
    3.66 +		if ! confirm; then
    3.67 +			gettext "Uninstallation canceled"
    3.68 +			echo -e "\n" && exit 0
    3.69 +		fi
    3.70 +	fi
    3.71 +	gettext "TODO"; echo
    3.72 +done
    3.73 +
    3.74  exit 0