s243a

pupngo041210_howto.sh

Mar 31st, 2019
357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 5.96 KB | None | 0 0
  1. #!/bin/sh
  2. ##See related post: http://www.murga-linux.com/puppy/viewtopic.php?p=473814#473814
  3. #this script shows howto use pupngo to build your own new puppy
  4. #this is a very rough demo - ajust script and functions to your own needs.
  5. #061210goingnuts
  6.  
  7. CURDIR=$(pwd)
  8. TITLE="pUPnGO 041210-rebuilder"
  9.  
  10. TYPE="cli"      #dialog or cli
  11. [ $(which dialog) ] && TYPE="dialog" && DIALOG=dialog
  12. [ $(which Xdialog) ] && [ "$DISPLAY" ] && DIALOG=Xdialog
  13. [ "$DISPLAY" ] && [ "$(tty | grep not)" ] && [ ! "${DIALOG}" = "Xdialog" ] && exec rxvt -e sh -c $0
  14.  
  15. message_fc () { #message function
  16. #clear
  17. if [ "${TYPE}" = "dialog" ]; then
  18.   "${DIALOG}" --title "${TITLE}" --msgbox "${TEXT} Press OK to continue/quit." 0 0
  19. fi
  20. if [ "${TYPE}" = "cli" ]; then 
  21.   echo "${TITLE}"
  22.   echo "${TEXT}"
  23.   echo "Press any key to continue/quit."
  24.   read dummy
  25. fi
  26. }
  27.  
  28. find_libs () {
  29. TARGETDIR="$CURDIR/myadds_412/"
  30. echo "Scanning directory:
  31. $TARGETDIR
  32. Please wait..."
  33. echo
  34. TEXT=""
  35. [ $(which upx) ] && UPX="no"
  36. cd $TARGETDIR
  37. echo -n > /tmp/liblist
  38. find . -type f | while read x; do
  39. [ "${UPX}" = "yes" ] && upx -d -q "$x" >/dev/null 2>&1;
  40. ldd "$x" >> /tmp/liblist 2>&1;
  41. done
  42.  
  43. cd $CURDIR
  44.  
  45. sed -i "s/\/\//\//g" /tmp/liblist
  46. sed -i "s/\t/ /g" /tmp/liblist
  47. cat /tmp/liblist | grep "=>" > /tmp/liblist
  48. cat /tmp/liblist | cut -d " " -f 4 | sort -u | grep "lib" > /tmp/liblist
  49.  
  50. #list missing libs
  51. NEEDED="$(cat /tmp/liblist)"
  52. for lib in $NEEDED; do
  53. if [ ! -f $TARGETDIR$lib ]; then
  54. echo "Missing             :    $lib"
  55. TEXT="$TEXT
  56. Missing             :    $lib"
  57. fi
  58. done
  59.  
  60. echo "------------------------------------------"
  61. TEXT="$TEXT
  62. ------------------------------------------
  63. "
  64.  
  65. #list present needed libs
  66. for lib in $NEEDED; do
  67. if [ -f $TARGETDIR$lib ]; then
  68. echo "Present and needed  :    $lib"
  69. TEXT="$TEXT
  70. Present and needed  :    $lib"
  71. fi
  72. done
  73.  
  74. #find all libs present
  75. cd $TARGETDIR
  76. echo -n > /tmp/liblist
  77. for y in lib usr/lib usr/X11R7/lib; do
  78. find $y -type f >> /tmp/liblist
  79. done
  80.  
  81. cat /tmp/liblist | grep "so" | sort -u > /tmp/liblist
  82.  
  83. #list all libs present
  84. PRESENT="$(cat /tmp/liblist)"
  85. echo -n > /tmp/liblist
  86. for lib in $PRESENT; do
  87. echo "/$lib" >> /tmp/liblist
  88. done
  89. PRESENT="$(cat /tmp/liblist)"
  90.  
  91. echo "------------------------------------------"
  92. TEXT="$TEXT
  93. ------------------------------------------
  94. "
  95.  
  96. #list unused libs
  97. for needed in $NEEDED; do
  98.    cat /tmp/liblist | grep -v $needed > /tmp/liblist
  99.    #find symlink target
  100.    if [ -h $TARGETDIR$needed ]; then
  101.    REAL=$(readlink $TARGETDIR$needed)
  102.    cat /tmp/liblist | grep -v $REAL > /tmp/liblist
  103.    fi
  104. done
  105.  
  106. UNUSED="$(cat /tmp/liblist)"
  107. for lib in $UNUSED; do
  108. echo "Unused              :    $lib"
  109. TEXT="$TEXT
  110. Unused              :    $lib"
  111. if [ ! "$(echo $lib | grep libgcc)" = "" ]; then
  112. echo "NB: $lib might be needed although not a direct dependency"
  113. TEXT="$TEXT
  114. NB: $lib might be needed although not a direct dependency"
  115. fi
  116. done
  117.  
  118. TEXT="$TEXT
  119. You should copy any missing libraries into folder
  120. $CURDIR/myadds_412.
  121. If libc is listed above (missing or needed) you
  122. also need /lib/ld-linux.so.2.
  123. If libraries present and not used you can delete
  124. them...
  125. "
  126. message_fc
  127. }
  128. http://www.murga-linux.com/puppy/viewtopic.php?p=473814#473814
  129. #start main program
  130. http://www.murga-linux.com/puppy/viewtopic.php?p=473814#473814
  131. #check we have the iso
  132. if [ ! -f $CURDIR/pUPnGO_V412_041210.iso ]; then
  133. TEXT="You need to have the pUPnGO_V412_041210.iso in
  134. the same directory as this script is running
  135. ($CURDIR).
  136. Or move this script to the directory where the iso is.
  137. "
  138. message_fc
  139. exit
  140. fi
  141.  
  142. TEXT="Welcome to this small demo of howto
  143. modify pUPnGO_041210 to contain the programs
  144. YOU want."
  145. message_fc
  146.  
  147. #first we need to create the construction area
  148. for DIR in isomaster output myadds_412 tmpmntpoint pets; do
  149. [ ! -d $DIR ] && mkdir -p $DIR
  150. done
  151. #mount the iso
  152. mount -t iso9660 -o loop pUPnGO_V412_041210.iso tmpmntpoint
  153. #copy main-things to isomaster - add glibc2.6_412.sfs, GUI_412.sfs and links_static.pet if you need them as well...
  154. for FILE in boot.msg initrd.gz isolinux.bin isolinux.cfg pup_412pupngo.sfs vmlinuz zdrv_412.sfs; do
  155. cp -f tmpmntpoint/$FILE isomaster/
  156. done
  157. umount tmpmntpoint
  158. http://www.murga-linux.com/puppy/viewtopic.php?p=473814#473814
  159. TEXT="You can now build the additional filestructure in directory http://www.murga-linux.com/puppy/viewtopic.php?p=473814#473814
  160. '$CURDIR/myadds'
  161. by either adding directly or place pet files in directory
  162. '$CURDIR/pets'.
  163. Do this before pressing OK/Enter.
  164. "
  165. message_fc
  166.  
  167. #check if pets placed in pets-dir
  168. PETS=$(ls pets/)
  169. echo $PETS
  170. if [ "$PETS" = "" ]; then
  171.   echo "empty"
  172. else
  173.   #unpack pets and move to myadds_412
  174.   for ARCHIVES in $PETS; do
  175.     cp -a $CURDIR/pets/${ARCHIVES} tmpmntpoint
  176.     cd tmpmntpoint
  177.     pet2tgz ${ARCHIVES}
  178.     tar -zxf ${ARCHIVES/.pet/}.tar.gz
  179.     cd ${ARCHIVES/.pet/}
  180.     cp -af * $CURDIR/myadds_412/
  181.     rm -rf $CURDIR/tmpmntpoint/*
  182.   done
  183. fi
  184.  
  185. #check for missing libs
  186. TEXT="Now I will try to test if some libraries are missing.
  187. This is not a fool-proof test - there might be some dependencies
  188. that can not be found directly."
  189. message_fc
  190.  
  191. find_libs
  192.  
  193. #create sfs-file with the new stuffhttp://www.murga-linux.com/puppy/viewtopic.php?p=473814#473814
  194. rm -f ${CURDIR}/isomaster/myadds_412.sfs    #clean up
  195. mksquashfs ${CURDIR}/myadds_412/ ${CURDIR}/isomaster/myadds_412.sfs -noappend
  196. http://www.murga-linux.com/puppy/viewtopic.php?p=473814#473814
  197. #rebuild the iso
  198. mkisofs -o ${CURDIR}/output/output.iso -jcharset iso-8859-1 -R -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table ${CURDIR}/isomaster
  199.  
  200. TEXT="Finished. You new ISO-image is in
  201. $CURDIR/output.
  202. Run in qemu (recommended!) or burn a cd and test it.
  203. After booting/login run 'firstboot', chose 'configure' and choose
  204. 'Install programs' - choose 'cancel' and 'exit'. At the prompt
  205. enter 'pkginstall.sh /mnt/cdrom/myadds_412.sfs' to install.
  206. Or reboot, create personal savefile - and the myadds_412.sfs
  207. will be loaded at next boot.
  208. "
  209. message_fc
Advertisement
Add Comment
Please, Sign In to add comment