SHARE
TWEET

tazwoof-devx.sh

s243a Jun 19th, 2018 (edited) 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2. #A slightly modified version of mistfire's TazWoof: http://murga-linux.com/puppy/viewtopic.php?p=996352#996352
  3. #180619-1a s243a a download failure shouldn't stop the build
  4. #180619-1b Keep track of sucfull and failed downloads
  5. #180619-1c Don't re download the file if it exists
  6.  
  7. WEBSITE="http://mirror1.slitaz.org"
  8.  
  9. DESKTOP="$1"
  10.  
  11. curdir="$(pwd)"
  12.  
  13. download_pkgs(){
  14.    
  15.     pkgs="$1"
  16.     PTRN="$(echo "^$pkgs-[0-9]" | sed -e "s#\+#\\\+#g")"
  17.     pkgname="$(cat $curdir/slitaz-devx/packages.list | grep -E "$PTRN")"
  18.  
  19.     if [ "$pkgname" != "" ]; then
  20.         if [ ! -f "$curdir/slitaz-devx/$pkgname.tazpkg" ]; then #180619-1c
  21.           wget --timeout=10 $WEBSITE/packages/cooking/$pkgname.tazpkg -O $curdir/slitaz-devx/$pkgname.tazpkg
  22.           if [ $? -ne 0 ]; then
  23.             echo "Downloading package failed: $pkgname"
  24.             #exit #180619-1
  25.             echo "$pkgname.tazpkg" >> "$curdir/slitaz-devx/packages.list.fail" #180619-1b
  26.           else
  27.             echo "$pkgname.tazpkg" >> "$curdir/slitaz-devx/packages.list.success" #180619-1b       
  28.           fi
  29.         else
  30.           echo "$pkgname.tazpkg" >> "$curdir/slitaz-devx/packages.list.success" #180619-1c
  31.         fi
  32.        
  33.     fi
  34.    
  35. }
  36.  
  37. cleanup_TMP(){ #180619-1c
  38.   rm -f $curdir/slitaz-devx/packages.list.fail 
  39.   rm -f $curdir/slitaz-devx/packages.list.success
  40.   rm -f $curdir/slitaz-devx/packages.list  
  41.   rm -rf $curdir/temp-devx
  42.   mkdir $curdir/temp-devx
  43. }
  44. cleanup_ROOTFS()
  45. {
  46.   rm -rf $curdir/devx-rootfs
  47. }
  48. cleanup(){
  49.   rm -rf $curdir/slitaz-devx   
  50.   mkdir $curdir/slitaz-devx
  51.   rm -rf $curdir/temp-devx
  52.   mkdir $curdir/temp-devx
  53.   rm -rf $curdir/devx-rootfs
  54. }
  55. extract_pkgdb(){
  56.   cd $curdir/slitaz-devx
  57.  
  58.   unlzma ./bundle.tar.lzma
  59.   tar xvf ./bundle.tar packages.list
  60.   tar xvf ./bundle.tar packages.info
  61.   rm -f ./bundle.tar   
  62. }
  63.  
  64. download_pkgdb(){
  65.  
  66.   wget --timeout=10 $WEBSITE/packages/cooking/bundle.tar.lzma -O $curdir/slitaz-devx/bundle.tar.lzma
  67.  
  68.   if [ $? -ne 0 ]; then
  69.     echo "Downloading slitaz package database failed"
  70.     exit
  71.   fi   
  72. }
  73.  
  74. build_pkg_db(){
  75.   rm -f $curdir/slitaz-devx/packages.txt
  76.   cat $curdir/slitaz-devx/packages.info | sed -e "s#\t#;#g" >  $curdir/slitaz-devx/packages.txt
  77. }
  78.  
  79. sniff_deps(){
  80.    
  81.   pkg="$1"
  82.  
  83.   PTRN="$(echo "^$pkg;" | sed -e "s#\+#\\\+#g")"
  84.  
  85.   if [ "$pkg" == "" ]; then
  86.     continue
  87.   fi
  88.  
  89.     if [ ! -f $curdir/temp-devx/package-listed.txt ]; then
  90.       echo "$pkg;" > $curdir/temp-devx/package-listed.txt
  91.     elif [ "$(cat $curdir/temp-devx/package-listed.txt | grep -E "$PTRN")" == "" ]; then
  92.       echo "$pkg;" >> $curdir/temp-devx/package-listed.txt
  93.     else
  94.      continue
  95.     fi
  96.  
  97.  
  98.   deps=$(cat $curdir/slitaz-devx/packages.txt | grep -E "$PTRN" | cut -f 8 -d ';')
  99.  
  100. if [ "$deps" == "" ]; then
  101.  continue
  102. fi
  103.  
  104. #echo "$pkg: $deps"
  105.    
  106. for dep in $deps
  107. do
  108.  
  109.    #echo "$dep"
  110.  
  111.     if [ "$dep" != "" ]; then
  112.  
  113.        xPTRN7="$(echo "^$dep;" | sed -e "s#\+#\\\+#g")"
  114.        
  115.        if [ -f $curdir/temp-devxlates/blocked-packages.txt ]; then
  116.         blkinst="$(cat $curdir/temp-devxlates/blocked-packages.txt | grep -E "$xPTRN7")"
  117.        fi
  118.        
  119.        if [ -f $curdir/temp-devxlates/slitaz-core.txt ]; then
  120.         cldpkg="$(cat $curdir/temp-devxlates/slitaz-core.txt | grep -E "$xPTRN7")"
  121.        fi
  122.        
  123.        if [ -f $curdir/temp-devxlates/puppy-core.txt ]; then
  124.         puppkg="$(cat $curdir/temp-devxlates/puppy-core.txt | grep -E "$xPTRN7")"
  125.        fi
  126.        
  127.        if [ "$blkinst" == "" ] && [ "$cldpkg" == "" ] && [ "$puppkg" == "" ]; then
  128.        
  129.           if [ ! -f $curdir/temp-devx/package-deps.txt ]; then
  130.               echo "$dep;" > $curdir/temp-devx/package-deps.txt
  131.           elif [ "$(cat $curdir/temp-devx/package-deps.txt | grep -E "$xPTRN7")" == "" ]; then
  132.               echo "$dep;" >> $curdir/temp-devx/package-deps.txt
  133.           fi  
  134.        
  135.           sniff_deps "$dep"
  136.          
  137.        fi
  138.        
  139.     fi
  140.          
  141. done
  142.    
  143. }
  144.  
  145. process_template(){
  146.    
  147.   cat $curdir/templates/devx.txt | sed -e "s#;##g" | sort > $curdir/temp-devx/download-devx-packages.txt
  148.    
  149. }
  150.  
  151. process_package() {
  152.    
  153.   chksum="$(md5sum $1)"
  154.  
  155.   cpio -idm --quiet < "$1" && rm -f "$1"
  156.   if [ -f fs.cpio.lzma ]; then
  157.     unlzma < fs.cpio.lzma | cpio -idm --quiet && rm fs.cpio.lzma
  158.   elif [ -f fs.cpio.gz ]; then
  159.     zcat fs.cpio.gz | cpio -idm --quiet && rm fs.cpio.gz
  160.   fi
  161.  
  162.   rm -f ./receipt > /dev/null
  163.   rm -f ./md5sum > /dev/null
  164.   rm -f ./files.list > /dev/null
  165.   rm -f ./description.txt > /dev/null
  166.  
  167.   cp -arf ./fs/* ./
  168.  
  169.   rm -rf ./fs
  170.  
  171. }
  172.  
  173. process_pkg_dir(){
  174.   if [ ! -d $curdir/devx-rootfs ]; then
  175.     mkdir $curdir/devx-rootfs
  176.   fi   
  177. }
  178.  
  179. install_packages(){
  180.   if [ ! -d  $curdir/slitaz-devx ]; then
  181.     echo "Devx tazpup package folder is missing."
  182.     exit
  183.   else
  184.  
  185.     if [ $(find $curdir/slitaz-devx -type f -name "*.tazpkg" | wc -l) -eq 0 ]; then
  186.       echo "Tazpup package is missing."
  187.       exit
  188.     fi
  189.  
  190.     for pkg in $(find $curdir/slitaz-devx -type f -name "*.tazpkg" | sort -r)
  191.     do
  192.       echo "Processing package:  $(basename $pkg)"
  193.       cp -f $pkg $curdir/devx-rootfs/
  194.       cd $curdir/devx-rootfs/
  195.       process_package "$(basename $pkg)"
  196.     done
  197.    
  198.   fi   
  199. }
  200.  
  201. fetch_pkg(){
  202.   for pkg in $(cat $curdir/temp-devx/download-devx-packages.txt)
  203.   do
  204.     download_pkgs "$pkg"
  205.   done     
  206. }
  207.  
  208. make_sfs(){
  209.   mksquashfs "$curdir/devx-rootfs/" "devx_tazpup.sfs" -comp xz -Xbcj x86 -b 1M -Xdict-size 100%
  210. }
  211.  
  212.  
  213. #### MAIN ####
  214.  
  215. cleanup
  216. download_pkgdb
  217. extract_pkgdb
  218. build_pkg_db
  219. process_template
  220. fetch_pkg
  221. process_pkg_dir
  222. install_packages
  223. make_sfs
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top