Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #line 172 to 387 /usr/libexec/tazpkg/install from TazPup alpha 9
- install_package() {
- debug "\ninstall_package('$1')"
- local dir
- PACKAGE_FILE="$1"
- TMP_DIR="$(mktemp -d)"
- { cd "$TMP_DIR"; cpio --quiet -i receipt >/dev/null 2>&1; } < "$PACKAGE_FILE"
- (
- . "$TMP_DIR/receipt"
- cat > "$TMP_DIR/receipt.var" <<EOT
- PACKAGE="$PACKAGE"
- VERSION="$VERSION"
- EXTRAVERSION="$EXTRAVERSION"
- CATEGORY="$CATEGORY"
- SHORT_DESC="$SHORT_DESC"
- WEB_SITE="$WEB_SITE"
- TAGS="$TAGS"
- DEPENDS="$DEPENDS"
- CONFIG_FILES="$CONFIG_FILES"
- PACKED_SIZE="$PACKED_SIZE"
- UNPACKED_SIZE="$UNPACKED_SIZE"
- EOT
- rm "$TMP_DIR/receipt"
- )
- . "$TMP_DIR/receipt.var"
- mkdir -p "$INSTALLED/$PACKAGE"
- find "$INSTALLED/$PACKAGE" -type f \( ! -name modifiers ! -name files.list \) -delete
- touch "$PKGS_DB/installed.$SUM"
- sed -i "/ $(basename "$PACKAGE_FILE")$/d" "$PKGS_DB/installed.$SUM" 2>/dev/null
- cd "$(dirname "$PACKAGE_FILE")"
- $CHECKSUM "$(basename "$PACKAGE_FILE")">> "$PKGS_DB/installed.$SUM"
- install_all_deps "$PACKAGE_FILE"
- if [ -n "$cookmode" ]; then
- f=${PACKAGE_FILE%/*}; f=${f%/*}; f=${f##*/}
- if [ "$f" == "$(cat /etc/slitaz-release)" ]; then
- _ 'Installing (web/cache): %s' "$(basename $PACKAGE_FILE .tazpkg)"
- else
- _ 'Installing (pkg/local): %s' "$(basename $PACKAGE_FILE .tazpkg)"
- fi
- fi
- if [ -n "$sequence" ]; then
- title 'Installation of package "%s" (%s)' "$PACKAGE" "$sequence"
- else
- title 'Installation of package "%s"' "$PACKAGE"
- fi
- if [ -z "$quiet" ]; then
- print_short_description "$PACKAGE"
- separator '-'
- fi
- action 'Copying package...'
- cp "$PACKAGE_FILE" "$TMP_DIR"
- status
- cd "$TMP_DIR"
- extract_package "$(basename "$PACKAGE_FILE")"
- . "$TMP_DIR/receipt.var"
- cd "$INSTALLED"
- IFS=$'\n'
- if [ -f "$PACKAGE/files.list" ]; then
- while read file; do
- grep -q "^$(echo "$file" | grepesc)$" "$TMP_DIR/files.list" && continue
- for i in $(cat "$PACKAGE/modifiers" 2>/dev/null;
- fgrep -sl "$PACKAGE" */modifiers | cut -d/ -f1); do
- grep -qs "^$(echo "$file" | grepesc)$" "$i/files.list" && continue 2
- done
- echo "$file"
- done < "$PACKAGE/files.list"> "$TMP_DIR/files2remove.list"
- fi
- unset IFS
- action 'Remember modified packages...'
- {
- check=false
- for i in $(fgrep -v [ $TMP_DIR/files.list); do
- [ -e "$root$i" ] || continue
- [ -d "$root$i" ] && continue
- echo "- $i"
- check=true
- done ;
- $check && \
- for i in *; do
- [ "$i" == "$PACKAGE" ] && continue
- [ -s "$i/files.list" ] || continue
- awk "{ printf \"$i %s\\n\",\$1 }" < "$i/files.list"
- done;
- } | awk '
- {
- if ($1 == "-" || file[$2] != "") {
- file[$2] = file[$2] " " $1
- if ($1 != "-") {
- if (pkg[$1] == "") all = all " " $1
- pkg[$1] = pkg[$1] " " $2
- }
- }
- }
- END {
- for (i = split(all, p, " "); i > 0; i--)
- for (j = split(pkg[p[i]], f, " "); j > 0; j--)
- printf "%s %s\n",p[i],f[j];
- }
- ' | while read dir file; do
- if grep -qs "^$dir$" "$PACKAGE/modifiers"; then
- rm "$TMP_DIR/$file" 2>/dev/null
- continue
- fi
- grep -qs "^$PACKAGE$" "$dir/modifiers" && continue
- if [ -s "$dir/volatile.cpio.gz" ]; then
- zcat "$dir/volatile.cpio.gz" | cpio -t --quiet | \
- grep -q "^${file#/}$" && continue
- fi
- echo "$PACKAGE">> "$dir/modifiers"
- done
- status
- cd "$TMP_DIR"
- for file in receipt files.list description.txt $CHECKSUM; do
- [ -f "$file" ] && cp "$file" "$INSTALLED/$PACKAGE"
- done
- call_pre_install "$INSTALLED/$PACKAGE/receipt"
- if [ -n "$CONFIG_FILES" ]; then
- action 'Saving configuration files...'
- debug "\n"
- cd fs
- local config_file
- for config_file in $CONFIG_FILES; do
- debug " config_file: '$config_file'"
- find ${config_file#/} -type f 2>/dev/null
- done | cpio -o -H newc --quiet | gzip -9 > "$INSTALLED/$PACKAGE/volatile.cpio.gz"
- cd ..
- if [ -z "$newconf" ]; then
- debug " no '--newconf': clean official config files"
- for config_file in $CONFIG_FILES; do
- for config_file_official in $(find "fs$config_file" ! -type d 2>/dev/null | sed 's|^fs||'); do
- if [ -e "$root$config_file_official" ]; then
- debug " official '$config_file_official' will be skipped"
- rm "fs$config_file_official"
- else
- debug " official '$config_file_official' will be written"
- fi
- done
- done
- fi
- :; status
- fi
- if [ -n "$(ls fs/* 2>/dev/null)" ]; then
- action 'Installing package...'
- debug '\n resolving destination links in source'
- IFS=$'\n'
- for dir in $(find fs -type d | sed 's|^fs||;/^$/d'); do
- if ldir=$(readlink -n $root$dir); then
- debug " * mv 'fs$dir'\n -> 'fs${dir%/*}/$ldir'"
- mkdir -p "fs${dir%/*}/${ldir%/*}"
- mv "fs$dir" "fs${dir%/*}/$ldir"
- fi
- done
- unset IFS
- debug ' copying folders and files to destination'
- cp -af fs/* "$root/"
- status
- fi
- if [ -s files2remove.list ]; then
- action 'Removing old files...'
- while read file; do
- dir="$root$file"
- rm -f "$dir"
- while [ "$dir" != "$root/" ]; do
- dir=$(dirname "$dir")
- rmdir "$dir" 2>/dev/null || break
- done
- done < files2remove.list
- :; status
- fi
- action "Removing all tmp files..."
- cd ..; rm -rf "$TMP_DIR"
- status
- call_post_install "$INSTALLED/$PACKAGE/receipt"
- local fl="$INSTALLED/$PACKAGE/files.list" upd=0 udesk umime uicon uschm ukrnl ukrnlfs
- fgrep /usr/share/applications/ "$fl" | fgrep -q .desktop && udesk='yes'
- fgrep -q /usr/share/mime "$fl" && umime='yes'
- fgrep -q /usr/share/icon/hicolor "$fl" && uicon='yes'
- fgrep /usr/share/glib-2.0/schemas "$fl" | fgrep -q .xml && uschm='yes'
- fgrep /usr/lib/gdk-pixbuf "$fl" | fgrep -q .so && upixb='yes'
- if fgrep -q /lib/modules "$fl"; then
- ukrnl='yes'
- if fgrep -q /kernel/fs/ "$fl"; then
- ukrnlfs='yes'
- fi
- fi
- if [ -n "$udesk$umime$uicon$uschm$upixb$ukrnl" ]; then
- action 'Update system databases...'
- upd=1
- fi
- [ -n "$udesk" ] && chroot "$root/" /usr/bin/update-desktop-database /usr/share/applications 2>/dev/null
- [ -n "$umime" ] && chroot "$root/" /usr/bin/update-mime-database /usr/share/mime
- [ -n "$uicon" ] && chroot "$root/" /usr/bin/gtk-update-icon-cache /usr/share/icons/hicolor
- [ -n "$uschm" ] && chroot "$root/" /usr/bin/glib-compile-schemas /usr/share/glib-2.0/schemas 2>&1 | fgrep -v '/apps/'
- [ -n "$upixb" ] && chroot "$root/" /usr/bin/gdk-pixbuf-query-loaders --update-cache
- if [ -n "$ukrnlfs" ]; then
- for i in $(awk -F/ '{if($6=="fs" && $8~$7)print $7}' "$fl" | sort -u); do
- touch "$root/etc/filesystems"
- grep -q "^$i\$" "$root/etc/filesystems" || echo "$i">> "$root/etc/filesystems"
- done
- fi
- [ -n "$ukrnl" ] && grep '/lib/modules' "$fl" | cut -d'/' -f4 | uniq | xargs chroot "$root/" /sbin/depmod -a
- [ "$upd" -eq 1 ] && status
- SIZES=$(echo $PACKED_SIZE $UNPACKED_SIZE | sed 's|\.0||g')
- DEPENDS=$(echo $DEPENDS)
- PKG_SUM="$(fgrep " $PACKAGE-$VERSION$EXTRAVERSION.tazpkg" "$PKGS_DB/installed.$SUM" | cut -d' ' -f1)"
- ii="$PKGS_DB/installed.info"
- sed -i "/^$PACKAGE /d" "$ii"
- cat >> "$ii" <<EOT
- $PACKAGE $VERSION$EXTRAVERSION $CATEGORY $SHORT_DESC $WEB_SITE $TAGS $SIZES $DEPENDS $PKG_SUM
- EOT
- TEMP_FILE="$(mktemp)"
- sort "$ii"> "$TEMP_FILE"; mv -f "$TEMP_FILE" "$ii"; chmod a+r "$ii"; unset ii
- cd "$CUR_DIR"
- footer "$(_ 'Package "%s" (%s) is installed.' "$PACKAGE" "$VERSION$EXTRAVERSION")"
- log_pkg Installed
- [ -s "$UP_LIST" ] && sed -i "/^$PACKAGE\$/d" "$UP_LIST"
- }
Add Comment
Please, Sign In to add comment