s243a

make-tazpup_functions.sh

Mar 31st, 2019
462
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 32.61 KB | None | 0 0
  1. #unmount_vfs(){
  2. # umount -l $curdir/slitaz-rootfs/dev 2>/dev/null
  3. # umount -l $curdir/slitaz-rootfs/sys 2>/dev/null
  4. # umount -l $curdir/slitaz-rootfs/proc 2>/dev/null
  5. # if [ ! -z "$prefix" ]; then
  6. #   umount -l $curdir/slitaz-rootfs$prefix/dev 2>/dev/null
  7. #   umount -l $curdir/slitaz-rootfs$prefix/sys 2>/dev/null
  8. #   umount -l $curdir/slitaz-rootfs$prefix/proc 2>/dev/null
  9. # fi
  10. # umount /mnt/wktaz 2>/dev/null
  11. # umount /mnt/wksfs 2>/dev/null
  12. #
  13. #}
  14. unmount_rootfs_binds(){
  15.     if [ "$(mount | grep "$curdir/slitaz-rootfs/dev")" != "" ]; then
  16.       umount -l $curdir/slitaz-rootfs/dev
  17.     fi 
  18.  
  19.     if [ "$(mount | grep "$curdir/slitaz-rootfs/sys")" != "" ]; then
  20.       umount -l $curdir/slitaz-rootfs/sys
  21.     fi 
  22.     if [ "$(mount | grep "$curdir/slitaz-rootfs/proc")" != "" ]; then
  23.       umount -l $curdir/slitaz-rootfs/proc
  24.     fi
  25.     if [ ! -z "$prefix" ] && [ ! -f $curdir/slitaz-rootfs$prefix ]; then
  26.        if [ "$(mount | grep "$curdir/slitaz-rootfs/dev")" != "" ]; then
  27.           umount -l $curdir/slitaz-rootfs$prefix/dev
  28.        fi  
  29.  
  30.       if [ "$(mount | grep "$curdir/slitaz-rootfs/sys")" != "" ]; then
  31.         umount -l $curdir/slitaz-rootfs$prefix/sys
  32.       fi   
  33.       if [ "$(mount | grep "$curdir/slitaz-rootfs/proc")" != "" ]; then
  34.         umount -l $curdir/slitaz-rootfs$prefix/proc
  35.       fi
  36.     fi
  37. }
  38. unmount_vfs(){
  39.  unmount_rootfs_binds
  40.  umount /mnt/wktaz 2>/dev/null
  41.  umount /mnt/wksfs 2>/dev/null
  42.  exec 11>&-
  43.  exec 12>&- #Used in: install_pkgs_fm_dir
  44. }  
  45.  
  46. unmount_vfs(){
  47.  unmount_rootfs_binds
  48.  umount /mnt/wktaz 2>/dev/null
  49.  umount /mnt/wksfs 2>/dev/null
  50.  
  51. }    
  52. clean_up(){
  53.        
  54.   if [ -d $curdir/slitaz-rootfs ]; then
  55.  
  56.     if [ "$(mount | grep "$curdir/slitaz-rootfs/dev")" != "" ]; then
  57.       umount -l $curdir/slitaz-rootfs/dev
  58.     fi 
  59.  
  60.     if [ "$(mount | grep "$curdir/slitaz-rootfs/sys")" != "" ]; then
  61.       umount -l $curdir/slitaz-rootfs/sys
  62.     fi 
  63.     if [ "$(mount | grep "$curdir/slitaz-rootfs/proc")" != "" ]; then
  64.       umount -l $curdir/slitaz-rootfs/proc
  65.     fi
  66.  
  67.     echo "Deleting slitaz-rootfs..."
  68.     rm -rf $curdir/slitaz-rootfs
  69.   fi
  70.  
  71.   if [ -d $curdir/tazpup-preiso ]; then
  72.     echo "Deleting tazpup-preiso..."
  73.     rm -rf $curdir/tazpup-preiso
  74.   fi
  75.  
  76.   if [ -d $curdir/kernel-modules ]; then
  77.     echo "Deleting kernel-modules..."
  78.     rm -rf $curdir/kernel-modules
  79.   fi
  80.  
  81.   if [ -d $curdir/slitaz-dload ]; then
  82.     echo "Deleting slitaz-dload..."
  83.     rm -rf $curdir/slitaz-dload
  84.   fi
  85.  
  86.   if [ -d $curdir/tazpup-core-files/slitaz-packages-fs ]; then
  87.     echo "Deleting slitaz-packages-fs..."
  88.     rm -rf $curdir/tazpup-core-files/slitaz-packages-fs
  89.   fi
  90.  
  91.   if [ -f $curdir/slitaz-rolling-core.iso ]; then
  92.     echo "Deleting slitaz-rolling-core.iso..."
  93.     rm -f $curdir/slitaz-rolling-core.iso
  94.   fi
  95.  
  96.   rm -f $curdir/tazpup-core-files/installed-isolated.md5
  97.   rm -f $curdir/tazpup-core-files/installed-isolated.info
  98.  
  99.   rm -f $curdir/package-deps.txt
  100.   rm -f $curdir/package-listed
  101.  
  102.   if [ -f $curdir/custom-tazpup.iso ]; then
  103.     echo "Deleting custom-tazpup.iso..."
  104.     rm -f $curdir/custom-tazpup.iso
  105.   fi
  106.  
  107.   if [ -f $curdir/custom-tazpup.iso.md5 ]; then
  108.     echo "Deleting custom-tazpup.iso.md5..."
  109.     rm -f $curdir/custom-tazpup.iso.md5
  110.   fi
  111.  
  112.   if [ -d $curdir/slitaz-livecd-wkg ]; then
  113.     rm -rf $curdir/slitaz-livecd-wkg
  114.   fi
  115.  
  116.    
  117. }
  118. clean_up_some(){
  119.        
  120.   if [ -d $curdir/slitaz-rootfs ]; then
  121.  
  122.     if [ "$(mount | grep "$curdir/slitaz-rootfs/dev")" != "" ]; then
  123.       umount -l $curdir/slitaz-rootfs/dev
  124.     fi 
  125.  
  126.     if [ "$(mount | grep "$curdir/slitaz-rootfs/sys")" != "" ]; then
  127.       umount -l $curdir/slitaz-rootfs/sys
  128.     fi 
  129.     if [ "$(mount | grep "$curdir/slitaz-rootfs/proc")" != "" ]; then
  130.       umount -l $curdir/slitaz-rootfs/proc
  131.     fi
  132.  
  133.     echo "Deleting slitaz-rootfs..."
  134.     rm -rf $curdir/slitaz-rootfs
  135.   fi
  136.  
  137.   if [ -d $curdir/tazpup-preiso ]; then
  138.     echo "Deleting tazpup-preiso..."
  139.     rm -rf $curdir/tazpup-preiso
  140.   fi
  141.  
  142.   if [ -d $curdir/kernel-modules ]; then
  143.     echo "Deleting kernel-modules..."
  144.     rm -rf $curdir/kernel-modules
  145.   fi
  146.  
  147.   if [ -d $curdir/slitaz-dload ]; then
  148.     echo "Deleting slitaz-dload..."
  149.     rm -rf $curdir/slitaz-dload
  150.   fi
  151.  
  152.   if [ -d $curdir/tazpup-core-files/slitaz-packages-fs ]; then
  153.     echo "Deleting slitaz-packages-fs..."
  154.     rm -rf $curdir/tazpup-core-files/slitaz-packages-fs
  155.   fi
  156.  
  157.   rm -f $curdir/tazpup-core-files/installed-isolated.md5
  158.   rm -f $curdir/tazpup-core-files/installed-isolated.info
  159.  
  160.   rm -f $curdir/package-deps.txt
  161.   rm -f $curdir/package-listed
  162.  
  163.   if [ -f $curdir/custom-tazpup.iso ]; then
  164.     echo "Deleting custom-tazpup.iso..."
  165.     rm -f $curdir/custom-tazpup.iso
  166.   fi
  167.  
  168.   if [ -f $curdir/custom-tazpup.iso.md5 ]; then
  169.     echo "Deleting custom-tazpup.iso.md5..."
  170.     rm -f $curdir/custom-tazpup.iso.md5
  171.   fi
  172.  
  173.   if [ -d $curdir/slitaz-livecd-wkg ]; then
  174.     rm -rf $curdir/slitaz-livecd-wkg
  175.   fi
  176.  
  177.    
  178. }
  179.  
  180.  
  181. sandbox_pkg(){
  182.  
  183.   cmd="$1"
  184.   pkg="$2"
  185.   bname="$(basename $pkg)"
  186.  
  187.   if [ ! -d $curdir/tazpup-core-files/slitaz-sandbox ]; then
  188.     mkdir -p $curdir/tazpup-core-files/slitaz-sandbox 2> /dev/null
  189.   fi
  190.  
  191.   cp -f $pkg $curdir/tazpup-core-files/slitaz-packages-fs/$bname
  192.  
  193.   mount -t aufs -o udba=reval,diropq=w,dirs=$curdir/tazpup-core-files/slitaz-packages-fs=rw:$curdir/slitaz-rootfs=ro unionfs $curdir/tazpup-core-files/slitaz-sandbox
  194.  
  195.   if [ "$cmd" == "install" ]; then
  196.     xcmd="tazpkg install /$bname --forced"
  197.   elif [ "$cmd" == "remove" ]; then
  198.    xcmd="tazpkg remove $pkg"
  199.   fi
  200.  
  201.   chroot $curdir/tazpup-core-files/slitaz-sandbox/ $xcmd
  202.   umount -l $curdir/tazpup-core-files/slitaz-sandbox
  203.  
  204.   rm -f $curdir/tazpup-core-files/slitaz-packages-fs/$bname
  205.    
  206. }
  207. install_pkg(){
  208.  
  209.   pkg="$1"
  210.   opt_in="$2"
  211.   options=${opt_in:-'--local'} #In some cases might want to use options like --forced --newconf --nodeps of --local
  212.   echo "installing $1"
  213.   echo "options=$options"
  214.   bname="$(basename $pkg)"
  215.  
  216.   #Direct errors to null because it should already exist in destination folder.    
  217.   cp $pkg $curdir/slitaz-rootfs$prefix/pkgs/$bname 2> /dev/null #We'll copy everything into $curdir/slitaz-rootfs/pkgs before installig anything.
  218.  
  219.   echo "#!/bin/sh
  220. cd $prefix/pkgs
  221. tazpkg $options install $bname --root=$prefix
  222. " > $curdir/slitaz-rootfs$prefix/pkgs/start.sh #$curdir/slitaz-rootfs/start.sh
  223.  
  224.   chmod +x $curdir/slitaz-rootfs$prefix/pkgs/start.sh
  225.   chroot $curdir/slitaz-rootfs/ $prefix/pkgs/start.sh #Consider chrooting into the prefix folder once enough packages are installed
  226.   #read -p "Press enter to continue" #added by s243a
  227.   rm -f $curdir/slitaz-rootfs$prefix/pkgs/$bname
  228.   rm -f $curdir/slitaz-rootfs$prefix/pkgs/start.sh     
  229.   post_inst_fixes $pkg
  230. }
  231. determine_mode_than_install_packages(){
  232.   source_folder_or_file=${1:-slitaz-packages}
  233.   if [ ! "${source_folder:0:1}" == "/" ]; then
  234.     source_folder=$curdir/$source_folder
  235.   fi
  236.  
  237.   if [ "$xmode" == "local" ]; then
  238.     install_local_pkg $source_folder_or_file
  239.   else
  240.    install_online_pkg $source_folder_or_file
  241.   fi
  242. }
  243. get_folder_description(){
  244.    
  245.   case `dirname $1` in
  246.     slitaz-packages)
  247.       folder_description="slitaz package"; ;; #These were orginally called core packages
  248.     pet-packages)  
  249.       folder_description="pet package"; ;; #Recommend using the converted alien's folder instead
  250.     slitaz-dependencies)
  251.       folder_description="slitaz dependency"; ;;  #This folder isn't typically instended for direct installation
  252.     slitaz-base)
  253.       folder_description="slitaz base package"; ;;  #This folder is typically used in place of the live slitaz CD
  254.     slitaz-post-patch-packages)
  255.       folder_description="slitaz post patch packages"; ;;  #Normally we don't need this folder
  256.     slitaz-preinst-pkg)
  257.       folder_description="slitaz pre-install package"; ;;  #Normally we don't need this folder
  258.     *)
  259.       folder_description="package"; ;;  #Normally we don't need this folder  
  260.   esac    
  261. }
  262. do_folder_missing_action(){
  263.   case `dirname $1` in
  264.     slitaz-packages)
  265.       pkg_type="slitaz package"; ;; #These were orginally called core packages
  266.     pet-packages)
  267.       pkg_type="pet package"; ;; #Recommend using the converted alien's folder instead
  268.     slitaz-dependencies)
  269.       echo 'the folder slitaz-dependencies is empty'; ;;
  270.     slitaz-base)
  271.        echo 'the folder slitaz-base is empty'; ;;  
  272.     slitaz-post-patch-packages)  
  273.        echo 'the folder slitaz-post-patch-packages is empty'; ;;  
  274.     slitaz-preinst-pkg)
  275.        echo 'the folder slitaz-preinst-pkg is empty'; ;;  
  276.     *)
  277.        echo 'the folder $1 is empty'; ;;    
  278.   esac      
  279. }
  280. install_local_pkgs(){ #s243a: added "s" to the function name
  281.    
  282.   if [ $# -eq 0 ]; then
  283.     set "$slitaz_packages_dir" "$special_packages_dir"
  284.   fi   
  285.    
  286.   for aDir in "$@"; do
  287.  
  288.     if [ ! "${aDir:0:1}" == "/" ]; then
  289.       fullpath_aDir=$curdir/$aDir
  290.     else
  291.       fullpath_aDir=$aDir
  292.     fi #TODO consider adding a case if the path starts with a "."
  293.     #assigns folder_description
  294.     get_folder_description #This is use din the echo statment to say what packages we are installing (or are missing)
  295.     if [ $(find $fullpath_aDir -type f -name "*.tazpkg" | wc -l) -eq 0 ]; then
  296.       echo "$folder_description is missing."
  297.       continue
  298.       #read -p "Press enter to continue" #TODO add some exit or paus e logic
  299.     fi
  300.     for pkg in $(find $fullpath_aDir -type f -name "*.tazpkg" | sort -r)
  301.     do
  302.       echo "Processing $folder_description: $(basename $pkg)"
  303.       install_pkg "$pkg"
  304.       post_inst_fixes $pkg
  305.     done
  306.   done
  307.    
  308. }
  309. get_install_pkg(){
  310.  
  311.   pkg="$1"
  312.  
  313.   echo "#!/bin/sh
  314. cd $prefix/pkgs
  315. tazpkg get-install $pkg
  316. " > $curdir/slitaz-rootfs$prefix/pkgs/start.sh #$curdir/slitaz-rootfs/start.sh
  317.  
  318.   chmod +x $curdir/slitaz-rootfs$prefix/pkgs/start.sh
  319.   #read -p "Press enter to continue"
  320.   chroot $curdir/slitaz-rootfs $prefix/pkgs/start.sh
  321.   rm -f $curdir/slitaz-rootfs$prefix/pkgs/start.sh     
  322.   post_inst_fixes $pkg
  323. }
  324.  
  325. install_online_pkg(){
  326.   if [ ! -f  $curdir/package-cloud.txt ]; then
  327.     echo "Package list is missing."
  328.     exit
  329.   else
  330.  
  331.     if [ $(find $curdir/special-packages -type f -name "*.tazpkg" | wc -l) -eq 0 ]; then
  332.       echo "Special tazpup package is missing."
  333.       exit
  334.     fi
  335.  
  336.     for pkg in $(cat $curdir/package-cloud.txt | tr '\n' ' ')
  337.     do
  338.       echo "Processing core package: $(basename $pkg)"
  339.       get_install_pkg "$pkg"
  340.     done
  341.    
  342.     for pkg in $(find $curdir/special-packages -type f -name "*.tazpkg" | sort -r)
  343.     do
  344.       echo "Processing special package: $(basename $pkg)"
  345.       install_pkg "$pkg"
  346.       post_inst_fixes $pkg
  347.     done
  348.      
  349. fi 
  350. }
  351.  
  352.  
  353. install_pet_pkg(){
  354. # source $curdir/make-tazpup_functions.sh
  355.  
  356.   pkg="$1"
  357.   bname="$(basename $pkg)"
  358.    
  359.   cp -a -u $pkg $curdir/slitaz-rootfs/$bname
  360.  
  361.   if [ $xforced -eq 1 ]; then
  362.     line="tazpet /$bname --forced"
  363.   else
  364.     line="tazpet /$bname"
  365.   fi
  366.  
  367.   echo "#!/bin/sh
  368. $line
  369. " > $curdir/slitaz-rootfs/start.sh #TODO add a check to first see if we are mounted and if not mount the requisit folders
  370.  
  371.   chmod +x $curdir/slitaz-rootfs/start.sh
  372.   chroot $curdir/slitaz-rootfs/ /start.sh
  373.   rm -f $curdir/slitaz-rootfs/$bname
  374.   rm -f $curdir/slitaz-rootfs/st# source $curdir/make-tazpup_functions.sh
  375. art.sh     
  376.  
  377. }
  378. add_locks_and_blockFiles(){
  379.   if [ "$xmode" == "local" ]; then
  380.     touch $curdir/slitaz-rootfs$prefix/var/lib/tazpkg/locked-packages
  381.     touch $curdir/slitaz-rootfs$prefix/tmp/tazpkg-local.lock
  382.     touch $curdir/slitaz-rootfs$prefix/tmp/tazpkg-skipdep.lock
  383.     touch $curdir/slitaz-rootfs$prefix/tmp/tazpkg-skipremovedep.lock
  384.     touch $curdir/slitaz-rootfs$prefix/tmp/tazpkg-dontbreak.lock
  385.     touch $curdir/slitaz-rootfs$prefix/tmp/tazpkg-skipupdate.lock
  386.     touch $curdir/slitaz-rootfs$prefix/tmp/tazpkg-editreceipt.lock
  387.     touch $curdir/slitaz-rootfs$prefix/tmp/tazpkg-autoconfirm.lock
  388.     touch $curdir/slitaz-rootfs$prefix/tmp/tazpkg-skiprefresh.lock
  389. else
  390.     touch $curdir/slitaz-rootfs$prefix/tmp/tazpkg-dontbreak.lock
  391.     touch $curdir/slitaz-rootfs$prefix/tmp/tazpkg-skipremovedep.lock
  392.     touch $curdir/slitaz-rootfs$prefix/tmp/tazpkg-skipupdate.lock
  393.     touch $curdir/slitaz-rootfs$prefix/tmp/tazpkg-editreceipt.lock
  394.     touch $curdir/slitaz-rootfs$prefix/tmp/tazpkg-autoconfirm.lock
  395.     touch $curdir/slitaz-rootfs$prefix/tmp/tazpkg-skiprefresh.lock
  396.     cp -f $curdir/tazpup-core-files/slitaz/var/lib/tazpkg/blocked-packages.list $curdir/slitaz-rootfs$prefix/var/lib/tazpkg/blocked-packages.list
  397.     cp -f $curdir/tazpup-core-files/slitaz/var/lib/tazpkg/locked-packages $curdir/slitaz-rootfs$prefix /var/lib/tazpkg/locked-packages
  398. fi
  399. }
  400.  
  401. make_pupcore(){
  402.  
  403.   mkdir -p $curdir/slitaz-rootfs$prefix/usr/share/pupcore 2> /dev/null
  404.   cp -f $curdir/tazpup-core-files/puppy/bin/ps $curdir/slitaz-rootfs$prefix/usr/share/pupcore/ps.bak
  405.   cp -f $curdir/tazpup-core-files/puppy/sbin/init $curdir/slitaz-rootfs$prefix/usr/share/pupcore/init.bak
  406.   cp -f $curdir/tazpup-core-files/puppy/sbin/losetup $curdir/slitaz-rootfs$prefix/usr/share/pupcore/losetup.bak
  407.  
  408.   cp -f $curdir/tazpup-core-files/slitaz/bin/gnome-alsamixer $curdir/slitaz-rootfs$prefix/usr/share/pupcore/gnome-alsamixer.bak
  409.   cp -f $curdir/tazpup-core-files/slitaz/etc/inittab $curdir/slitaz-rootfs$prefix/usr/share/pupcore/inittab.bak
  410.   cp -f $curdir/tazpup-core-files/slitaz/etc/init.d/daemon $curdir/slitaz-rootfs$prefix/usr/share/pupcore/daemon.bak
  411.   cp -f $curdir/tazpup-core-files/slitaz/etc/init.d/bootopts.sh $curdir/slitaz-rootfs$prefix/usr/share/pupcore/bootopts.sh.bak
  412.    
  413. }
  414.  
  415. remove_some_slitaz(){
  416.  
  417. if [ -z $prefix ]; then #TODO ad or case for when we want to enter this if block but the prefix exists
  418.   rm -rf $curdir/slitaz-rootfs$prefix/lib/modules/*
  419.  
  420.   for pkg2 in $(ls -1 $curdir/slitaz-rootfs/var/lib/tazpkg/installed/ | grep -E "^linux" | tr '\n' ' ')
  421.   do
  422.     chroot $curdir/slitaz-rootfs$prefix tazpkg remove $pkg2
  423.   done
  424.  
  425.   for pkg2 in $(ls -1 $curdir/slitaz-rootfs/var/lib/tazpkg/installed/ | grep -E "^firmware-" | tr '\n' ' ')
  426.   do
  427.     chroot $curdir/slitaz-rootfs$prefix tazpkg remove $pkg2
  428.   done
  429.  
  430.   if [ -f $curdir/remove-builtin.txt ]; then
  431.     for pkg2 in $(cat $curdir/remove-builtin.txt)
  432.     do
  433.      chroot $curdir/slitaz-rootfs$prefix tazpkg remove $pkg2
  434.     done
  435.   fi
  436. fi
  437. rm -f $curdir/slitaz-rootfs/etc/dialogrc
  438.  
  439. }
  440.  
  441. extractfs() {
  442.   one=$1
  443.   #$prefix2=${one:-""} #If we have a prefix it is usually empty but in theory
  444.   if [ ! -d $curdir/slitaz-rootfs ]; then
  445.     mkdir $curdir/slitaz-rootfs
  446.   fi
  447.  
  448.   (busybox unlzma -c $1 || cat $1 ) 2>/dev/null | (cd $curdir/slitaz-rootfs; busybox cpio -idmu > /dev/null)
  449.  
  450. }
  451.  
  452. #extractfs_prefix is not used yet. It will be be used if one want to use a seperate iso for the build than the build system
  453. extractfs_prefix() { #TODO use options to combine this with the above function
  454.   #one=$1 #TODO allow prefix2 to be defined as an ninput argument
  455.   #$prefix2=${one:-""} #If we have a prefix it is usually empty but in theory
  456.   if [ ! -d $curdir/slitaz-rootfs$prefix ]; then
  457.     mkdir $curdir/slitaz-rootfs$prefix
  458.   fi
  459.  
  460.   (busybox unlzma -c $1 || cat $1 ) 2>/dev/null | (cd $curdir/slitaz-rootfs$prefix2; busybox cpio -idmu > /dev/null)
  461.  
  462. }
  463.  
  464. select_local(){
  465.   if [ -z "*IMG" ]; then   
  466.     IMG="$(Xdialog --stdout --title "$LABEL1 Select Slitaz image file" --fselect $HOME 0 0)"
  467.  
  468.     if [ $? -ne 0 ]; then
  469.       echo "Operation cancelled"
  470.     exit
  471.     fi
  472.  
  473.     if [ "$IMG" == "" ]; then
  474.       echo "No image file selected"
  475.       exit
  476.     fi
  477.   fi
  478. }
  479.  
  480.  
  481. download_iso(){
  482.    
  483.   wget -4 -t 2 -T 20 --waitretry=20 --spider -S "$WEBSITE/$LIVECD"  
  484.  
  485.   if [ $? -ne 0 ]; then
  486.     echo "Failed to reach $WEBSITE"
  487.     exit
  488.   fi
  489.  
  490.   wget "$WEBSITE/$LIVECD" -O $curdir/$LIVECD
  491.  
  492.   if [ $? -ne 0 ]; then
  493.     echo "Downloading Slitaz live cd failed"
  494.     rm -f $curdir/$LIVECD
  495.     exit
  496.   fi
  497.  
  498.   IMG="$curdir/$LIVECD"
  499. }
  500. select_build_mode(){
  501.   if [ -z "$xmode" ]; then
  502.     Xdialog --title "TazPuppy Builder" --ok-label "LOCAL" --cancel-label "ONLINE" --yesno "Select mode for building TazPuppy\n\nLOCAL - Build TazPuppy offline using collection of files and packages\nONLINE - Build TazPuppy using slitaz repo. Internet connection required\n\nNOTE: Both modes requires Puppy ISO file" 0 0
  503.     retval3=$?# source $curdir/make-tazpup_functions.sh
  504.  
  505.  
  506.     if [ $retval3 -eq 255 ]; then
  507.       echo "Operation cancelled"
  508.       exit
  509.     fi
  510.  
  511.     if [ $retval3 -eq 0 ]; then
  512.       LABEL1="Local Build:"
  513.       xmode="local"
  514.       select_local
  515.     elif [ $retval3 -eq 1 ]; then
  516.       LABEL1="Online Build:"
  517.      xmode="online"
  518.     fi
  519.   fi
  520.  }
  521.  
  522.  
  523. select_interact_mode(){
  524.   if [ -z "$xinteractive" ]; then  
  525.     Xdialog --title "TazPuppy Builder" --ok-label "Yes" --cancel-label "No" --yesno "Allow the post install script packages to interact?" 0 0
  526.     retval3=$?
  527.  
  528.     if [ $retval3 -eq 255 ]; then
  529.       xinteractive=0
  530.       exit
  531.     fi
  532.  
  533.     if [ $retval3 -eq 0 ]; then
  534.       xinteractive=1
  535.       else
  536.       xinteractive=0
  537.     fi
  538.   fi
  539. }
  540. select_force_custom(){
  541.   if [ -z "$xforced" ]; then
  542.     Xdialog --title "TazPuppy Builder" --ok-label "Yes" --cancel-label "No" --yesno "Force install custom pet package?" 0 0
  543.     retval3=$?
  544.  
  545.     if [ $retval3 -eq 0 ]; then
  546.       xforced=1
  547.     else
  548.       xforced=0
  549.     fi
  550.   fi
  551. }
  552. select_copy_tazpkg_in_build_env(){
  553.   if [ -z "$cpytaz" ]; then
  554.     Xdialog --title "TazPuppy Builder" \
  555.             --ok-label "Yes" \
  556.             --cancel-label "No" \
  557.             --yesno \
  558. "Copy tazpkg into the build system? This is not necessary if included in build ISO (i.e. SliTaz iso)" \
  559. 0 0
  560.  
  561.     retval3=$?
  562.  
  563.     if [ $retval3 -eq 0 ]; then
  564.       cpytaz=1
  565.     else
  566.       cpytaz=0
  567.     fi
  568.   fi   
  569. }
  570. select_copy_tazpkg_in_target_env(){
  571.   if [ -z "$cpytaz_target" ]; then
  572.     Xdialog --title "TazPuppy Builder" \
  573.             --ok-label "Yes" \
  574.             --cancel-label "No" \
  575.             --yesno \
  576. "Copy tazpkg into the target environment? This will overwrite tazpkg files if they are already installed in the target enviornment." \
  577. 0 0
  578.  
  579.     retval3=$?
  580.  
  581.     if [ $retval3 -eq 0 ]; then
  582.       cpytaz_target=1
  583.     else
  584.       cpytaz_target=0
  585.     fi 
  586.   fi
  587. }
  588. post_inst_fixes_coreutils(){
  589.   arg_1=$1
  590.   pfk_local=${arg_1:-$prefix}
  591.   if [ -f $curdir/slitaz-rootfs$prefix/var/lib/tazpkg/installed/coreutils ]; then
  592.     #TODO perhaps we don't want to do this if df-Full already exists.
  593.     echo '#!/bin/sh
  594.     exec df $@' > $curdir/slitaz-rootfs$prefix/usr/bin/df-FULL
  595.     chmod +x $curdir/slitaz-rootfs$prefix/usr/bin/df-FULL
  596.   fi
  597. }
  598. post_inst_fixes_gzip(){
  599.      if [ -f $curdir/slitaz-rootfs$prefix/var/lib/tazpkg/installed/grep ]; then    
  600.        rm -f  $curdir/slitaz-rootfs$prefix/bin/gzip
  601.      fi
  602. }
  603. post_inst_fixes_lzma(){
  604.     if [ -f $curdir/slitaz-rootfs$prefix/var/lib/tazpkg/installed/lzma ]; then
  605.       rm -f  $curdir/slitaz-rootfs$prefix/bin/lzma
  606.       rm -f  $curdir/slitaz-rootfs$prefix/bin/unlzma
  607.       rm -f  $curdir/slitaz-rootfs$prefix/bin/lzcat      
  608.     fi
  609. }
  610. post_inst_fixes_xz(){
  611.     if [ -f $curdir/slitaz-rootfs$prefix/var/lib/tazpkg/installed/xz ]; then
  612.       rpost_inst_fixes_lzma
  613.     fi
  614. }
  615. post_inst_fixes(){
  616.   arg_1=$1
  617.   #arg_2=$2
  618.   pkg_local=${arg_1:-$pkg}
  619.   pfk_local=${prefix:-$2}
  620.  
  621.   if [ -z "${pkg_local##coreutils}" ]; then
  622.     post_inst_fixes_coreutils $pfk_local
  623.   fi
  624.  
  625.   if [ -z "${pkg_local##gzip}" ]; then
  626.     post_inst_fixes_gzip $pfk_local
  627.   fi
  628.   if [ -z "${pkg_local##lzma}" ]; then #Added by s243a
  629.     post_inst_fixes_lzma $pfk_local
  630.   fi
  631.   if [ -z "${pkg_local##xz}" ]; then #Added by s243a
  632.      post_inst_fixes_xz $pfk_local
  633.   fi  
  634. }
  635. select_pup_img(){
  636.   ISO_Var_Name=${1:-IMGPUP}  
  637.   if [ -z "$1"]; then
  638.     ISO_Path=$IMGPUP
  639.   else
  640.     ISO_Path=""
  641.   fi
  642.   if [ -z "$ISO_Path" ]; then
  643.     ISO_Path="$(Xdialog --stdout --title "$LABEL1 Select Puppy image file" --fselect $HOME 0 0)"
  644.  
  645.     if [ $? -ne 0 ]; then
  646.       echo "Operation cancelled"
  647.       exit
  648.     fi
  649.  
  650.     if [ "$ISO_Path=" == "" ]; then
  651.       echo "No puppy image file selected. Press enter to continue or cntrl-c to exit"
  652.       #exit #TODO Maybe prompt people if they want to exit
  653.     fi
  654.   fi
  655.   eval "$ISO_Var_Name=$ISO_Path"
  656. }
  657.  
  658.  
  659. extract_kernal_modules(){
  660.   if [ -z "$IMGPUP" ]; then
  661.     select_pup_img
  662.   fi
  663.   echo "Mounting $(basename $IMGPUP)..."
  664.  
  665.   mount -o ro $IMGPUP /mnt/wktaz
  666.   #mount $IMGPUP /mnt/wktaz -o loop
  667.  
  668.  
  669.   if [ $? -ne 0 ]; then
  670.     echo "Mounting puppy image failed"
  671.     exit
  672.   fi
  673.  
  674.   rootfslist="$(find /mnt/wktaz -type f -name "*.sfs")"
  675.  
  676.   if [ "$rootfslist" == "" ]; then
  677.     echo "Not a puppy disc image"
  678.     umount /mnt/wktaz
  679.     exit
  680.   fi
  681.  
  682.   echo "Copying puppy kernel...."
  683.  
  684.   #cp -f /mnt/wktaz/vmlinuz $curdir/tazpup-preiso/
  685.   cp -f /mnt/wktaz/vmlinuz $curdir/tazpup-livecd-files #Target changed from tazpup-preiso to tazpup-livecd-files so that we can delete tazpup-preiso withiout woring about deleating vmlinuz
  686.  
  687.   echo "Searching for kernel modules..."
  688.  
  689.   mkdir -p $curdir/kernel-modules/lib
  690.  
  691.   for file1 in $(find /mnt/wktaz -type f -name "*.sfs")
  692.   do
  693.  
  694.   mount -t squashfs $file1 /mnt/wksfs
  695.  
  696.   if [ $? -eq 0 ]; then
  697.  
  698.     if [ -d /mnt/wksfs/lib/modules ]; then
  699.       echo "Copying kernel modules from $(basename $file1) to rootfs..."
  700.       cp -rf /mnt/wksfs/lib/modules $curdir/kernel-modules/lib/
  701.       mkdir -p $curdir/kernel-modules/var/lib/tazpkg/installed/linux   
  702.       touch $curdir/kernel-modules/var/lib/tazpkg/installed/linux/files.list
  703.    
  704. echo 'PACKAGE="linux"
  705. VERSION=""
  706. CATEGORY="misc"
  707. SHORT_DESC="Linux kernel (compiled for puppy linux)"
  708. WEB_SITE="http://puppylinux.org/"
  709. MAINTAINER="[email protected]"
  710. DEPENDS="linux-modules"
  711. ' > $curdir/kernel-modules/var/lib/tazpkg/installed/linux/receipt
  712.      
  713.      
  714.      mkdir -p $curdir/kernel-modules/var/lib/tazpkg/installed/linux-modules
  715.  
  716. echo 'PACKAGE="linux-modules"
  717. VERSION=""
  718. CATEGORY="misc"
  719. SHORT_DESC="Linux kernel modules(compiled for puppy linux)"
  720. WEB_SITE="http://puppylinux.org/"
  721. MAINTAINER="[email protected]"
  722. DEPENDS=""
  723. ' > $curdir/kernel-modules/var/lib/tazpkg/installed/linux-modules/receipt    
  724.      
  725.       xcurdir="$(echo "$curdir" | sed "s#\/#\\\/#g")"
  726.      
  727.       find $curdir/kernel-modules/lib/ -type f -name "*" | sed -e "s#$xcurdir\/kernel-modules\/lib\/#\/lib\/#g" > $curdir/kernel-modules/var/lib/tazpkg/installed/linux-modules/files.list
  728.      
  729.     fi
  730.    
  731.     if [ -d /mnt/wksfs/etc/modules ]; then
  732.       cp -rf /mnt/wksfs/etc/modules $curdir/kernel-modules/etc/
  733.     fi
  734.        
  735.     umount /mnt/wksfs
  736.   fi
  737.  
  738.   done
  739.   re_extract_kernal=0 #Added by s243a
  740.   umount /mnt/wktaz
  741. }  
  742. prepare_working_folders(){
  743.   echo "Preparing working folders..."
  744.  
  745.   if [ ! -d $curdir/slitaz-livecd-wkg ]; then
  746.     mkdir $curdir/slitaz-livecd-wkg
  747.   fi
  748.  
  749.   if [ ! -d $curdir/tazpup-preiso ]; then
  750.     mkdir $curdir/tazpup-preiso
  751.   fi
  752.  
  753.   if [ ! -d /mnt/wktaz ]; then
  754.     mkdir /mnt/wktaz
  755.   fi
  756.  
  757.   if [ ! -d /mnt/wksfs ]; then
  758.     mkdir /mnt/wksfs
  759.   fi
  760. }
  761.  
  762. select_re_extract_kernal_Modules(){
  763.   if [ ! -f $curdir/slitaz-livecd-wkg/ ]; then
  764.       re_extract_kernal=1
  765.   fi   
  766.   if [ -z "$re_extract_kernal" ]; then
  767.     Xdialog --title "TazPuppy Builder" \
  768.             --ok-label "Yes" \
  769.             --cancel-label "No" \
  770.             --yesno \
  771. "Re-extract Kernal modules?" \
  772. 0 0
  773.  
  774.     retval3=$?
  775.  
  776.     if [ $retval3 -eq 0 ]; then
  777.       re_extract_kernal=1
  778.     else
  779.       re_extract_kernal=0
  780.     fi 
  781.   fi
  782.   if [ $re_extract_kernal -eq 1 ]; then
  783.     rm $curdir/kernel-modules
  784.     mkdir -p $curdir/kernel-modules
  785.     extract_kernal_modules
  786.   fi
  787.    
  788. }
  789. select_full_clearn(){
  790.   if [ ! -z cpytaz_target ]; then
  791.     Xdialog --title "TazPuppy Builder" \
  792.             --ok-label "Yes" \
  793.             --cancel-label "No" \
  794.             --yesno \
  795. "Clean All Folders?" \
  796. 0 0
  797.  
  798.     retval3=$?
  799.  
  800.     if [ $retval3 -eq 0 ]; then
  801.       cpytaz_target=1
  802.     else
  803.       cpytaz_target=0
  804.     fi 
  805.   fi
  806. }
  807.  
  808. clean_up_some(){
  809.        
  810.   if [ -d $curdir/slitaz-rootfs ]; then
  811.     unmount_rootfs_binds
  812.     echo "Deleting slitaz-rootfs..."
  813.     rm -rf $curdir/slitaz-rootfs
  814.   fi
  815.   select_re_extract_kernal_Modules
  816.   if [ $cpytaz_target -eq 0 ]; then
  817.     if [ -d $curdir/tazpup-preiso ]; then
  818.       echo "Deleting tazpup-preiso..."
  819.       rm -rf $curdir/tazpup-preiso
  820.     fi
  821.     if [ -d $curdir/kernel-modules ]; then
  822.       echo "Deleting kernel-modules..."
  823.       rm -rf $curdir/kernel-modules
  824.     fi
  825.   fi
  826.   if [ -f $curdir/custom-tazpup.iso.md5 ]; then
  827.     echo "Deleting custom-tazpup.iso.md5..."
  828.     rm -f $curdir/custom-tazpup.iso.md5
  829.   fi  
  830.   if [ -d $curdir/slitaz-dload ]; then
  831.     echo "Deleting slitaz-dload..."
  832.     rm -rf $curdir/slitaz-dload
  833.   fi
  834.  
  835.   #These are used in the sandbox
  836.   #if [ -d $curdir/tazpup-core-files/slitaz-packages-fs ]; then
  837.   #  echo "Deleting slitaz-packages-fs..."
  838.   #  rm -rf $curdir/tazpup-core-files/slitaz-packages-fs
  839.   #fi
  840.  
  841.   if [ -f $curdir/slitaz-rolling-core.iso ]; then
  842.     echo "Deleting slitaz-rolling-core.iso..."
  843.     rm -f $curdir/slitaz-rolling-core.iso
  844.   fi
  845.   if [ -d $curdir/slitaz-livecd-wkg ]; then
  846.     rm -rf $curdir/slitaz-livecd-wkg
  847.   fi
  848.  
  849.  
  850.   #rm -f $curdir/tazpup-core-files/installed-isolated.md5
  851.   #rm -f $curdir/tazpup-core-files/installed-isolated.info
  852.  
  853.   #rm -f $curdir/package-deps.txt
  854.   #rm -f $curdir/package-listed
  855.  
  856.   if [ -f $curdir/custom-tazpup.iso ]; then
  857.     echo "Deleting custom-tazpup.iso..."
  858.     rm -f $curdir/custom-tazpup.iso
  859.   fi
  860.    
  861. }
  862. #function moved to: $curdir/build-scripts/add_puppy_jwm_files.sh
  863. #add_puppy_jwm_files(){
  864. #  
  865. #   #cp --remove-destination -arf $curdir/tazpup-core-files/desktop/jwm/no-arch/ptheme/* $curdir/slitaz-rootfs$prefix/ 2>/dev/null
  866. #  
  867. #                                $curdir/slitaz-rootfs$prefix/ 2>/dev/null 
  868. #
  869. #   cp --remove-destination -arf $curdir/tazpup-core-files/desktop/jwm/no-arch/rootfs-packages/woof-CE-19-03-06/ptheme/* \
  870. #                                $curdir/slitaz-rootfs$prefix/ 2>/dev/null 
  871. #
  872. #   mkdir -p $curdir/tazpup-core-files/pkg-managers/petget/usr/local/petget/
  873. #   cp --remove-destination -arf $curdir/tazpup-core-files/pkg-managers/petget/usr/local/petget/pinstall.sh \
  874. #                                $curdir/slitaz-rootfs$prefix/usr/local/petget/pinstall.sh 2>/dev/null
  875. #}
  876. clean_cache_and_logs(){
  877.   #dont include to main sfs
  878.   rm -rf $curdir/slitaz-rootfs$prefix/var/cache/tazpkg/* 2>/dev/null
  879.   rm -rf $curdir/slitaz-rootfs$prefix/var/log/slitaz/* 2>/dev/null
  880.   rm -rf $curdir/slitaz-rootfs$prefix/var/log/*.log 2>/dev/null
  881.   rm -rf $curdir/slitaz-rootfs$prefix/var/tmp/* 2>/dev/null
  882.   rm -rf $curdir/slitaz-rootfs$prefix/tmp/* 2>/dev/null
  883.   rm -f $curdir/slitaz-rootfs$prefix/etc/rc.d/PUPSTATE
  884. }
  885. update_icon_caches(){
  886.    #trap update_system_database_cleanup EXIT SIGKILL SIGTERM
  887.    update_icon_caches_fd_path="/tmp/mk-tazpup_fns/update_icon_caches/fd"
  888.    mkdir -p "$update_icon_caches_fd_path"
  889.    exec 11<> "$update_icon_caches_fd_path"/fd_11
  890.    while IFS=$'\0' read  -r -d $'\0' -u11 theme_index_path_prefixed ; do
  891.      theme_index_path=`dirname "${theme_index_path_prefixed#$curdir/slitaz-rootfs$prefix}"`
  892.      chroot "$curdir/slitaz-rootfs$prefix/" /usr/bin/gtk-update-icon-cache "$theme_index_path"
  893.    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/
  894.       exec 11>&-
  895. }
  896. update_system_databases(){
  897.   echo "Updating system database..."
  898.   chroot "$curdir/slitaz-rootfs$prefix/" update-ca-certificates
  899.   chroot "$curdir/slitaz-rootfs$prefix/" tazpkg recharge
  900.   chroot "$curdir/slitaz-rootfs$prefix/" /usr/bin/update-desktop-database /usr/share/applications
  901.   chroot "$curdir/slitaz-rootfs$prefix/" /usr/bin/update-mime-database /usr/share/mime
  902.  
  903.   update_icon_caches #Replaces: chroot "$curdir/slitaz-rootfs$prefix/" /usr/bin/gtk-update-icon-cache /usr/share/icons/hicolor
  904.  
  905.   chroot "$curdir/slitaz-rootfs$prefix/" /usr/bin/glib-compile-schemas /usr/share/glib-2.0/schemas
  906.   chroot "$curdir/slitaz-rootfs$prefix/" /usr/bin/gdk-pixbuf-query-loaders --update-cache
  907.   chroot "$curdir/slitaz-rootfs$prefix/" /usr/bin/gio-querymodules /usr/lib/gio/modules
  908.   chroot "$curdir/slitaz-rootfs$prefix/" /usr/bin/fc-cache -f
  909. }
  910. is_array(){ #Pass the name of the variable to this function (not the variable it's self)
  911.   #https://stackoverflow.com/questions/14525296/bash-check-if-variable-is-array
  912.   #http://fvue.nl/wiki/Bash:_Detect_if_variable_is_an_array
  913.   #https://www.computerhope.com/unix/bash/declare.htm
  914.   if [ $(declare -p $1 | grep -q '^declare \-a') ]; then
  915.   #Variable is an array
  916.    return 1 #This is opposite standard unix exit codes: https://shapeshed.com/unix-exit-codes/
  917.   else
  918.   #variable is not an array
  919.    return 0 #This is opposite standard unix exit codes: #http://www.tldp.org/LDP/abs/html/exitcodes.html
  920.   fi
  921. }
  922. default_applications(){
  923.   case $1 in
  924.   text_editors)
  925.   ;;
  926.   esac 
  927. }
  928. close_fd_12() { exec 12>&- ; }
  929. install_pkgs_fm_dir(){ #Specify full path to directory as first input argument
  930.    mkdir -p "/tmp/make-tazpup/functions/fd"
  931.    exec 12<> "/tmp/make-tazpup/functions/fd/fd_12"
  932.    while IFS=$'\0' read  -r -d $'\0' -u12 aPkg ; do
  933.    if [ -L "$aPkg" ]; then
  934.        aPkg=`readlink "$aPkg"`
  935.    fi
  936.    if [ -f "$aPkg" ]; then
  937.      install_pkg "$aPkg"
  938.    fi
  939.    done 12< <( find "$1" -wholename '*'"$branch/"'*.tazpkg' -print0 ) #https://blog.famzah.net/2016/10/20/bash-process-null-terminated-results-piped-from-external-commands/
  940.    exec 12>&-
  941. }
  942. install_woofCE_pkg(){
  943.     aPKG="$1"
  944.     #"$curdir/slitaz-rootfs$prefix/"
  945.     if [ ! -f "$curdir/slitaz-rootfs$prefix/var/lib/tazpkg/installed/$aPkg" ]; then
  946.       local aPkg=$1
  947.       source_pkg_dir="$curdir/tazpup-core-files/packages/woof-CE-19-03-06"
  948.       target_dir="$curdir/slitaz-rootfs$prefix"
  949.       pinst_dir="$target_dir"/desktop_pkg_inst_scripts
  950.       cp --remove-destination -arf "$source_pkg_dir/$aPkg"/* \
  951.                                    "$target_dir"/ #2>/dev/null 
  952.       if [ -f $source_pkg_dir/install.sh ]; then
  953.         chroot "$curdir/slitaz-rootfs$prefix/" /pinstall.sh  
  954.         #mkdir -p $curdir/slitaz-rootfs$prefix/ #Already done above
  955.         mv "$target_dir/pinstall.sh" "$pinst_dir/$aPkg"_pinstall.sh
  956.       fi
  957.     fi
  958. }
  959.  
  960. #pdiag-20171205|pdiag|20171205||Utility|44K||pdiag-20171205.pet||Consolidated diagnostic data collector||||
  961.  
  962. process_pet_specs(){
  963.     local specs_txt=`cat "$1" | head --lines=1`
  964.     #https://stackoverflow.com/questions/918886/how-do-i-split-a-string-on-a-delimiter-in-bash
  965.     #http://www.linuxquestions.org/questions/programming-9/bash-shell-script-split-array-383848/#post3270796
  966.     specs=(${specs_txt//|/ })
  967.     process_pet_specs_FULL_NAME=specs[0]   
  968.     process_pet_specs_PKG_NAME=[1]
  969.     process_pet_specs_VERSION=specs[2]
  970.     process_pet_CATEGORY=specs[4]
  971.     process_pet_SIZE=specs[5]  
  972.     process_pet_BRANCH=specs[6] #Repository Folder
  973.     process_pet_FILE_NAME=specs[7] #File Namer
  974.     process_pet_FILE_DEPENDS=specs[8]
  975.     process_pet_FILE_SHORT_DESC=specs[9]
  976.     process_pet_FILE_COMPILED WITHIN=specs[10]
  977.     process_pet_FILE_COMPAT_DISTRO_VER=specs[11]   
  978.     process_pet_REPO_NAME=specs[12]
  979. }
  980.  
  981. pet_specs_to_tazpkg_installed(){
  982.   local pkg_path=$1
  983.   local pkg_name=`basename $pkg_path` #TODO: add option to use petspec instead for this
  984.   local web_site=${2:-"http://puppylinux.org/"} #TODO: add option to use petspec instead for this
  985.   local maintainer=${3:-"[email protected]"} #TODO: add option to use petspec instead for this
  986.  
  987.  
  988.   process_pet_specs $pkg_path
  989.   echo 'PACKAGE="$process_pet_specs_PKG_NAME"
  990. VERSION="$process_pet_specs_VERSION"
  991. CATEGORY="$process_pet_CATEGORY"
  992. SHORT_DESC="$process_pet_SHORT_DESC"
  993. WEB_SITE="$web_site"
  994. MAINTAINER="$maintainer"
  995. DEPENDS="$process_pet_FILE_DEPENDS"
  996. ' > $curdir/litaz-rootfs$prefix/var/lib/tazpkg/installed/linux-modules/receipt #TODO add che for pkgmanager type and suport for toher package managers   
  997.      
  998.       xcurdir="$(echo "$curdir" | sed "s#\/#\\\/#g")"
  999.      
  1000.       find $pkg_name -type -name "*" > $curdir/slitaz-rootfs$prefix/var/lib/tazpkg/installed/$pkg_name/files.list-tmp
  1001.       cat "$curdir/slitaz-rootfs$prefix/var/lib/tazpkg/installed/$pkg_name/files.list" |
  1002.    touch "$curdir/slitaz-rootfs$prefix/var/lib/tazpkg/installed/$pkg_name/files.list"
  1003.    while read  -r -d $'\n' $aFile_prefixed ; do
  1004.      if [ ! -d "$aFile" ]; then
  1005.        aFile=${aFile_prefixed#"$pkg_path"}
  1006.        echo $aFile > "$curdir/slitaz-rootfs$prefix/var/lib/tazpkg/installed/$pkg_name/files.list"
  1007.      fi
  1008.    done <"$curdir/slitaz-rootfs$prefix/var/lib/tazpkg/installed/$pkg_name/files.list-tmp"
  1009. }
  1010. install_pkgs_fm_dir(){ #Specify full path to directory as first input argument
  1011.    mkdir -p "/tmp/make-tazpup/functions/fd"
  1012.    exec 12<> "/tmp/make-tazpup/functions/fd/fd_12"
  1013.    while IFS=$'\0' read  -r -d $'\0' -u12 aPkg ; do
  1014.    if [ -L "$aPkg" ]; then
  1015.        aPkg=`readlink "$aPkg"`
  1016.    fi
  1017.    if [ -f "$aPkg" ]; then
  1018.      install_pkg "$aPkg"
  1019.    fi
  1020.    done 12< <( find "$1" -wholename '*'"$branch/"'*.tazpkg' -print0 ) #https://blog.famzah.net/2016/10/20/bash-process-null-terminated-results-piped-from-external-commands/
  1021.    exec 12>&-
  1022. }
Advertisement
Add Comment
Please, Sign In to add comment