tazpkg rev 890

Module 'install': process option '--local' without using the databases
author Aleksej Bobylev <al.bobylev@gmail.com>
date Thu Dec 17 15:44:35 2015 +0200 (2015-12-17)
parents ce0db4329d29
children 879df9728956
files modules/install
line diff
     1.1 --- a/modules/install	Wed Dec 16 12:01:42 2015 +0200
     1.2 +++ b/modules/install	Thu Dec 17 15:44:35 2015 +0200
     1.3 @@ -145,8 +145,6 @@
     1.4  	# Also we can prefer local packages over mirrored/cached using '--local' option
     1.5  	[ "$dir" == '/home/boot/packages' ] && local='yes'
     1.6  	debug "  local='$local'"
     1.7 -	[ -n "$local" ] && tazpkg mkdb "$dir" --forced >/dev/null
     1.8 -
     1.9  
    1.10  	# "--nodeps" option prevents to install dependencies
    1.11  	if [ "$answer" -eq 0 -a -z "$nodeps" ]; then
    1.12 @@ -159,14 +157,22 @@
    1.13  				found='0'
    1.14  				# Prefer local packages
    1.15  				if [ -n "$local" ]; then
    1.16 -					_ 'Checking if package "%s" exists in local list...' "$pkg"
    1.17 -					pkgfile=$(awk -F$'\t' -vp="$pkg" '
    1.18 -						$1==p{printf "%s-%s.tazpkg", $1, $2; exit 1}
    1.19 -						' "$dir/packages.info")
    1.20 -					if [ -n "$pkgfile" ]; then
    1.21 -						found='1'
    1.22 -						tazpkg install "$dir/$pkgfile"
    1.23 -					fi
    1.24 +					[ -z "$quiet" ] && _ 'Checking if package "%s" exists in local list...' "$pkg"
    1.25 +					# Find local package
    1.26 +					tempd="$(mktemp -d)"; cd "$tempd"
    1.27 +					for pkgfile in $dir/$pkg-*.tazpkg; do
    1.28 +						# Extract receipt from each matched package
    1.29 +						cpio -F "$pkgfile" -i receipt >/dev/null 2>&1
    1.30 +						name=$(. receipt; echo $PACKAGE)
    1.31 +						rm receipt
    1.32 +						if [ "$name" == "$pkg" ]; then
    1.33 +							found='1'
    1.34 +							# Install the first matched package: normally there is only one package
    1.35 +							# with the $PACKAGE matched in the receipt
    1.36 +							tazpkg install "$pkgfile"
    1.37 +						fi
    1.38 +					done
    1.39 +					rm -r "$tempd"
    1.40  				fi
    1.41  				debug "    found='$found'"
    1.42