SHARE
TWEET

/usr/bin/make-devx (TazPup64)

s243a Apr 21st, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2. #written by mistfire
  3. #A slightly modified version of mistfire's TazWoof: http://murga-linux.com/puppy/viewtopic.php?p=996352#996352
  4. #180619-1a s243a a download failure shouldn't stop the build
  5. #180619-1b Keep track of sucessful and failed downloads
  6. #180619-1c Don't re download the file if it exists
  7.  
  8. if [ -f /etc/slitaz/slitaz.conf ]; then
  9.   . /etc/slitaz/slitaz.conf #Comment this line out if you don't want to use distro defualts.
  10. fi
  11. WEBSITE=${MIRROR_URL:-"http://mirror1.slitaz.org"}
  12. DIRPKG=${SLITAZ_RELEASE:-'next64'}
  13.  
  14. cmd1=$(basename $0)
  15.  
  16.  
  17. if [ "$1" != "" ]; then
  18.  
  19.  if [ "$(whoami)" != root ]; then
  20.   exec sudo -A $0 $@
  21.   exit
  22.  fi
  23.  
  24.  curdir=`realpath "$1"`
  25.  while read aDir; do
  26.    if [ ! -e $aDir ]; then
  27.      echo "Create working folder: $aDir"
  28.      mkdir -p $aDir 2>/dev/null
  29.      if [ $? -ne 0 ]; then
  30.        echo "Failed to create working folder $aDir"
  31.        exit
  32.      fi
  33.    fi
  34.  done <<EOM
  35. $curdir
  36. $curdir/devx-rootfs
  37. $curdir/slitaz-devx  
  38. EOM
  39.  
  40.  
  41.  
  42. else
  43.  echo "Usage: $cmd1 [working folder]"
  44.  echo "Creates DEVX module for compiling"
  45.  exit
  46. fi
  47. cd $curdir
  48. download_pkgs(){
  49.    
  50.     pkgs="$1"
  51.     PTRN="$(echo "^$pkgs-[0-9]" | sed -e "s#\+#\\\+#g")"
  52.     pkgname="$(cat $curdir/slitaz-devx/packages.list | grep -E "$PTRN")"
  53.  
  54.     if [ "$pkgname" != "" ]; then
  55.         if [ ! -f "$curdir/slitaz-devx/$pkgname.tazpkg" ]; then #180619-1c
  56.           wget -nc --timeout=10 $WEBSITE/packages/$DIRPKG/$pkgname.tazpkg -O $curdir/slitaz-devx/$pkgname.tazpkg
  57.           if [ $? -ne 0 ]; then
  58.             echo "Downloading package failed: $pkgname"
  59.             #exit #180619-1
  60.             echo "$pkgname.tazpkg" >> "$curdir/slitaz-devx/packages.list.fail" #180619-1b
  61.           else
  62.             echo "$pkgname.tazpkg" >> "$curdir/slitaz-devx/packages.list.success" #180619-1b       
  63.           fi
  64.         else
  65.           echo "$pkgname.tazpkg" >> "$curdir/slitaz-devx/packages.list.success" #180619-1c
  66.         fi 
  67.     fi
  68.    
  69. }
  70.  
  71. cleanup_TMP(){ #180619-1c
  72.   rm -f $curdir/slitaz-devx/packages.list.fail 
  73.   rm -f $curdir/slitaz-devx/packages.list.success
  74.   rm -f $curdir/slitaz-devx/packages.list  
  75.   rm -rf $curdir/temp-devx
  76.   mkdir $curdir/temp-devx
  77. }
  78.  
  79. cleanup_ROOTFS(){
  80.   rm -rf $curdir/devx-rootfs
  81. }
  82.  
  83. cleanup(){
  84.   rm -rf $curdir/slitaz-devx   
  85.   mkdir $curdir/slitaz-devx
  86.   rm -rf $curdir/temp-devx
  87.   mkdir $curdir/temp-devx
  88.   rm -rf $curdir/devx-rootfs
  89. }
  90.  
  91. extract_pkgdb(){
  92.   cd $curdir/slitaz-devx
  93.  
  94.   unlzma ./bundle.tar.lzma
  95.   tar xvf ./bundle.tar packages.list
  96.   tar xvf ./bundle.tar packages.info
  97.   rm -f ./bundle.tar   
  98. }
  99.  
  100. download_pkgdb(){
  101.  
  102.   wget --timeout=10 $WEBSITE/packages/$DIRPKG/bundle.tar.lzma -O $curdir/slitaz-devx/bundle.tar.lzma
  103.  
  104.   if [ $? -ne 0 ]; then
  105.     echo "Downloading slitaz package database failed"
  106.     exit
  107.   fi   
  108. }
  109.  
  110. build_pkg_db(){
  111.  
  112.   rm -f $curdir/slitaz-devx/packages.txt
  113.   cat $curdir/slitaz-devx/packages.info | sed -e "s#\t#;#g" >  $curdir/slitaz-devx/packages.txt
  114. }
  115.  
  116. sniff_deps(){
  117.    
  118.   pkg="$1"
  119.  
  120.   PTRN="$(echo "^$pkg;" | sed -e "s#\+#\\\+#g")"
  121.  
  122.   if [ "$pkg" == "" ]; then
  123.     continue
  124.   fi
  125.  
  126.     if [ ! -f $curdir/temp-devx/package-listed.txt ]; then
  127.       echo "$pkg;" > $curdir/temp-devx/package-listed.txt
  128.     elif [ "$(cat $curdir/temp-devx/package-listed.txt | grep -E "$PTRN")" == "" ]; then
  129.       echo "$pkg;" >> $curdir/temp-devx/package-listed.txt
  130.     else
  131.      continue
  132.     fi
  133.  
  134.  
  135.   deps=$(cat $curdir/slitaz-devx/packages.txt | grep -E "$PTRN" | cut -f 8 -d ';')
  136.  
  137. if [ "$deps" == "" ]; then
  138.  continue
  139. fi
  140.  
  141. #echo "$pkg: $deps"
  142.    
  143. for dep in $deps
  144. do
  145.  
  146.    #echo "$dep"
  147.  
  148.     if [ "$dep" != "" ]; then
  149.  
  150.        xPTRN7="$(echo "^$dep\$" | sed -e "s#\+#\\\+#g")"
  151.        xPTRN8="$(echo "^$dep;" | sed -e "s#\+#\\\+#g")"
  152.        
  153.        if [ -f /var/lib/tazpkg/blocked-packages.list ]; then
  154.         blkinst="$(cat var/lib/tazpkg/blocked-packages.list | grep -E "$xPTRN7")"
  155.        fi
  156.        
  157.        if [ -f /var/lib/tazpkg/locked-packages ]; then
  158.         clkinst="$(cat var/lib/tazpkg/locked-packages | grep -E "$xPTRN7")"
  159.        fi
  160.        
  161.        if [ "$blkinst" == "" ] && [ "$clkinst" == "" ] && [ ! -d /var/lib/tazpkg/installed/$dep ]; then
  162.        
  163.           if [ ! -f $curdir/temp-devx/package-deps.txt ]; then
  164.               echo "$dep;" > $curdir/temp-devx/package-deps.txt
  165.           elif [ "$(cat $curdir/temp-devx/package-deps.txt | grep -E "$xPTRN8")" == "" ]; then
  166.               echo "$dep;" >> $curdir/temp-devx/package-deps.txt
  167.           fi  
  168.        
  169.           sniff_deps "$dep"
  170.          
  171.        fi
  172.        
  173.     fi
  174.          
  175. done
  176.    
  177. }
  178.  
  179. process_template(){
  180.    
  181.   cat /usr/share/devx.txt | sed -e "s#;##g" | sort > $curdir/temp-devx/download-devx-packages.txt
  182.    
  183. }
  184.  
  185. process_package() {
  186.    
  187.   chksum="$(md5sum $1)"
  188.  
  189.   cpio -idm --quiet < "$1" && rm -f "$1"
  190.   if [ -f fs.cpio.lzma ]; then
  191.     unlzma < fs.cpio.lzma | cpio -idm --quiet && rm fs.cpio.lzma
  192.   elif [ -f fs.cpio.gz ]; then
  193.     zcat fs.cpio.gz | cpio -idm --quiet && rm fs.cpio.gz
  194.   fi
  195.  
  196.   if [ ! -d ./var/lib/tazpkg/installed ]; then
  197.    mkdir -p ./var/lib/tazpkg/installed
  198.   fi
  199.  
  200.   unset PACKAGE VERSION EXTRAVERSION CATEGORY SHORT_DESC WEB_SITE \
  201.   TAGS PACKED_SIZE UNPACKED_SIZE DEPENDS
  202.  
  203.   . ./receipt #Modified by s243a
  204.  
  205.   mkdir -p ./var/lib/tazpkg/installed/$PACKAGE 2>/dev/null
  206.  
  207.   mv -f ./receipt ./var/lib/tazpkg/installed/$PACKAGE/ 2>/dev/null
  208.   mv -f ./files.list ./var/lib/tazpkg/installed/$PACKAGE/ 2>/dev/null
  209.   mv -f ./description.txt ./var/lib/tazpkg/installed/$PACKAGE/ 2>/dev/null
  210.  
  211.   rm -f ./md5sum > /dev/null
  212.  
  213.   cp -arf ./fs/* ./
  214.  
  215.   rm -rf ./fs
  216.  
  217. }
  218.  
  219. process_pkg_dir(){
  220.   if [ ! -d $curdir/devx-rootfs ]; then
  221.     mkdir $curdir/devx-rootfs
  222.   fi   
  223. }
  224.  
  225. install_packages(){
  226.   if [ ! -d  $curdir/slitaz-devx ]; then
  227.     echo "Devx tazpup package folder is missing."
  228.     exit
  229.   else
  230.  
  231.     if [ $(find $curdir/slitaz-devx -type f -name "*.tazpkg" | wc -l) -eq 0 ]; then
  232.       echo "Tazpup package is missing."
  233.       exit
  234.     fi
  235.  
  236.     for pkg in $(find $curdir/slitaz-devx -type f -name "*.tazpkg" | sort -r)
  237.     do
  238.       echo "Processing package:  $(basename $pkg)"
  239.       cp -f $pkg $curdir/devx-rootfs/
  240.       cd $curdir/devx-rootfs/
  241.       process_package "$(basename $pkg)"
  242.     done
  243.    
  244.   fi   
  245. }
  246.  
  247. fetch_pkg(){
  248.   for pkg in $(cat $curdir/temp-devx/download-devx-packages.txt)
  249.   do
  250.     download_pkgs "$pkg"
  251.   done 
  252.  
  253.   echo "Download sucess: $(cat $curdir/slitaz-devx/packages.list.success | wc -l)"
  254.   echo "Download failed: $(cat $curdir/slitaz-devx/packages.list.fail | wc -l)"
  255.    
  256. }
  257.  
  258. make_sfs(){
  259.   cd $curdir   
  260.   mksquashfs "$curdir/devx-rootfs/" "$curdir/devx_tazpup.sfs" -comp xz -Xbcj x86 -b 1M -Xdict-size 100%
  261.  
  262.   if [ $? -eq 0 ]; then
  263.    echo "DEVX modules sucessfully created: $curdir/devx_tazpup.sfs"
  264.   fi
  265.  
  266. }
  267.  
  268. #### MAIN ####
  269.  
  270. cleanup
  271. download_pkgdb
  272. extract_pkgdb
  273. build_pkg_db
  274. process_template
  275. fetch_pkg
  276. process_pkg_dir
  277. install_packages
  278. 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