tazpkg view modules/install @ rev 963

modules/install: prefex "exact" packages over than "provided" packages.
In other words when requested "linux-agp": prefer "linux-agp" (if it exists) over the "linux-libre-agp".
author Aleksej Bobylev <al.bobylev@gmail.com>
date Mon Feb 26 00:54:19 2018 +0200 (16 months ago)
parents 69af973613cd
children ed2904dae9f2
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 < "$1" >/dev/null 2>&1
116 . ./receipt; echo $DEPENDS
117 rm -rf "$TMP_DIR"
118 )
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!)
190 # Find local package
191 namever=$(awk -F$'\t' -vpkg="$pkg" '{
192 if ($1 == pkg) { printf("%s-%s", $1, $2); exit; }
193 }' "$pi") # <namever> = <package_name>-<package_version>
195 # Find local provided package
196 [ -n "$namever" ] ||
197 namever=$(awk -F$'\t' -vpkg="$pkg" '{
198 if (index(" " $10 " ", " " pkg " ")) { printf("%s-%s", $1, $2); exit; }
199 }' "$pi") # <namever> = <package_name>-<package_version>
201 # Package file may be in form <namever>.tazpkg or <namever>-<arch>.tazpkg, so find one
202 [ -n "$namever" ] && pkgfile=$(find "$dir" -name "$namever*.tazpkg")
203 [ -n "$pkgfile" ] && found='1'
204 else
205 # Packages DB missing, proceed to sniff packages
206 tempd="$(mktemp -d)"; cd "$tempd"
207 for pkgfile in $dir/$pkg-*.tazpkg; do
208 [ -e "$pkgfile" ] || continue
209 # Extract receipt from each matched package
210 cpio -F "$pkgfile" -i receipt >/dev/null 2>&1
211 name=$(. ./receipt; echo $PACKAGE)
212 [ "$name" == "$pkg" ] && found='1' && break
213 # Install the first matched package: normally there is only one package
214 # with the $PACKAGE matched in the receipt
215 rm receipt
216 done
217 rm -r "$tempd"
218 fi
219 fi
220 debug " found='$found'"
222 if [ "$found" -eq 1 ]
223 then tazpkg install "$pkgfile"
224 else tazpkg get-install "$pkg"
225 fi
226 done
227 else
228 # Answered 'No' to install dependencies, or '--nodeps' option given
229 newline
230 _ 'Leaving dependencies for package "%s" unresolved.' "$PACKAGE"
231 _ 'The package will be installed but will probably not work.'
232 newline
233 fi
234 }
237 # Extract a package with cpio and gzip/lzma.
239 extract_package() {
240 # input: $1 - path to package to be extracted; package should be in the current dir
241 # ROOT INDEPENDENT
242 action 'Extracting package...'
244 # Extract "outer layer": cpio; remove the original package file
245 cpio -idm --quiet < "$1" && rm -f "$1"
247 # "Inner layer" may vary
248 if [ -f fs.cpio.lzma ]; then
249 # "Plain" cpio.lzma
250 unlzma < fs.cpio.lzma | cpio -idm --quiet && rm fs.cpio.lzma
251 elif [ -f fs.cpio.gz ]; then
252 # "Fast" cpio.gz (used to pack-then-install process in most of get-packages)
253 zcat fs.cpio.gz | cpio -idm --quiet && rm fs.cpio.gz
254 fi
256 status
257 }
260 # Print short package description
262 print_short_description() {
263 # TODO: undigest repo support? priority...
264 # ROOT READY
265 local short_desc=''
267 # Try to find localized short description
268 for LC in $LANG ${LANG%_*}; do
269 [ -e "$PKGS_DB/packages-desc.$LC" ] &&
270 short_desc=$(awk -F$'\t' -vp="$1" '$1==p{print $2; exit}' "$PKGS_DB/packages-desc.$LC")
271 done
273 # Try to find short description for mirrored package
274 [ -z "$short_desc" -a -s "$PKGS_DB/packages.info" ] &&
275 short_desc=$(awk -F$'\t' -vp="$1" '$1==p{print $4; exit}' "$PKGS_DB/packages.info")
277 [ -z "$short_desc" ] && short_desc="$SHORT_DESC"
279 longline "$short_desc"
280 }
283 grepesc() {
284 sed 's/\[/\\[/g'
285 }
290 #*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*
292 # Block of receipt function callers
293 # Why? "Bad" receipt sourcing can redefine some vital TazPkg variables.
294 # Few receipts functions should be patched now.
296 # Input: $1 = path to the receipt to be processed
298 # Pre-install commands
299 call_pre_install() {
300 local tmp
301 if grep -q '^pre_install()' "$1"; then
302 action 'Execute pre-install commands...'
303 tmp="$(mktemp)"
304 cp "$1" "$tmp"
305 sed -i 's|$1/*$INSTALLED|$INSTALLED|g' "$tmp"
306 ( . "$tmp"; pre_install "$root" )
307 status
308 rm "$tmp"
309 fi
311 }
312 # Post-install commands
313 call_post_install() {
314 local tmp
315 if grep -q '^post_install()' "$1"; then
316 action 'Execute post-install commands...'
317 tmp="$(mktemp)"
318 cp "$1" "$tmp"
319 sed -i 's|$1/*$INSTALLED|$INSTALLED|g' "$tmp"
320 ( . "$tmp"; post_install "$root" )
321 status
322 rm "$tmp"
323 fi
324 }
327 #*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*
330 # This function installs a package in the rootfs.
332 install_package() {
333 # input: $1 = path to package to be installed
334 # dep: install_all_deps, print_short_description, extract_package, grepesc.
336 debug "\ninstall_package('$1')"
337 local dir
339 PACKAGE_FILE="$1"
340 TMP_DIR="$(mktemp -d)"
342 # Get receipt's variables and functions
343 { cd "$TMP_DIR"; cpio --quiet -i receipt < "$PACKAGE_FILE" >/dev/null 2>&1; }
344 # Why next code? "Bad" receipt sourcing can redefine some vital TazPkg variables.
345 (
346 . "$TMP_DIR/receipt"
347 cat > "$TMP_DIR/receipt.var" <<EOT
348 PACKAGE="$PACKAGE"
349 VERSION="$VERSION"
350 EXTRAVERSION="$EXTRAVERSION"
351 CATEGORY="$CATEGORY"
352 SHORT_DESC="${SHORT_DESC//\"/\"}"
353 WEB_SITE="$WEB_SITE"
354 TAGS="$TAGS"
355 DEPENDS="$DEPENDS"
356 CONFIG_FILES="$CONFIG_FILES"
357 PACKED_SIZE="$PACKED_SIZE"
358 UNPACKED_SIZE="$UNPACKED_SIZE"
359 EOT
360 rm "$TMP_DIR/receipt"
361 )
362 . "$TMP_DIR/receipt.var"
365 # Make sure folder exists on new installs or upgrades
366 mkdir -p "$INSTALLED/$PACKAGE"
368 # Keep "modifiers" and "files.list" on upgrade
369 find "$INSTALLED/$PACKAGE" -type f \( ! -name modifiers ! -name files.list \) -delete
371 # Update "installed.md5"
372 # TODO: discontinue using 'installed.md5'
373 touch "$PKGS_DB/installed.$SUM"
374 sed -i "/ $(basename "$PACKAGE_FILE")$/d" "$PKGS_DB/installed.$SUM" 2>/dev/null
375 cd "$(dirname "$PACKAGE_FILE")"
376 $CHECKSUM "$(basename "$PACKAGE_FILE")" >> "$PKGS_DB/installed.$SUM"
378 # Resolve package dependencies before package installation
379 install_all_deps "$PACKAGE_FILE"
382 # TODO: why this list-processed in the $PKGS_DB?
383 #[ -n "$INSTALL_LIST" ] && echo "$PACKAGE_FILE" >> "$PKGS_DB/$INSTALL_LIST-processed"
385 # Special mode for using in cookutils: clearly show whether freshly used package or cached one
386 if [ -n "$cookmode" ]; then
387 f=${PACKAGE_FILE%/*}; f=${f%/*}; f=${f##*/}
388 if [ "$f" == "$(cat /etc/slitaz-release)" ]; then
389 _ 'Installing (web/cache): %s' "$(basename $PACKAGE_FILE .tazpkg)"
390 else
391 _ 'Installing (pkg/local): %s' "$(basename $PACKAGE_FILE .tazpkg)"
392 fi
393 fi
395 if [ -n "$sequence" ]; then
396 title 'Installation of package "%s" (%s)' "$PACKAGE" "$sequence"
397 else
398 title 'Installation of package "%s"' "$PACKAGE"
399 fi
401 if [ -z "$quiet" ]; then
402 print_short_description "$PACKAGE"
403 separator '-'
404 fi
406 action 'Copying package...'
407 cp "$PACKAGE_FILE" "$TMP_DIR"
408 status
410 cd "$TMP_DIR"
411 extract_package "$(basename "$PACKAGE_FILE")"
413 # Include temporary receipt to get the right variables
414 . "$TMP_DIR/receipt.var"
416 cd "$INSTALLED"
419 # Get files to remove if upgrading
420 # IFS here modified temporarily for processing filenames with spaces
421 IFS=$'\n'
422 if [ -f "$PACKAGE/files.list" ]; then
423 while read file; do
424 grep -q "^$(echo "$file" | grepesc)$" "$TMP_DIR/files.list" && continue
425 for i in $(cat "$PACKAGE/modifiers" 2>/dev/null;
426 fgrep -sl "$PACKAGE" */modifiers | cut -d/ -f1); do
427 grep -qs "^$(echo "$file" | grepesc)$" "$i/files.list" && continue 2
428 done
429 echo "$file"
430 done < "$PACKAGE/files.list" > "$TMP_DIR/files2remove.list"
431 fi
432 unset IFS
435 # Remember modified packages
436 action 'Remember modified packages...'
437 {
438 check=false
439 # TODO: why '[' the special?
440 # FIXME: we have files with spaces in our packages!
441 for i in $(fgrep -v [ $TMP_DIR/files.list); do
442 [ -e "$root$i" ] || continue
443 [ -d "$root$i" ] && continue
444 echo "- $i"
445 check=true
446 done ;
447 $check && \
448 for i in *; do
449 [ "$i" == "$PACKAGE" ] && continue
450 [ -s "$i/files.list" ] || continue
451 awk "{ printf \"$i %s\\n\",\$1 }" < "$i/files.list"
452 done;
453 } | awk '
454 {
455 if ($1 == "-" || file[$2] != "") {
456 file[$2] = file[$2] " " $1
457 if ($1 != "-") {
458 if (pkg[$1] == "") all = all " " $1
459 pkg[$1] = pkg[$1] " " $2
460 }
461 }
462 }
463 END {
464 for (i = split(all, p, " "); i > 0; i--)
465 for (j = split(pkg[p[i]], f, " "); j > 0; j--)
466 printf "%s %s\n",p[i],f[j];
467 }
468 ' | while read dir file; do
469 if grep -qs "^$dir$" "$PACKAGE/modifiers"; then
470 # Do not overload an overloaded file !
471 rm "$TMP_DIR/$file" 2>/dev/null
472 continue
473 fi
474 grep -qs "^$PACKAGE$" "$dir/modifiers" && continue
475 if [ -s "$dir/volatile.cpio.gz" ]; then
476 # We can modify backed up files without notice
477 zcat "$dir/volatile.cpio.gz" | cpio -t --quiet | \
478 grep -q "^${file#/}$" && continue
479 fi
480 echo "$PACKAGE" >> "$dir/modifiers"
481 done
482 status
485 cd "$TMP_DIR"
486 # Copy receipt, etc.
487 for file in receipt files.list description.txt $CHECKSUM; do
488 [ -f "$file" ] && cp "$file" "$INSTALLED/$PACKAGE"
489 done
492 # Pre-install commands
493 call_pre_install "$INSTALLED/$PACKAGE/receipt"
496 if [ -n "$CONFIG_FILES" ]; then
497 # Save "official" configuration files
498 action 'Saving configuration files...'
499 debug "\n"
501 cd fs
502 local config_file
503 for config_file in $CONFIG_FILES; do
504 debug " config_file: '$config_file'"
505 find ${config_file#/} -type f 2>/dev/null
506 done | cpio -o -H newc --quiet | gzip -9 > "$INSTALLED/$PACKAGE/volatile.cpio.gz"
507 cd ..
509 if [ -z "$newconf" ]; then
510 debug " no '--newconf': clean official config files"
511 # Keep user configuration files: remove "official" from fs tree
512 for config_file in $CONFIG_FILES; do
513 for config_file_official in $(find "fs$config_file" ! -type d 2>/dev/null | sed 's|^fs||'); do
514 if [ -e "$root$config_file_official" ]; then
515 debug " official '$config_file_official' will be skipped"
516 rm "fs$config_file_official"
517 else
518 debug " official '$config_file_official' will be written"
519 fi
520 done
521 done
522 fi
523 # always '[ Done ]' status, unless '--newconf' is passed or not
524 :; status
525 fi
528 if [ -n "$(ls fs/* 2>/dev/null)" ]; then
529 action 'Installing package...'
531 debug '\n resolving destination links in source'
532 IFS=$'\n'
533 for dir in $(find fs -type d | sed 's|^fs||;/^$/d'); do
534 if ldir=$(readlink -n $root$dir); then
535 debug " * mv 'fs$dir'\n -> 'fs${dir%/*}/$ldir'"
536 mkdir -p "fs${dir%/*}/${ldir%/*}"
537 mv "fs$dir" "fs${dir%/*}/$ldir"
538 fi
539 done
540 unset IFS
542 debug ' copying folders and files to destination'
543 cp -af fs/* "$root/"
544 status
545 fi
548 if [ -s files2remove.list ]; then
549 action 'Removing old files...'
550 while read file; do
551 dir="$root$file"
552 # Remove specified file
553 rm -f "$dir"
554 # Recursive remove non-empty up-dirs
555 while [ "$dir" != "$root/" ]; do
556 dir=$(dirname "$dir")
557 rmdir "$dir" 2>/dev/null || break
558 done
559 done < files2remove.list
560 :; status
561 fi
564 # Remove the temporary random directory.
565 action "Removing all tmp files..."
566 cd ..; rm -rf "$TMP_DIR"
567 status
570 # Post install commands
571 call_post_install "$INSTALLED/$PACKAGE/receipt"
576 # Update system databases
577 # Updating DBs is important process, so not to hide such errors (localized):
578 # chroot: can't execute '/usr/bin/***': No such file or directory
580 local fl="$INSTALLED/$PACKAGE/files.list" upd=0 udesk umime uicon uschm ukrnl ukrnlfs
582 fgrep /usr/share/applications/ "$fl" | fgrep -q .desktop && udesk='yes'
583 fgrep -q /usr/share/mime "$fl" && umime='yes'
584 fgrep -q /usr/share/icon/hicolor "$fl" && uicon='yes'
585 fgrep /usr/share/glib-2.0/schemas "$fl" | fgrep -q .xml && uschm='yes'
586 fgrep /usr/lib/gdk-pixbuf "$fl" | fgrep -q .so && upixb='yes'
587 if fgrep -q /lib/modules "$fl"; then
588 ukrnl='yes'
589 if fgrep -q /kernel/fs/ "$fl"; then
590 ukrnlfs='yes'
591 fi
592 fi
594 if [ -n "$udesk$umime$uicon$uschm$upixb$ukrnl" ]; then
595 action 'Update system databases...'
596 upd=1
597 fi
599 # package 'desktop-file-utils'
600 [ -n "$udesk" ] && chroot "$root/" /usr/bin/update-desktop-database /usr/share/applications 2>/dev/null
601 # package 'shared-mime-info'
602 [ -n "$umime" ] && chroot "$root/" /usr/bin/update-mime-database /usr/share/mime
603 # packages 'gtk+', 'gtk+3'
604 [ -n "$uicon" ] && chroot "$root/" /usr/bin/gtk-update-icon-cache /usr/share/icons/hicolor
605 # package 'glib'
606 # hide messages like next because they are unresolved (we may to patch glib to hide them, almost the same)
607 # warning: Schema '*' has path '*'. Paths starting with '/apps/', '/desktop/' or '/system/' are deprecated.
608 [ -n "$uschm" ] && chroot "$root/" /usr/bin/glib-compile-schemas /usr/share/glib-2.0/schemas 2>&1 | fgrep -v '/apps/'
609 # package 'gdk-pixbuf'
610 [ -n "$upixb" ] && chroot "$root/" /usr/bin/gdk-pixbuf-query-loaders --update-cache
612 if [ -n "$ukrnlfs" ]; then
613 for i in $(awk -F/ '{if($6=="fs" && $8~$7)print $7}' "$fl" | sort -u); do
614 touch "$root/etc/filesystems"
615 grep -q "^$i\$" "$root/etc/filesystems" || echo "$i" >> "$root/etc/filesystems"
616 done
617 fi
618 # packages 'busybox', 'kmod', 'depmod'
619 [ -n "$ukrnl" ] && grep '/lib/modules' "$fl" | cut -d'/' -f4 | uniq | xargs chroot "$root/" /sbin/depmod -a
621 [ "$upd" -eq 1 ] && status
626 # Update installed.info ----------------------------------------------------
627 SIZES=$(echo $PACKED_SIZE $UNPACKED_SIZE | sed 's|\.0||g')
629 # Remove newlines from some receipts
630 DEPENDS=$(echo $DEPENDS)
631 PKG_SUM="$(fgrep " $PACKAGE-$VERSION$EXTRAVERSION.tazpkg" "$PKGS_DB/installed.$SUM" | cut -d' ' -f1)"
633 # Calculate "release checksum": md5sum of file containing md5sums of:
634 # a) all files, b) receipt, and c) description.txt.
635 rsumf=$(mktemp)
636 cp $INSTALLED/$PACKAGE/md5sum $rsumf
637 md5sum $INSTALLED/$PACKAGE/receipt | sed 's| [^ ]*/| |' >> $rsumf
638 [ -e "$INSTALLED/$PACKAGE/description.txt" ] &&
639 md5sum $INSTALLED/$PACKAGE/description.txt | sed 's| [^ ]*/| |' >> $rsumf
640 RSUM=$(md5sum $rsumf | awk '{print $1}')
641 rm $rsumf
643 ii="$PKGS_DB/installed.info"
645 # Remove old entry
646 sed -i "/^$PACKAGE /d" "$ii"
648 cat >> "$ii" <<EOT
649 $PACKAGE $VERSION$EXTRAVERSION $CATEGORY $SHORT_DESC $WEB_SITE $TAGS $SIZES $DEPENDS $PKG_SUM
650 EOT
652 TEMP_FILE="$(mktemp)"
653 sort "$ii" > "$TEMP_FILE"; mv -f "$TEMP_FILE" "$ii"; chmod a+r "$ii"; unset ii
654 # --------------------------------------------------------------------------
656 cd "$CUR_DIR"
657 footer "$(_ 'Package "%s" (%s) is installed.' "$PACKAGE" "$VERSION$EXTRAVERSION")"
659 # Log this activity
660 log_pkg Installed
662 # Remove package from upgrade list
663 [ -s "$UP_LIST" ] && sed -i "/^$PACKAGE\$/d" "$UP_LIST"
664 }
669 #*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*
672 PACKAGE=$(
673 tmp_dir=$(mktemp -d); cd "$tmp_dir"
674 cpio --quiet -i receipt < "$1" >/dev/null 2>&1
675 . ./receipt; echo $PACKAGE
676 rm -rf "$tmp_dir"
677 )
679 if grep -qs "^$PACKAGE$" "$BLOCKED"; then
680 _ 'Package "%s" blocked.' "$PACKAGE"
681 exit 1
682 fi
684 if [ -z "$forced" ]; then
685 # Check if a package is already installed
686 debug "\ncheck for installed package '$PACKAGE'"
688 awk -F$'\t' -vpv="$PACKAGE" '$1==pv { exit 1 }' "$PKGS_DB/installed.info"
690 if [ "$?" -eq 1 ]; then
691 if [ -z "$quiet" ]; then
692 newline
693 _ '"%s" package is already installed.' "$(colorize 34 "$PACKAGE")"
694 longline "$(_ 'You can use the --forced option to force installation.')"
695 newline
696 fi
697 exit 1
698 fi
699 fi
701 install_package "$(realpath "$1")"