tazpkg view modules/install @ rev 954

modules/install: PKG_SUM restores update new build detection
author Richard Dunbar <mojo@slitaz.org>
date Fri Nov 03 16:10:39 2017 -0400 (2017-11-03)
parents 4802158453e1
children 69af973613cd
line source
1 #!/bin/sh
2 # TazPkg - Tiny autonomous zone packages manager, hg.slitaz.org/tazpkg
3 # install - TazPkg module
4 # Install packages
7 # Connect function libraries
8 . /lib/libtaz.sh
9 . /usr/lib/slitaz/libpkg.sh
12 # Get TazPkg working environment
13 . @@MODULES@@/getenv
14 # $CACHE_DIR will change, it based on unchanged value of $SAVE_CACHE_DIR
15 SAVE_CACHE_DIR="$CACHE_DIR"
18 . @@MODULES@@/find-depends
23 # Log TazPkg activity
25 log_pkg() {
26 debug "\nlog_pkg('$1')\n PACKAGE='$PACKAGE'\n VERSION='$VERSION'\n EXTRAVERSION='$EXTRAVERSION'"
28 local extra
30 [ "$1" == 'Installed' ] && \
31 extra=" - $(fgrep " $PACKAGE-$VERSION" "$PKGS_DB/installed.$SUM" | awk '{print $1}')"
32 debug " extra='$extra'"
34 [ -w "$LOG" ] &&
35 echo "$(date +'%F %T') - $1 - $PACKAGE ($VERSION$EXTRAVERSION)$extra" >> $LOG
36 }
39 # get an already installed package from packages.equiv
41 equivalent_pkg() {
42 # input: $1 = dependency package name (like "nano");
43 # $2 = package path/name for which dependency tested
44 local i rep rules rule out
46 if [ -n "$local" ]; then
47 # Search for virtual packages
48 if [ -n "$cookmode" ]; then
49 pi='/home/slitaz/packages/packages.info'
50 else
51 pi="$(dirname "$2")/packages.info"
52 fi
53 [ -f "$pi" ] &&
54 out=$(awk -F$'\t' -vpkg="$1" '{
55 # if package name or provided package name matched
56 if ($1 == pkg || index(" " $10 " ", " " pkg " ")) { print $1 }
57 }' "$pi")
58 for i in $out; do
59 # If package installed
60 [ -f "$PKGS_DB/installed/$i/receipt" ] && out="$i" && break
61 unset out
62 done
63 else
64 rules=$(for rep in $PRIORITY; do
65 grep -hs "^$1=" "$rep/packages.equiv"
66 done | sed "s|^$1=||")
67 debug " >rules='$rules'"
69 for rule in $rules; do
70 debug " >rule='$rule'"
71 case $rule in
72 *:*)
73 debug '-- x:x'
74 # format 'alternative:newname'
75 # if alternative is installed then substitute newname
76 out="${rule#*:}"
77 awk -F$'\t' -vp="${rule%:*}" '$1==p{exit 1}' "$PKGS_DB/installed.info" || break
78 debug '-- x:x /'
79 ;;
80 *)
81 debug '-- x'
82 # unconditional substitution
83 out="$rule"
84 awk -F$'\t' -vp="$rule" '$1==p{exit 1}' "$PKGS_DB/installed.info" || break
85 debug '-- x /'
86 ;;
87 esac
88 unset out
89 done
90 fi
91 debug '--'
92 # if not found in packages.equiv then no substitution
93 echo "${out:-$1}"
94 }
97 # Check and install all missing deps.
98 # Auto install or ask user then install all missing deps from local dir, CD-ROM,
99 # media or from the mirror.
101 install_all_deps() {
102 # input: $1 = package file to check/install missing dependencies
103 # ROOT READY
104 # dep: equivalent_pkg.
106 debug "\ninstall_all_deps('$1')"
108 local TMP_DIR DEPENDS num missing_packages equiv pkg answer dir found pkgfile
110 # Check for missing deps listed in a receipt packages.
112 # Get the receipt's variable DEPENDS
113 DEPENDS=$(
114 TMP_DIR=$(mktemp -d); cd "$TMP_DIR"
115 cpio --quiet -i receipt >/dev/null 2>&1
116 . ./receipt; echo $DEPENDS
117 rm -rf "$TMP_DIR"
118 ) < "$1"
120 unset num missing_packages
121 for depend in $DEPENDS; do
122 debug " depend='$depend'"
123 equiv=$(equivalent_pkg $depend "$1")
124 debug " equiv='$equiv'\n"
125 if [ ! -d "$INSTALLED/$equiv" ]; then
126 missing_packages="$missing_packages $equiv"
127 num=$((num+1))
128 elif [ ! -f "$INSTALLED/$equiv/receipt" ]; then
129 [ -z "$quiet" ] && _ 'WARNING! Dependency loop between "%s" and "%s".' "$PACKAGE" "$equiv"
130 fi
131 done
133 # Nothing to install, exit function
134 [ -z "$num" ] && return
137 title "$(_ 'Tracking dependencies for package "%s"' "$PACKAGE")"
139 # Individual messages for each missing package
140 [ -z "$quiet" ] && \
141 for pkg in $missing_packages; do
142 _ 'Missing package "%s"' "$pkg"
143 done
145 footer "$(_p \
146 '%s missing package to install.' \
147 '%s missing packages to install.' "$num" \
148 "$num")"
151 if [ "$AUTO_INSTALL_DEPS" == 'yes' ] || [ -n "$quiet" ]; then
152 # Quietly not displaying anything. Assume 'yes' unless '--noconfirm' is provided
153 answer=0
154 [ -n "$noconfirm" ] && answer=1
155 else
156 # Display question; wait for answer or print auto-answer
157 newline
158 confirm "$(_ 'Install all missing dependencies? (y/N)')"
159 answer=$?
160 newline
161 fi
162 debug " answer='$answer'"
164 dir="$(dirname "$1")"
165 debug " dir='$dir'"
167 # We can install packages from /home/boot/packages at boot time
168 # Also we can prefer local packages over mirrored/cached using '--local' option
169 [ "$dir" == '/home/boot/packages' ] && local='yes'
170 debug " local='$local'"
172 # "--nodeps" option prevents to install dependencies
173 if [ "$answer" -eq 0 -a -z "$nodeps" ]; then
174 debug " let's install missing packages"
175 for pkg in $missing_packages; do
176 debug " pkg='$pkg'"
177 [ -d "$INSTALLED/$pkg" ] && continue
178 # Package not installed
180 found='0'; namever=''; pkgfile=''
181 # Prefer local packages
182 if [ -n "$local" ]; then
183 [ -z "$quiet" ] && _ 'Checking if package "%s" exists in local list...' "$pkg"
184 [ -n "$cookmode" ] && dir='/home/slitaz/packages'
185 pi="$dir/packages.info"
186 # Find local package
187 if [ -f "$pi" ]; then
188 # Packages database exists (should be everfresh!)
189 namever=$(awk -F$'\t' -vpkg="$pkg" '{
190 # if package name or provided package name matched
191 if (index(" " $1 " " $10 " ", " " pkg " ")) { printf("%s-%s", $1, $2); exit; }
192 }' "$pi") # <namever> = <package_name>-<package_version>
193 # Package file may be in form <namever>.tazpkg or <namever>-<arch>.tazpkg, so find one
194 [ -n "$namever" ] && pkgfile=$(find "$dir" -name "$namever*.tazpkg")
195 [ -n "$pkgfile" ] && found='1'
196 else
197 # Packages DB missing, proceed to sniff packages
198 tempd="$(mktemp -d)"; cd "$tempd"
199 for pkgfile in $dir/$pkg-*.tazpkg; do
200 [ -e "$pkgfile" ] || continue
201 # Extract receipt from each matched package
202 cpio -F "$pkgfile" -i receipt >/dev/null 2>&1
203 name=$(. ./receipt; echo $PACKAGE)
204 [ "$name" == "$pkg" ] && found='1' && break
205 # Install the first matched package: normally there is only one package
206 # with the $PACKAGE matched in the receipt
207 rm receipt
208 done
209 rm -r "$tempd"
210 fi
211 fi
212 debug " found='$found'"
214 if [ "$found" -eq 1 ]
215 then tazpkg install "$pkgfile"
216 else tazpkg get-install "$pkg"
217 fi
218 done
219 else
220 # Answered 'No' to install dependencies, or '--nodeps' option given
221 newline
222 _ 'Leaving dependencies for package "%s" unresolved.' "$PACKAGE"
223 _ 'The package will be installed but will probably not work.'
224 newline
225 fi
226 }
229 # Extract a package with cpio and gzip/lzma.
231 extract_package() {
232 # input: $1 - path to package to be extracted; package should be in the current dir
233 # ROOT INDEPENDENT
234 action 'Extracting package...'
236 # Extract "outer layer": cpio; remove the original package file
237 cpio -idm --quiet < "$1" && rm -f "$1"
239 # "Inner layer" may vary
240 if [ -f fs.cpio.lzma ]; then
241 # "Plain" cpio.lzma
242 unlzma < fs.cpio.lzma | cpio -idm --quiet && rm fs.cpio.lzma
243 elif [ -f fs.cpio.gz ]; then
244 # "Fast" cpio.gz (used to pack-then-install process in most of get-packages)
245 zcat fs.cpio.gz | cpio -idm --quiet && rm fs.cpio.gz
246 fi
248 status
249 }
252 # Print short package description
254 print_short_description() {
255 # TODO: undigest repo support? priority...
256 # ROOT READY
257 local short_desc=''
259 # Try to find localized short description
260 for LC in $LANG ${LANG%_*}; do
261 [ -e "$PKGS_DB/packages-desc.$LC" ] &&
262 short_desc=$(awk -F$'\t' -vp="$1" '$1==p{print $2; exit}' "$PKGS_DB/packages-desc.$LC")
263 done
265 # Try to find short description for mirrored package
266 [ -z "$short_desc" -a -s "$PKGS_DB/packages.info" ] &&
267 short_desc=$(awk -F$'\t' -vp="$1" '$1==p{print $4; exit}' "$PKGS_DB/packages.info")
269 [ -z "$short_desc" ] && short_desc="$SHORT_DESC"
271 longline "$short_desc"
272 }
275 grepesc() {
276 sed 's/\[/\\[/g'
277 }
282 #*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*
284 # Block of receipt function callers
285 # Why? "Bad" receipt sourcing can redefine some vital TazPkg variables.
286 # Few receipts functions should be patched now.
288 # Input: $1 = path to the receipt to be processed
290 # Pre-install commands
291 call_pre_install() {
292 local tmp
293 if grep -q '^pre_install()' "$1"; then
294 action 'Execute pre-install commands...'
295 tmp="$(mktemp)"
296 cp "$1" "$tmp"
297 sed -i 's|$1/*$INSTALLED|$INSTALLED|g' "$tmp"
298 ( . "$tmp"; pre_install "$root" )
299 status
300 rm "$tmp"
301 fi
303 }
304 # Post-install commands
305 call_post_install() {
306 local tmp
307 if grep -q '^post_install()' "$1"; then
308 action 'Execute post-install commands...'
309 tmp="$(mktemp)"
310 cp "$1" "$tmp"
311 sed -i 's|$1/*$INSTALLED|$INSTALLED|g' "$tmp"
312 ( . "$tmp"; post_install "$root" )
313 status
314 rm "$tmp"
315 fi
316 }
319 #*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*
322 # This function installs a package in the rootfs.
324 install_package() {
325 # input: $1 = path to package to be installed
326 # dep: install_all_deps, print_short_description, extract_package, grepesc.
328 debug "\ninstall_package('$1')"
329 local dir
331 PACKAGE_FILE="$1"
332 TMP_DIR="$(mktemp -d)"
334 # Get receipt's variables and functions
335 { cd "$TMP_DIR"; cpio --quiet -i receipt >/dev/null 2>&1; } < "$PACKAGE_FILE"
336 # Why next code? "Bad" receipt sourcing can redefine some vital TazPkg variables.
337 (
338 . "$TMP_DIR/receipt"
339 cat > "$TMP_DIR/receipt.var" <<EOT
340 PACKAGE="$PACKAGE"
341 VERSION="$VERSION"
342 EXTRAVERSION="$EXTRAVERSION"
343 CATEGORY="$CATEGORY"
344 SHORT_DESC="${SHORT_DESC//\"/\"}"
345 WEB_SITE="$WEB_SITE"
346 TAGS="$TAGS"
347 DEPENDS="$DEPENDS"
348 CONFIG_FILES="$CONFIG_FILES"
349 PACKED_SIZE="$PACKED_SIZE"
350 UNPACKED_SIZE="$UNPACKED_SIZE"
351 EOT
352 rm "$TMP_DIR/receipt"
353 )
354 . "$TMP_DIR/receipt.var"
357 # Make sure folder exists on new installs or upgrades
358 mkdir -p "$INSTALLED/$PACKAGE"
360 # Keep "modifiers" and "files.list" on upgrade
361 find "$INSTALLED/$PACKAGE" -type f \( ! -name modifiers ! -name files.list \) -delete
363 # Update "installed.md5"
364 # TODO: discontinue using 'installed.md5'
365 touch "$PKGS_DB/installed.$SUM"
366 sed -i "/ $(basename "$PACKAGE_FILE")$/d" "$PKGS_DB/installed.$SUM" 2>/dev/null
367 cd "$(dirname "$PACKAGE_FILE")"
368 $CHECKSUM "$(basename "$PACKAGE_FILE")" >> "$PKGS_DB/installed.$SUM"
370 # Resolve package dependencies before package installation
371 install_all_deps "$PACKAGE_FILE"
374 # TODO: why this list-processed in the $PKGS_DB?
375 #[ -n "$INSTALL_LIST" ] && echo "$PACKAGE_FILE" >> "$PKGS_DB/$INSTALL_LIST-processed"
377 # Special mode for using in cookutils: clearly show whether freshly used package or cached one
378 if [ -n "$cookmode" ]; then
379 f=${PACKAGE_FILE%/*}; f=${f%/*}; f=${f##*/}
380 if [ "$f" == "$(cat /etc/slitaz-release)" ]; then
381 _ 'Installing (web/cache): %s' "$(basename $PACKAGE_FILE .tazpkg)"
382 else
383 _ 'Installing (pkg/local): %s' "$(basename $PACKAGE_FILE .tazpkg)"
384 fi
385 fi
387 if [ -n "$sequence" ]; then
388 title 'Installation of package "%s" (%s)' "$PACKAGE" "$sequence"
389 else
390 title 'Installation of package "%s"' "$PACKAGE"
391 fi
393 if [ -z "$quiet" ]; then
394 print_short_description "$PACKAGE"
395 separator '-'
396 fi
398 action 'Copying package...'
399 cp "$PACKAGE_FILE" "$TMP_DIR"
400 status
402 cd "$TMP_DIR"
403 extract_package "$(basename "$PACKAGE_FILE")"
405 # Include temporary receipt to get the right variables
406 . "$TMP_DIR/receipt.var"
408 cd "$INSTALLED"
411 # Get files to remove if upgrading
412 # IFS here modified temporarily for processing filenames with spaces
413 IFS=$'\n'
414 if [ -f "$PACKAGE/files.list" ]; then
415 while read file; do
416 grep -q "^$(echo "$file" | grepesc)$" "$TMP_DIR/files.list" && continue
417 for i in $(cat "$PACKAGE/modifiers" 2>/dev/null;
418 fgrep -sl "$PACKAGE" */modifiers | cut -d/ -f1); do
419 grep -qs "^$(echo "$file" | grepesc)$" "$i/files.list" && continue 2
420 done
421 echo "$file"
422 done < "$PACKAGE/files.list" > "$TMP_DIR/files2remove.list"
423 fi
424 unset IFS
427 # Remember modified packages
428 action 'Remember modified packages...'
429 {
430 check=false
431 # TODO: why '[' the special?
432 # FIXME: we have files with spaces in our packages!
433 for i in $(fgrep -v [ $TMP_DIR/files.list); do
434 [ -e "$root$i" ] || continue
435 [ -d "$root$i" ] && continue
436 echo "- $i"
437 check=true
438 done ;
439 $check && \
440 for i in *; do
441 [ "$i" == "$PACKAGE" ] && continue
442 [ -s "$i/files.list" ] || continue
443 awk "{ printf \"$i %s\\n\",\$1 }" < "$i/files.list"
444 done;
445 } | awk '
446 {
447 if ($1 == "-" || file[$2] != "") {
448 file[$2] = file[$2] " " $1
449 if ($1 != "-") {
450 if (pkg[$1] == "") all = all " " $1
451 pkg[$1] = pkg[$1] " " $2
452 }
453 }
454 }
455 END {
456 for (i = split(all, p, " "); i > 0; i--)
457 for (j = split(pkg[p[i]], f, " "); j > 0; j--)
458 printf "%s %s\n",p[i],f[j];
459 }
460 ' | while read dir file; do
461 if grep -qs "^$dir$" "$PACKAGE/modifiers"; then
462 # Do not overload an overloaded file !
463 rm "$TMP_DIR/$file" 2>/dev/null
464 continue
465 fi
466 grep -qs "^$PACKAGE$" "$dir/modifiers" && continue
467 if [ -s "$dir/volatile.cpio.gz" ]; then
468 # We can modify backed up files without notice
469 zcat "$dir/volatile.cpio.gz" | cpio -t --quiet | \
470 grep -q "^${file#/}$" && continue
471 fi
472 echo "$PACKAGE" >> "$dir/modifiers"
473 done
474 status
477 cd "$TMP_DIR"
478 # Copy receipt, etc.
479 for file in receipt files.list description.txt $CHECKSUM; do
480 [ -f "$file" ] && cp "$file" "$INSTALLED/$PACKAGE"
481 done
484 # Pre-install commands
485 call_pre_install "$INSTALLED/$PACKAGE/receipt"
488 if [ -n "$CONFIG_FILES" ]; then
489 # Save "official" configuration files
490 action 'Saving configuration files...'
491 debug "\n"
493 cd fs
494 local config_file
495 for config_file in $CONFIG_FILES; do
496 debug " config_file: '$config_file'"
497 find ${config_file#/} -type f 2>/dev/null
498 done | cpio -o -H newc --quiet | gzip -9 > "$INSTALLED/$PACKAGE/volatile.cpio.gz"
499 cd ..
501 if [ -z "$newconf" ]; then
502 debug " no '--newconf': clean official config files"
503 # Keep user configuration files: remove "official" from fs tree
504 for config_file in $CONFIG_FILES; do
505 for config_file_official in $(find "fs$config_file" ! -type d 2>/dev/null | sed 's|^fs||'); do
506 if [ -e "$root$config_file_official" ]; then
507 debug " official '$config_file_official' will be skipped"
508 rm "fs$config_file_official"
509 else
510 debug " official '$config_file_official' will be written"
511 fi
512 done
513 done
514 fi
515 # always '[ Done ]' status, unless '--newconf' is passed or not
516 :; status
517 fi
520 if [ -n "$(ls fs/* 2>/dev/null)" ]; then
521 action 'Installing package...'
523 debug '\n resolving destination links in source'
524 IFS=$'\n'
525 for dir in $(find fs -type d | sed 's|^fs||;/^$/d'); do
526 if ldir=$(readlink -n $root$dir); then
527 debug " * mv 'fs$dir'\n -> 'fs${dir%/*}/$ldir'"
528 mkdir -p "fs${dir%/*}/${ldir%/*}"
529 mv "fs$dir" "fs${dir%/*}/$ldir"
530 fi
531 done
532 unset IFS
534 debug ' copying folders and files to destination'
535 cp -af fs/* "$root/"
536 status
537 fi
540 if [ -s files2remove.list ]; then
541 action 'Removing old files...'
542 while read file; do
543 dir="$root$file"
544 # Remove specified file
545 rm -f "$dir"
546 # Recursive remove non-empty up-dirs
547 while [ "$dir" != "$root/" ]; do
548 dir=$(dirname "$dir")
549 rmdir "$dir" 2>/dev/null || break
550 done
551 done < files2remove.list
552 :; status
553 fi
556 # Remove the temporary random directory.
557 action "Removing all tmp files..."
558 cd ..; rm -rf "$TMP_DIR"
559 status
562 # Post install commands
563 call_post_install "$INSTALLED/$PACKAGE/receipt"
568 # Update system databases
569 # Updating DBs is important process, so not to hide such errors (localized):
570 # chroot: can't execute '/usr/bin/***': No such file or directory
572 local fl="$INSTALLED/$PACKAGE/files.list" upd=0 udesk umime uicon uschm ukrnl ukrnlfs
574 fgrep /usr/share/applications/ "$fl" | fgrep -q .desktop && udesk='yes'
575 fgrep -q /usr/share/mime "$fl" && umime='yes'
576 fgrep -q /usr/share/icon/hicolor "$fl" && uicon='yes'
577 fgrep /usr/share/glib-2.0/schemas "$fl" | fgrep -q .xml && uschm='yes'
578 fgrep /usr/lib/gdk-pixbuf "$fl" | fgrep -q .so && upixb='yes'
579 if fgrep -q /lib/modules "$fl"; then
580 ukrnl='yes'
581 if fgrep -q /kernel/fs/ "$fl"; then
582 ukrnlfs='yes'
583 fi
584 fi
586 if [ -n "$udesk$umime$uicon$uschm$upixb$ukrnl" ]; then
587 action 'Update system databases...'
588 upd=1
589 fi
591 # package 'desktop-file-utils'
592 [ -n "$udesk" ] && chroot "$root/" /usr/bin/update-desktop-database /usr/share/applications 2>/dev/null
593 # package 'shared-mime-info'
594 [ -n "$umime" ] && chroot "$root/" /usr/bin/update-mime-database /usr/share/mime
595 # packages 'gtk+', 'gtk+3'
596 [ -n "$uicon" ] && chroot "$root/" /usr/bin/gtk-update-icon-cache /usr/share/icons/hicolor
597 # package 'glib'
598 # hide messages like next because they are unresolved (we may to patch glib to hide them, almost the same)
599 # warning: Schema '*' has path '*'. Paths starting with '/apps/', '/desktop/' or '/system/' are deprecated.
600 [ -n "$uschm" ] && chroot "$root/" /usr/bin/glib-compile-schemas /usr/share/glib-2.0/schemas 2>&1 | fgrep -v '/apps/'
601 # package 'gdk-pixbuf'
602 [ -n "$upixb" ] && chroot "$root/" /usr/bin/gdk-pixbuf-query-loaders --update-cache
604 if [ -n "$ukrnlfs" ]; then
605 for i in $(awk -F/ '{if($6=="fs" && $8~$7)print $7}' "$fl" | sort -u); do
606 touch "$root/etc/filesystems"
607 grep -q "^$i\$" "$root/etc/filesystems" || echo "$i" >> "$root/etc/filesystems"
608 done
609 fi
610 # packages 'busybox', 'kmod', 'depmod'
611 [ -n "$ukrnl" ] && grep '/lib/modules' "$fl" | cut -d'/' -f4 | uniq | xargs chroot "$root/" /sbin/depmod -a
613 [ "$upd" -eq 1 ] && status
618 # Update installed.info ----------------------------------------------------
619 SIZES=$(echo $PACKED_SIZE $UNPACKED_SIZE | sed 's|\.0||g')
621 # Remove newlines from some receipts
622 DEPENDS=$(echo $DEPENDS)
623 PKG_SUM="$(fgrep " $PACKAGE-$VERSION$EXTRAVERSION.tazpkg" "$PKGS_DB/installed.$SUM" | cut -d' ' -f1)"
625 # Calculate "release checksum": md5sum of file containing md5sums of:
626 # a) all files, b) receipt, and c) description.txt.
627 rsumf=$(mktemp)
628 cp $INSTALLED/$PACKAGE/md5sum $rsumf
629 md5sum $INSTALLED/$PACKAGE/receipt | sed 's| [^ ]*/| |' >> $rsumf
630 [ -e "$INSTALLED/$PACKAGE/description.txt" ] &&
631 md5sum $INSTALLED/$PACKAGE/description.txt | sed 's| [^ ]*/| |' >> $rsumf
632 RSUM=$(md5sum $rsumf | awk '{print $1}')
633 rm $rsumf
635 ii="$PKGS_DB/installed.info"
637 # Remove old entry
638 sed -i "/^$PACKAGE /d" "$ii"
640 cat >> "$ii" <<EOT
641 $PACKAGE $VERSION$EXTRAVERSION $CATEGORY $SHORT_DESC $WEB_SITE $TAGS $SIZES $DEPENDS $PKG_SUM
642 EOT
644 TEMP_FILE="$(mktemp)"
645 sort "$ii" > "$TEMP_FILE"; mv -f "$TEMP_FILE" "$ii"; chmod a+r "$ii"; unset ii
646 # --------------------------------------------------------------------------
648 cd "$CUR_DIR"
649 footer "$(_ 'Package "%s" (%s) is installed.' "$PACKAGE" "$VERSION$EXTRAVERSION")"
651 # Log this activity
652 log_pkg Installed
654 # Remove package from upgrade list
655 [ -s "$UP_LIST" ] && sed -i "/^$PACKAGE\$/d" "$UP_LIST"
656 }
661 #*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*
664 PACKAGE=$(
665 tmp_dir=$(mktemp -d); cd "$tmp_dir"
666 cpio --quiet -i receipt >/dev/null 2>&1
667 . ./receipt; echo $PACKAGE
668 rm -rf "$tmp_dir"
669 ) < "$1"
671 if grep -qs "^$PACKAGE$" "$BLOCKED"; then
672 _ 'Package "%s" blocked.' "$PACKAGE"
673 exit 1
674 fi
676 if [ -z "$forced" ]; then
677 # Check if a package is already installed
678 debug "\ncheck for installed package '$PACKAGE'"
680 awk -F$'\t' -vpv="$PACKAGE" '$1==pv { exit 1 }' "$PKGS_DB/installed.info"
682 if [ "$?" -eq 1 ]; then
683 if [ -z "$quiet" ]; then
684 newline
685 _ '"%s" package is already installed.' "$(colorize 34 "$PACKAGE")"
686 longline "$(_ 'You can use the --forced option to force installation.')"
687 newline
688 fi
689 exit 1
690 fi
691 fi
693 install_package "$(realpath "$1")"