Advertisement
metalx1000

Create an ARM IMG of Slitaz for Chrooting on Android

Feb 3rd, 2015
491
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.01 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. dir=$PWD
  4. img="slitaz_arm.img"
  5. url="http://mirror.switch.ch/ftp/mirror/slitaz/arm/rpi/slitaz-rpi-base-20140329.tar.bz2"
  6. pkg_url="http://cook.slitaz.org/cross/arm/packages/"
  7. spk_version="$(wget $pkg_url -q -O-|grep spk|cut -d\" -f4 )"
  8. bz2="slitaz_arm.tar.bz2"
  9. mnt="mnt"
  10. tmp="slitaz-rpi-base-20140329"
  11. tmp2="tmp"
  12. img_size=400000
  13.  
  14. #check if root user
  15. if [[ $EUID -ne 0 ]]; then
  16.   echo "You must be a root user"
  17.   echo "Trying to restart script as sudo"
  18.   sudo $0
  19.   exit
  20. fi
  21.  
  22. echo "checking if ARM emulation is available"
  23. if [ ! -f /usr/bin/qemu-arm-static ]
  24. then
  25.   apt-get install binfmt-support qemu qemu-user-static -y
  26. fi
  27.  
  28. echo "Downloading Slitaz Arm"
  29. wget "$url" -O $bz2
  30. tar xvjf $bz2
  31.  
  32. echo "Creating empty img file..."
  33. dd bs=512 count=$img_size if=/dev/zero of=$img
  34. mkfs.ext2 $img
  35.  
  36. echo "Mounting IMG..."
  37. mkdir $mnt
  38. mount $img $mnt
  39.  
  40. echo "Moving File System to IMG..."
  41. cp -pfr $tmp/rootfs/* $mnt
  42.  
  43. echo "Added DNS to /etc/resolv.conf"
  44. echo "nameserver 8.8.8.8" > $mnt/etc/resolv.conf
  45.  
  46. echo "Adding ARM Emulation for x86..."
  47. cp /usr/bin/qemu-arm-static $mnt/usr/bin
  48.  
  49. echo "Updating SPK Package Manager..."
  50. mkdir $tmp2
  51. cd $tmp2
  52. wget ${pkg_url}${spk_version} -O spk.tazpkg
  53. cat spk.tazpkg|cpio -i -H newc -d
  54. unlzma fs.cpio.lzma
  55. cat fs.cpio|cpio -i -H newc -d
  56. cp -pvfr ./fs/* ../$mnt
  57. cd $dir
  58.  
  59. clear
  60. echo """
  61.  Welcome to your ARM system.
  62.  Make Changes that you want.
  63.  When you exit the IMG file can be copied to your phone.
  64.  
  65.  Package Manager is spk.
  66.  examples:
  67.        spk-up
  68.        spk --add nmap
  69. """
  70.  
  71. chroot $mnt sh
  72.  
  73. echo "Clean Up..."
  74. umount $mnt
  75. rm -fr $tmp $tmp2 $mnt
  76. rm $bz2
  77.  
  78. echo """
  79. ARM IMG of Slitaz has been created.
  80. Please place $img on your Phone or Tablet for Chrooting.
  81. Mount with a command like this:
  82. busybox mount -o loop slitaz_img.img slitaz
  83.  
  84. Other useful info:
  85. export PATH=$PATH:/usr/bin:/bin
  86.  
  87. busybox mount --bind /dev slitaz/dev
  88. mount -t devpts devpts slitaz/dev/pts
  89. mount -t proc proc slitaz/proc
  90. mount -t sysfs sysfs slitaz/sys
  91.  
  92. """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement