KXStudio scripts and misc stuff
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

405 lines
12KB

  1. #!/bin/bash
  2. # Debian fix
  3. export PATH=/usr/sbin/:$PATH
  4. # Check dependencies
  5. if (which 7z > /dev/null); then true; else
  6. echo "7z not found, please install it"
  7. exit
  8. fi
  9. if (which cpio > /dev/null); then true; else
  10. echo "cpio not found, please install it"
  11. exit
  12. fi
  13. if (which debootstrap > /dev/null); then true; else
  14. echo "debootstrap not found, please install it"
  15. exit
  16. fi
  17. if (which gzip > /dev/null); then true; else
  18. echo "gzip not found, please install it"
  19. exit
  20. fi
  21. if (which lzma > /dev/null); then true; else
  22. echo "lzma not found, please install it"
  23. exit
  24. fi
  25. if (which mksquashfs > /dev/null); then true; else
  26. echo "mksquashfs not found, please install it"
  27. exit
  28. fi
  29. if (which xorriso > /dev/null); then true; else
  30. echo "xorriso not found, please install it"
  31. exit
  32. fi
  33. case $1 in
  34. squash)
  35. sudo debootstrap --arch=$3 $2 ~/livecd/custom http://archive.ubuntu.com/ubuntu/
  36. exit
  37. ;;
  38. custom)
  39. # sudo mount --bind /dev ~/livecd/custom/dev
  40. sudo rm -f ~/livecd/custom/etc/hosts
  41. sudo rm -f ~/livecd/custom/etc/resolv.conf
  42. sudo cp /etc/resolv.conf /etc/hosts ~/livecd/custom/etc/
  43. echo "run this now:
  44. mount -t proc none /proc/
  45. mount -t sysfs none /sys/
  46. mount -t devpts none /dev/pts
  47. export HOME=/root
  48. export LANG=C
  49. export LC_ALL=C
  50. unset LC_TIME
  51. "
  52. echo "
  53. SAVE THIS INFORMATION BELLOW, AND RUN IT ONE AT A TIME:
  54. # Update Sources
  55. apt-get update
  56. apt-get install software-properties-common wget
  57. add-apt-repository -y ppa:kxstudio-debian/kxstudio
  58. sed -i 's/bionic/trusty/' /etc/apt/sources.list.d/kxstudio-debian-ubuntu-kxstudio-bionic.list
  59. add-apt-repository -y ppa:plasmazilla/releases
  60. sed -i 's/bionic/artful/' /etc/apt/sources.list.d/plasmazilla-ubuntu-releases-bionic.list # FIXME: remove when bionic is supported
  61. apt-get update
  62. apt-get install kxstudio-repos kxstudio-repos-gcc5
  63. rm /etc/apt/sources.list.d/kxstudio-debian-ubuntu-kxstudio-bionic.list
  64. apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E6D4736255751E5D
  65. apt-get clean
  66. # Check /etc/apt/sources.list
  67. echo 'deb http://archive.ubuntu.com/ubuntu/ bionic main restricted universe multiverse
  68. # deb-src http://archive.ubuntu.com/ubuntu/ bionic main restricted universe multiverse
  69. deb http://archive.ubuntu.com/ubuntu/ bionic-updates main restricted universe multiverse
  70. # deb-src http://archive.ubuntu.com/ubuntu/ bionic-updates main restricted universe multiverse
  71. deb http://archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
  72. # deb-src http://archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
  73. deb http://security.ubuntu.com/ubuntu/ bionic-security main restricted universe multiverse
  74. # deb-src http://security.ubuntu.com/ubuntu/ bionic-security main restricted universe multiverse
  75. deb http://archive.canonical.com/ubuntu/ bionic partner
  76. # deb-src http://archive.canonical.com/ubuntu/ bionic partner
  77. # Neon repos, change to bionic LTS when available
  78. deb [arch=amd64] http://archive.neon.kde.org/user/lts/ xenial main
  79. # deb-src http://archive.neon.kde.org/user/lts/ xenial main
  80. # Stuff to delete later on
  81. deb http://archive.neon.kde.org/dev/unstable/ bionic main
  82. # deb-src http://archive.neon.kde.org/dev/unstable/ bionic main
  83. deb http://archive.ubuntu.com/ubuntu/ artful main restricted universe multiverse
  84. deb http://archive.ubuntu.com/ubuntu/ artful-updates main restricted universe multiverse
  85. deb http://security.ubuntu.com/ubuntu/ artful-security main restricted universe multiverse
  86. ' > /etc/apt/sources.list
  87. # Update System
  88. apt-get update; apt-get dist-upgrade
  89. # Base Install
  90. apt-get install --no-install-recommends ubuntu-standard laptop-detect os-prober \
  91. libpam-systemd command-not-found friendly-recovery nano ntfs-3g ufw uuid-runtime \
  92. manpages geoip-database bash-completion irqbalance powermgmt-base ppp pppconfig pppoeconf \
  93. cryptsetup lvm2 dkms fakeroot libc6-dev libc-dev kxstudio-meta-live-conflicts
  94. # Kernel Install
  95. apt-get install linux-lowlatency linux-image-lowlatency linux-headers-lowlatency kxstudio-meta-live-conflicts # skip grub install/configure to HDD here
  96. apt-get purge linux-headers-3.13.0-46 linux-headers-3.13.0-46-lowlatency linux-image-3.13.0-46-lowlatency
  97. apt-get clean
  98. # Install packages (KXStudio)
  99. apt-get install jackd2 kxstudio-meta-audio-plugins-collection kxstudio-desktop-neon kxstudio-meta-all kubuntu-restricted-extras kxstudio-meta-restricted-extras kxstudio-meta-live-conflicts
  100. # FIXME: graphics not installable on neon, fix later (also video needs tweaking)
  101. apt-get install jackd2 kxstudio-meta-audio-plugins-collection kxstudio-desktop-neon kxstudio-meta-audio kxstudio-meta-audio-plugins kubuntu-restricted-extras kxstudio-meta-restricted-extras kxstudio-meta-live-conflicts
  102. # Test
  103. rm /var/cache/apt/archives/wine-rt*
  104. # needed for a few gtk things
  105. apt-get install --no-install-recommends gnome-themes-standard
  106. apt-get update; apt-get dist-upgrade
  107. apt-get clean
  108. # 64bit fix
  109. dpkg --add-architecture i386
  110. apt-get update; apt-get dist-upgrade
  111. # Install extras
  112. apt-get install kxstudio-docs
  113. apt-get install indicator-cpufreq \
  114. sni-qt libgl1-mesa-dri libgl1-mesa-glx libegl1-mesa libglapi-mesa libgles2-mesa libglu1-mesa \
  115. sni-qt:i386 libgl1-mesa-dri:i386 libgl1-mesa-glx:i386 libegl1-mesa:i386 libglapi-mesa:i386 libgles2-mesa:i386 libglu1-mesa:i386
  116. # Remove deprecated/dummy
  117. apt-get purge kxstudio-meta-live-conflicts
  118. apt-get install calf-plugins-git zynaddsubfx-git
  119. apt-get purge ardour3
  120. apt-get purge amsynth-dssi drumkv1 samplv1 synthv1
  121. apt-get purge carla calf-plugins
  122. apt-get purge composite composite-data
  123. apt-get purge hydrogen-drumkits hydrogen-drumkits-effects fluid-soundfont-gm
  124. apt-get purge kxstudio-kernel-lowlatency
  125. apt-get purge flashplugin-installer
  126. # Cleanup
  127. apt-get autoremove
  128. apt-get clean
  129. dpkg -l | grep "rc "
  130. rm /boot/*liquorix*
  131. ## ---- PAUSE HERE ----- ##
  132. # Before installing ubiquity in the live session, you'll need to run this outside:
  133. $ sudo mkdir -p ~/livecd/cd/casper/
  134. $ sudo touch ~/livecd/cd/casper/filesystem.manifest-desktop
  135. $ sudo chmod 777 ~/livecd/cd/casper/filesystem.manifest-desktop
  136. $ sudo chroot ~/livecd/custom dpkg-query -W --showformat='\${Package} \${Version}\n' > ~/livecd/cd/casper/filesystem.manifest-desktop"
  137. # sudo mkdir -p ~/livecd/cd/casper/
  138. # sudo touch ~/livecd/cd/casper/filesystem.manifest-desktop
  139. # sudo chmod 777 ~/livecd/cd/casper/filesystem.manifest-desktop
  140. # sudo chroot ~/livecd/custom dpkg-query -W --showformat='${Package} ${Version}\n' > ~/livecd/cd/casper/filesystem.manifest-desktop
  141. echo "## ----- END PAUSE ----- ##
  142. # Now use locate
  143. apt-get clean
  144. # /usr/bin/updatedb.mlocate
  145. # Now install the liveDVD specific packages
  146. apt-get install ubiquity-frontend-kde casper lupin-casper discover jfsutils xfsprogs
  147. # Just in case you want to revert the live-dvd install action
  148. apt-get purge \
  149. apt-clone archdetect-deb btrfs-tools casper cifs-utils discover \
  150. discover-data dmraid dpkg-repack ecryptfs-utils jfsutils keyutils kpartx \
  151. kpartx-boot libdebian-installer4 libdiscover2 libdmraid1.0.0.rc16 \
  152. libecryptfs0 libnss3-1d localechooser-data lupin-casper python3-icu \
  153. python3-pam rdate sbsigntool ubiquity ubiquity-casper ubiquity-frontend-kde \
  154. ubiquity-ubuntu-artwork user-setup xfsprogs
  155. "
  156. sudo chroot ~/livecd/custom
  157. echo "done"
  158. exit
  159. ;;
  160. custom_end)
  161. echo "run this now:
  162. #rm -f /sbin/initctl
  163. #dpkg-divert --rename --remove /sbin/initctl
  164. rm -f /var/kxstudio/*
  165. apt-get clean
  166. rm -rf /tmp/*
  167. rm -f /etc/hosts /etc/resolv.conf
  168. ln -s /run/resolvconf/resolv.conf /etc/resolv.conf
  169. chmod 644 /root/.{b,p}*
  170. find /var/log -type f | while read file; do cat /dev/null | tee $file; done
  171. umount /dev/pts
  172. umount -lf /proc
  173. umount -lf /sys
  174. exit
  175. sudo nano ~/livecd/custom/root/.bash_history
  176. "
  177. exit
  178. ;;
  179. mksquash)
  180. sudo mkdir -p ~/livecd/cd/casper/
  181. cd ~/livecd/cd/casper/
  182. sudo su root -c "printf $(sudo du -sx --block-size=1 ~/livecd/custom | cut -f1) > ./filesystem.size"
  183. sudo touch ./filesystem.manifest
  184. sudo touch ./filesystem.manifest-remove
  185. sudo chmod 777 ./filesystem.manifest
  186. sudo chmod 777 ./filesystem.manifest-remove
  187. sudo chroot ~/livecd/custom dpkg-query -W --showformat='${Package} ${Version}\n' > ./filesystem.manifest
  188. if [ -f ./filesystem.manifest-desktop ]; then
  189. comm -3 <(cat ./filesystem.manifest | awk '{print $1}' | sort) <(cat ./filesystem.manifest-desktop | awk '{print $1}' | sort) > ./filesystem.manifest-remove
  190. fi
  191. sudo rm -f ./filesystem.squashfs ./filesystem.manifest-desktop
  192. sudo mksquashfs ~/livecd/custom ./filesystem.squashfs -noappend -comp xz
  193. echo "done"
  194. exit
  195. ;;
  196. mkart)
  197. if [ ! -f ~/livecd/iso-stuff.7z ]; then
  198. echo "Please copy iso-stuff.7z to ~/livecd before continuing"
  199. exit
  200. fi
  201. ISO_ARCH="$2"
  202. ISO_NAME="$3"
  203. if [ $ISO_ARCH"0" == "0" ]; then
  204. echo "usage: $0 mkart <arch> <distro>"
  205. exit
  206. fi
  207. if [ $ISO_NAME"0" == "0" ]; then
  208. echo "usage: $0 mkart $ISO_ARCH <distro>"
  209. exit
  210. fi
  211. sudo mkdir -p ~/livecd/cd
  212. cd ~/livecd/cd
  213. sudo 7z x -y ../iso-stuff.7z
  214. sudo sed "s/X-ISO_ARCH-X/$ISO_ARCH/" -i ~/livecd/cd/README.diskdefines
  215. sudo sed "s/X-ISO_NAME-X/$ISO_NAME/" -i ~/livecd/cd/README.diskdefines
  216. sudo sed "s/X-ISO_NAME-X/$ISO_NAME/" -i ~/livecd/cd/isolinux/txt.cfg
  217. sudo mkdir -p ~/livecd/cd/.disk/
  218. if [ "$ISO_ARCH" == "i386" ]; then
  219. sudo su root -c 'echo "KXStudio 14.04.5 (Live 32bit)" > .disk/info'
  220. else
  221. sudo su root -c 'echo "KXStudio 14.04.5 (Live 64bit)" > .disk/info'
  222. fi
  223. # sudo su root -c 'echo "Live-MOD 2015-03" > .disk/info'
  224. sudo su root -c 'echo "http://kxstudio.sourceforge.net/Documentation:KXStudio14045:ReleaseNotes" > .disk/release_notes_url'
  225. echo "Please edit these files manually:
  226. ~/livecd/cd/.disk/info
  227. ~/livecd/cd/.disk/release_notes_url
  228. ~/livecd/cd/README.diskdefines
  229. ~/livecd/cd/isolinux/txt.cfg
  230. ~/livecd/cd/preseed/live.seed
  231. "
  232. exit
  233. ;;
  234. mkboot)
  235. sudo mkdir -p ~/livecd/cd/casper/
  236. cd ~/livecd/
  237. sudo rm -f cd/casper/vmlinuz cd/casper/vmlinuz.efi cd/casper/initrd.lz cd/casper/initrd_tmp.gz
  238. sudo cp custom/boot/vmlinuz-* cd/casper/vmlinuz
  239. sudo cp custom/boot/vmlinuz-* cd/casper/vmlinuz.efi
  240. sudo cp custom/boot/initrd.img-* cd/casper/initrd_tmp.gz
  241. cd ~/livecd/cd/casper
  242. sudo rm -rf ext
  243. sudo mkdir ext
  244. cd ext
  245. sudo su root -c 'gzip -cd ../initrd_tmp.gz | cpio -i'
  246. # fix links
  247. LINKS=`find . -type l`
  248. for i in $LINKS; do
  249. FILE=`readlink $i`
  250. if [ "$FILE" == "busybox" ]; then
  251. FILE="./bin/busybox"
  252. elif [ "$FILE" == "lvm" ]; then
  253. FILE="./sbin/lvm"
  254. fi
  255. sudo rm "$i"
  256. if [ -f "./$FILE" ]; then
  257. sudo cp -v "./$FILE" "$i"
  258. else
  259. sudo cp -v "../../../custom/$FILE" "$i"
  260. fi
  261. done
  262. sudo su root -c 'find . | cpio --dereference -o -H newc | lzma -7 > ../initrd.lz'
  263. cd ..
  264. sudo rm -rf ext initrd_tmp.gz
  265. echo "done"
  266. exit
  267. ;;
  268. md5sum)
  269. cd ~/livecd/cd
  270. sudo chmod 777 -R .
  271. sudo rm -f md5sum.txt MD5SUMS
  272. sudo su root -c "find . -type f -print0 | xargs -0 md5sum > ../md5sum.txt"
  273. sudo mv ../md5sum.txt .
  274. echo "done"
  275. exit
  276. ;;
  277. iso)
  278. ARG2="$2"
  279. ARG3="$3"
  280. if [ "$ARG2""0" == "0" ]; then
  281. echo "usage: $0 iso <filename> <name>"
  282. exit
  283. fi
  284. if [ "$ARG3""0" == "0" ]; then
  285. echo "usage: $0 iso <filename> <name>"
  286. exit
  287. fi
  288. cd ~/livecd/cd
  289. # i386 ends on -boot-info-table
  290. sudo xorriso -as mkisofs \
  291. -r \
  292. -V "$ARG3" \
  293. -o ~/livecd/"$ARG2".iso \
  294. -J \
  295. -isohybrid-mbr isolinux/isohdpfx.bin \
  296. -partition_offset 16 \
  297. -joliet-long \
  298. -cache-inodes \
  299. -b isolinux/isolinux.bin \
  300. -c isolinux/boot.cat \
  301. -no-emul-boot \
  302. -boot-load-size 4 \
  303. -boot-info-table \
  304. -eltorito-alt-boot \
  305. -e boot/grub/efi.img \
  306. -no-emul-boot \
  307. -isohybrid-gpt-basdat \
  308. -isohybrid-apm-hfsplus \
  309. .
  310. echo "done"
  311. exit
  312. ;;
  313. clean)
  314. sudo umount /tmp/livecd/
  315. sudo umount ~/livecd/squashfs/
  316. sudo rm -rf /tmp/livecd/
  317. sudo rm -rf ~/livecd/
  318. echo "done"
  319. exit
  320. ;;
  321. *)
  322. echo "usage: $0 <cmd>
  323. 1 - squash <version> <arch> [version=trusty] [arch=i386/amd64]
  324. 2 - custom
  325. 3 - custom_end
  326. 4 - mksquash
  327. 5 - mkart <arch> <distro-name> [arch=i386/amd64] [distro=KXStudio (no spaces!)]
  328. 6 - mkboot
  329. 7 - md5sum
  330. 8 - iso <filename> <name> [file/name=KXStudio_14.04_32bit]
  331. x - clean
  332. "
  333. exit
  334. ;;
  335. esac