s243a

update_system_databases.sh

Mar 31st, 2019
490
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.91 KB | None | 0 0
  1. #!/bin/bash
  2. curdir=`realpath $(pwd)/../..`
  3. prefix="/64"
  4. xinteractive=0
  5. update_icon_caches_fd_path=/tmp/make-tazpup/functions/fd/ #11 for the file descriptor
  6. update_system_database_cleanup(){
  7.   if [ -f "$update_icon_caches_fd_path" ]; then
  8.     exec 11>&-
  9.   fi
  10.   if [ $unmount_when_finished -eq 1 ]; then
  11.     umount -l $curdir/slitaz-rootfs$prefix/dev 2>/dev/null
  12.     umount -l $curdir/slitaz-rootfs$prefix/sys 
  13.     umount -l $curdir/slitaz-rootfs$prefix/proc
  14.   fi
  15. }
  16. update_icon_caches(){
  17.    trap update_system_database_cleanup EXIT SIGKILL SIGTERM
  18.    mkdir -p "$update_icon_caches_fd_path"
  19.    exec 11<> "$update_icon_caches_fd_path"/fd_11
  20.    while IFS=$'\0' read  -r -d $'\0' -u11 theme_index_path_prefixed ; do
  21.      theme_index_path=`dirname "${theme_index_path_prefixed#$curdir/slitaz-rootfs$prefix}"`
  22.      chroot "$curdir/slitaz-rootfs$prefix/" /usr/bin/gtk-update-icon-cache "$theme_index_path"
  23.    done 11< <( find "$curdir/slitaz-rootfs$prefix/" -type f -name 'index.theme' -print0 ) #https://blog.famzah.net/2016/10/20/bash-process-null-terminated-results-piped-from-external-commands/
  24.       exec 11>&-
  25. }
  26. update_system_databases(){
  27.   echo "Updating system database..."
  28.   chroot "$curdir/slitaz-rootfs$prefix/" update-ca-certificates
  29.   chroot "$curdir/slitaz-rootfs$prefix/" tazpkg recharge
  30.   chroot "$curdir/slitaz-rootfs$prefix/" /usr/bin/update-desktop-database /usr/share/applications
  31.   chroot "$curdir/slitaz-rootfs$prefix/" /usr/bin/update-mime-database /usr/share/mime
  32.  
  33.   update_icon_caches #Replaces: chroot "$curdir/slitaz-rootfs$prefix/" /usr/bin/gtk-update-icon-cache /usr/share/icons/hicolor
  34.  
  35.   chroot "$curdir/slitaz-rootfs$prefix/" /usr/bin/glib-compile-schemas /usr/share/glib-2.0/schemas
  36.   chroot "$curdir/slitaz-rootfs$prefix/" /usr/bin/gdk-pixbuf-query-loaders --update-cache
  37.   chroot "$curdir/slitaz-rootfs$prefix/" /usr/bin/gio-querymodules /usr/lib/gio/modules
  38.   chroot "$curdir/slitaz-rootfs$prefix/" /usr/bin/fc-cache -f
  39. }
  40.  
  41. if mountpoint -q $curdir/slitaz-rootfs$prefix/proc; then
  42.   echo "/proc is a mount point"
  43.   unmount_when_finished=1
  44. elif mountpoint -q $curdir/slitaz-rootfs$prefix/sys; then
  45.   echo "/sys is a mount point"
  46.   unmount_when_finished=1
  47. elif mountpoint -q $curdir/slitaz-rootfs$prefix/dev; then
  48.   echo "/dev is a mount point"
  49.   unmount_when_finished=1
  50. else
  51.   unmount_when_finished=0
  52. fi
  53. if [ ! -z $prefix ]; then
  54.  
  55.   mount -o rbind /proc $curdir/slitaz-rootfs$prefix/proc #We might want to do these minds earlier
  56.   mount -t sysfs none $curdir/slitaz-rootfs$prefix/sys
  57.   if [ $xinteractive -eq 1 ]; then
  58.     echo "Removing block device files..."
  59.     rm -rf $curdir/slitaz-rootfs$prefix/dev/* #Maybe we want to rename rather than delete these
  60.     #mount bind -t devtmpfs none $curdir/slitaz-rootfs/dev
  61.     mount -o rbind /dev $curdir/slitaz-rootfs$prefix/dev
  62.     cp -f /etc/resolv.conf $curdir/slitaz-rootfs$prefix/etc/resolv.conf
  63.   fi
  64. fi
  65.  
  66. update_system_databases
Advertisement
Add Comment
Please, Sign In to add comment