Advertisement
s243a

InstallAndBuild-Simple

May 31st, 2018
328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 6.13 KB | None | 0 0
  1. #!/bin/ash
  2.  
  3. #THIS_DIR=$PWD
  4. #ROOT="${THIS_DIR%%/tazpupsave/*}/tazpupsave"
  5. export ROOT='/mnt/home/devX_TazPup_s243a_1.0'
  6. export TMP='/tmp/InstallAndBuild'
  7. export FirstInstall=true
  8. export BuildDevX=false
  9. export BashAsSh=true
  10. export InstallCoreUtils=true
  11. export InstallDev=true
  12. export Large=false
  13. export tinypy=true
  14. export runEvals=true
  15. export icu=false #Globalization Libraries (Ignored if Large=true)
  16. export InstallPackages=true
  17. export InstallCoreUtils=true
  18. export extractPackages=true
  19. export GCC_VERSION=1
  20. mkdir -p "$TMP"
  21. rm "$TMP"/To_Install
  22. rm "$TMP"/For_DevX
  23. rm "$TMP"/Should_Be_Standard
  24. rm "$TMP"/To_Eval
  25. rm "$TMP"/To_Extract
  26. #cd $THIS_DIR
  27. #https://stackoverflow.com/questions/2337616/can-i-read-line-from-a-heredoc-in-bash
  28. while read line; do
  29.  
  30.   echo "$line"
  31.   line=$( echo "$line" | tr -s [:blank:] )
  32.   case "$line" in
  33.      "#"*)
  34.         #do nothing
  35.         ;;
  36.      "I "*) #Install if this is the first time running this script (New Installation)
  37.          [ $FirstInstall ] && echo "$line" | tr -s [:blank:] | cut -d' ' -f2 >> $TMP/To_Install
  38.          ;;
  39.      "Id "*)
  40.          #Install if this is the first time running this script (New Installation)
  41.          [ $FirstInstall ] && [ $InstallDev ] && echo "$line" | tr -s [:blank:] | cut -d' ' -f2 >> "$TMP/To_Install"
  42.          echo "$line" | tr -s [:blank:] | cut -d' ' -f2 >> "$TMP/For_DevX"
  43.          ;;
  44.      "i "*)
  45.          echo "$line" | tr -s [:blank:] | cut -d' ' -f2 >> "$TMP/To_Install"
  46.          ;;    
  47.      "id "*)
  48.          [ $InstallDev ] && echo "$line" | tr -s [:blank:] | cut -d' ' -f2 >> "$TMP/To_Install"
  49.          echo "$line" | tr -s [:blank:] | cut -d' ' -f2 >> "$TMP/For_DevX"
  50.          ;;
  51.       "d *")
  52.          echo "$line" | tr -s [:blank:] | cut -d' ' -f2 >> "$TMP/For_DevX"
  53.          ;;
  54.      "L_i "*)          
  55.          [ $Large ] && echo "$line" | tr -s [:blank:] | cut -d' ' -f2 >> "$TMP/To_Install"
  56.           ;;
  57.      "L_id "*)
  58.          [ $Large ] && [ $InstallDev ] && echo "$line" | tr -s [:blank:] | cut -d' ' -f2 >> "$TMP/To_Install"
  59.          [ $Large ] && echo "$line" | tr -s [:blank:] | cut -d' ' -f2 >> "$TMP/For_DevX"; ;;
  60.       "s "*)  #Check if these are installed, I flagged them because they are important and should be standard but I don't know for sure          
  61.           echo "$line" | tr -s [:blank:] | cut -d' ' -f2 >> "$TMP/Should_Be_Standard"; ;;
  62.       "!eval "*) #To Eval
  63.           echo "$line" | tr -s [:blank:] | cut -d' ' -f2-10 >> "$TMP/To_Eval"; ;;          
  64.       "e "*) #Extract a package
  65.           echo "$line" | tr -s [:blank:] | cut -d' ' -f2 >> "$TMP/To_Extract"; ;;
  66.          
  67.    esac  
  68. #done < <( echo <<EOM
  69. done <<EOM
  70. # First any glib changes
  71.   /var/lib/tazpkg/installed/bash
  72.   $( if [ $BashAsSh == true ]; then
  73.            echo "i /var/lib/tazpkg/installed/bash
  74.                  !eval cd /bin;
  75.                  !eval rm 'sh';
  76.                  !eval ln -s bash sh
  77.                  !eval changeSheBang /usr/sbin/snapmergepuppy /bin/bash"
  78.    fi )
  79.  
  80.   $( if [ $InstallCoreUtils == true ]; then
  81.            echo "e /tazpkg/installed/coreutils-multicall
  82.             !eval copyExtracted coreutils-multicall /usr/bin/readlink
  83.             !eval copyExtracted coreutils-multicall /usr/libexec/coreutils/libstdbuf.so            
  84.             !eval copyExtracted coreutils-multicall /usr/bin/coreutils
  85.             !eval cd /usr/bin; rm readlink; ln -s coreutils readlink"
  86.    fi )
  87. s /var/lib/tazpkg/installed/libssl
  88. s /var/lib/tazpkg/installed/lz4
  89. s /var/lib/tazpkg/installed/lzlib
  90. s /var/lib/tazpkg/installed/openssl
  91. i /var/lib/tazpkg/installed/get-palemoon
  92. i /var/lib/tazpkg/installed/perl-core
  93. s /var/lib/tazpkg/installed/pygtk
  94. i /var/lib/tazpkg/installed/qt4
  95. i /var/lib/tazpkg/installed/rox-default-icons
  96. i /var/lib/tazpkg/installed/rox-filer
  97. i /var/lib/tazpkg/installed/rox-filer-locales
  98. i /var/lib/tazpkg/installed/tinypy
  99. EOM
  100. copyExtracted(){
  101.     PKG_Name="$( basename "$1" )"
  102.     DIR_NAME="$( dirname $2)"
  103.     VERSION=`tazpkg info $PKG_Name | grep 'Version' | sed 's/.*://'|cut -c 6-` 
  104.     cd "$TMP"/"$PKG_Name"-"$VERSION/fs"
  105.     pwd
  106.     mkdir -p "$DIR_NAME"
  107.     cp -a -u ."$2" "$2"
  108. }
  109. changeSheBang(){
  110.     if [ -f $1 ]; then
  111.       cp $1 $1-old
  112.       CHMOD_VAL="$( stat -c %a $1 )"
  113.       rm $1
  114.       line_num=1
  115.       while read line; do
  116.         if [ $line_num -eq 1 ]; then
  117.           echo "#!$2" >> "$1"
  118.         else
  119.           echo "$line" >> "$1"
  120.         fi
  121.         line_num=`expr $line_num + 1`
  122.       done <"$1-old"
  123.       chmod "$CHMOD_VAL" "$1"
  124.     fi
  125. }
  126. if [ $InstallPackages == true ]; then
  127.  echo '============ INSTALLING PACKAGES ====================='
  128.   while read PKG; do
  129.      [ -f "$PKG" ] || tazpkg get-install "$( basename "$PKG" )"
  130.   done <"$TMP/To_Install"
  131.    while read PKG; do
  132.      [ -f "$PKG" ] || tazpkg get-install "$( basename "$PKG" )"
  133.   done <"$TMP/Should_Be_Standard"
  134. fi
  135. if [ $extractPackages == true ]; then
  136.  echo '============ EXTRACTING PACKAGES ====================='
  137.  cd "$TMP"
  138.   while read PKG; do
  139.       PKG_Name="$( basename "$PKG" )"
  140.       tazpkg get $PKG_Name
  141.       VERSION=`tazpkg info $PKG_Name | grep 'Version' | sed 's/.*://'|cut -c 6-`
  142.       tazpkg extract "$PKG_Name"-"$VERSION".tazpkg "."
  143.   done <"$TMP/To_Extract"
  144. fi
  145. copyPackage(){
  146.     PACKAGE=$1
  147.     if [ -n "$2" ]; then
  148.       aRoot="$2"
  149.     else
  150.       aROOT="$ROOT"
  151.     fi
  152.     if [ -f $PACKAGE/files.list ]; then
  153.       while read line; do
  154.         DIR=$( dirname "$line" )
  155.         mkdir -p "$aROOT$DIR"
  156.         cp -a -u "$line" "$aROOT$line"
  157.       done <"$PACKAGE/files.list"
  158.     else
  159.    
  160.       #mkdir -p /t  
  161.       cd "$TMP"
  162.       PKG_Name="$( basename "$PACKAGE" )"
  163.       tazpkg get $PKG_Name
  164.       VERSION=`tazpkg info $PKG_Name | grep 'Version' | sed 's/.*://'|cut -c 6-`
  165.       tazpkg extract "$PKG_Name"-"$VERSION".tazpkg "$ROOT"
  166.     fi
  167. }
  168. if [ $BuildDevX == true ]; then
  169.  echo '============ BUILDING DEVX ====================='
  170.   while read PKG; do
  171.     copyPackage "$PKG"
  172.   done <"$TMP/For_DevX"
  173.   mksquashfs "$ROOT" devX_TazPup_s243a_1.0.sfs -comp xz -Xbcj arm -noappend
  174. fi
  175. if [ $runEvals == true ]; then
  176.  echo '============ RUNNING EVALS ====================='
  177.   while read toEval; do
  178.       eval "$toEval"
  179.   done <"$TMP/To_Eval"
  180. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement