Advertisement
s243a

update_system_databases.sh

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