Advertisement
Guest User

Untitled

a guest
Jul 26th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.78 KB | None | 0 0
  1. #!/usr/bin/bash
  2. set -e
  3. cat <<'EOF' > $HOME/.hadk.env
  4. export MER_ROOT="$HOME/mer"
  5. export ANDROID_ROOT="$MER_ROOT/android/droid"
  6. export VENDOR="motorola"
  7. export DEVICE="titan"
  8. export PORT_ARCH="armv7hl"
  9. EOF
  10. cat <<'EOF' >> $HOME/.mersdkubu.profile
  11. function hadk() { source $HOME/.hadk.env; echo "Env setup for $DEVICE"; }
  12. export PS1="HABUILD_SDK [\${DEVICE}] $PS1"
  13. hadk
  14. EOF
  15. cat <<'EOF' >> $HOME/.mersdk.profile
  16. function hadk() { source $HOME/.hadk.env; echo "Env. setup for $DEVICE"; }
  17. hadk
  18. EOF
  19. export MER_ROOT=$HOME/mer
  20. TARBALL=mer-i486-latest-sdk-rolling-chroot-armv7hl-sb2.tar.bz2
  21. curl -k -O https://img.merproject.org/images/mer-sdk/$TARBALL
  22. mkdir -p $MER_ROOT/sdks/sdk
  23. cd $MER_ROOT/sdks/sdk
  24. sudo tar --numeric-owner -p -xjf $HOME/$TARBALL
  25. echo "export MER_ROOT=$MER_ROOT" >> ~/.bashrc
  26. alias sdk=$MER_ROOT/sdks/sdk/mer-sdk-chroot' >> ~/.bashrc
  27. exec bash
  28. echo 'PS1="MerSDK $PS1"' >> ~/.mersdk.profile
  29. cd $HOME
  30. sdk
  31. +verbose Exiting the SDK
  32. exit
  33. +verbose Entering the SDK
  34. sdk
  35. +verbose Adding the curlfix repo
  36. sudo zypper ar http://repo.merproject.org/obs/home:/sledge:/mer/latest_i486/ \
  37. curlfix
  38. +verbose Adding the common repo
  39. sudo zypper ar http://repo.merproject.org/obs/nemo:/devel:/hw:/common/sailfish_latest_armv7hl/ \
  40. common
  41. +verbose Refreshing the curlfix repo
  42. sudo zypper ref curlfix
  43. sudo zypper dup --from curlfix
  44. +verbose Refreshing the common repo
  45. sudo zypper ref common
  46. sudo zypper dup --from common
  47. +verbose Installing android-tools createrepo and zip
  48. sudo zypper in android-tools createrepo zip
  49. TARBALL=ubuntu-trusty-android-rootfs.tar.bz2
  50. +verbose Downloading the Rootfs tarball for Android
  51. curl -O http://img.merproject.org/images/mer-hybris/ubu/$TARBALL
  52. UBUNTU_CHROOT=$MER_ROOT/sdks/ubuntu
  53. sudo mkdir -p $UBUNTU_CHROOT
  54. +verbose Unpacking the Rootfs tarball for Android into $UBUNTU_CHROOT
  55. sudo tar --numeric-owner -xvjf $TARBALL -C $UBUNTU_CHROOT
  56. +verbose Entering the HABUILD_SDK
  57. ubu-chroot -r $MER_ROOT/sdks/ubuntu
  58. +verbose Exiting the HABUILD_SDK
  59. exit
  60. +verbose "Enter your full name to present yourself to git"
  61. read name ; git --global user.name $name
  62. +verbose And now enter your emailadress.
  63. read email git --global user.email $name
  64. +verbose Making the bin directory for the repo command to be put into
  65. mkdir ~/bin
  66. +verbose Adding the bin directory to $PATH
  67. PATH=~/bin:$PATH
  68. +verbose Downloading the repo binary into ~/bin
  69. curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
  70. +verbose Making the repo binary executable
  71. chmod a+x ~/bin/repo
  72. +verbose Entering the HABUILD_SDK
  73. ubu-chroot -r $MER_ROOT/sdks/ubuntu
  74. +verbose Creating the Root directory for Android
  75. sudo mkdir -p $ANDROID_ROOT
  76. +verbose Changing owner to the root directory for Android to your user
  77. sudo chown -R $USER $ANDROID_ROOT
  78. +verbose Entering the root directory for Android
  79. cd $ANDROID_ROOT
  80. +verbose Initialising the hybris repo into $ANDROID_ROOT
  81. repo init -u git://github.com/mer-hybris/android.git -b hybris-12.1
  82. +verbose Creating the local_manifests directory
  83. mkdir $ANDROID_ROOT/.repo/local_manifests
  84. +verbose Entering the local_manifests directory
  85. cd $HOME/.repo/local_manifests/
  86. +verbose Creating the titan.xml file
  87. touch titan.xml
  88. +verbose Putting relevant repos to sync in the titan.xml file
  89. cat > titan.xml <<EOF
  90. <?xml version="1.0" encoding="UTF-8"?>
  91. <manifest>
  92. <project path="device/motorola/msm8226-common" name="CyanogenMod/android_device_motorola_titan" revision="cm-12.1" />
  93. <project path="device/motorola/msm8226-common" name="CyanogenMod/android_device_htc_scorpion_windy" revision="cm-12.1" />
  94. <project path="device/motorola/msm8226-common" name="CyanogenMod/android_device_htc_shinano-common" revision="cm-12.1" />
  95. <project path="device/motorola/msm8226-common" name="CyanogenMod/android_device_htc_msm8974-common" revision="cm-12.1" />
  96. <project path="device/motorola/msm8226-common" name="CyanogenMod/android_device_htc_common" revision="cm-12.1" />
  97. <project path="device/qcom/common" name="CyanogenMod/android_device_qcom_common" revision="cm-12.1" />
  98. <project path="hardware/motorola/thermanager" name="CyanogenMod/android_hardware_htc_thermanager" revision="cm-12.1" />
  99. <project path="kernel/motorola/msm8974" name="Nokius/android_kernel_htc_msm8974" revision="hybris-12.1" />
  100. <project path="vendor/motorola" name="TheMuppets/proprietary_vendor_htc" revision="cm-12.1" />
  101. <project path="rpm/" name="Nokius/droid-hal-titan" revision="master" />
  102. <project path="hybris/droid-configs" name="Nokius/droid-config-titan" revision="master" />
  103. <project path="hybris/droid-hal-version-endeavoru" name="Nokius/droid-hal-version-titan" revision="master" />
  104. </manifest>
  105. EOF
  106. +verbose Entering $ANDROID_ROOT
  107. cd $ANDROID_ROOT
  108. +verbose Syncing the repos that you added to the titan.xml file
  109. repo sync --fetch-submodules
  110. +verbose Resyncing again to make sure that you're fully up-to-date.
  111. repo sync --fetch-submodules
  112. cat > /home/$USER/mer/android/droid/hybris/hybris-boot/fixup-mountpoints << EOF
  113. #!/bin/bash
  114.  
  115. DEVICE=$1
  116. shift
  117.  
  118. +verbose "Fixing mount-points for device $DEVICE"
  119.  
  120. case "$DEVICE" in
  121.  
  122. "titan")
  123. sed -i \
  124. -e 's block/platform/msm_sdcc.1/by-name/fsg mmcblk0p21 ' \
  125. - -e 's block/platform/msm_sdcc.1/by-name/firmware mmcblk0p1 ' \
  126. + -e 's block/platform/msm_sdcc.1/by-name/modem mmcblk0p1 ' \
  127. -e 's block/platform/msm_sdcc.1/by-name/persist mmcblk0p29 ' \
  128. -e 's block/platform/msm_sdcc.1/by-name/userdata mmcblk0p38 ' \
  129. -e 's block/platform/msm_sdcc.1/by-name/system mmcblk0p36 ' \
  130. "$@" ;;
  131.  
  132. *)
  133. exit 1
  134. ;;
  135. esac
  136. EOF
  137. +verbose Done!
  138. +verbose Running source build/envsetup.sh
  139. source build/envsetup.sh
  140. export USE_CCACHE=1
  141. +verbose Running breakfast for Titan
  142. breakfast $DEVICE
  143. +verbose Running make to build hybris-hal
  144. make -j4 hybris-hal
  145. +verbose Running java -jar $HOME/mer/android/droid/out/host/linux-x86/framework/dumpkey.jar build/target/product/security/testkey.x509.pem build/target/product/security/cm.x509.pem build/target/product/security/cm-devkey.x509.pem > $HOME/mer/android/droid/out/target/product/$DEVICE/obj/PACKAGING/ota_keys_intermediates/keys in order for make to complete successfully
  146. java -jar $HOME/mer/android/droid/out/host/linux-x86/framework/dumpkey.jar build/target/product/security/testkey.x509.pem build/target/product/security/cm.x509.pem build/target/product/security/cm-devkey.x509.pem > $HOME/mer/android/droid/out/target/product/scorpion/obj/PACKAGING/ota_keys_intermediates/keys
  147. +verbose Done!
  148. +verbose Rerunning make to build hybris-hal once again
  149. make -j4 hybris-hal
  150. +verbose Showing the kernel config file built by hybris
  151. hybris/mer-kernel-check/mer_verify_kernel_config \
  152. ./out/target/product/$DEVICE/obj/KERNEL_OBJ/.config
  153. +verbose Building hybris-boot and hybris-recovery for your device
  154. make hybris-boot && make hybris-recovery
  155. +verbose Exiting the HABUILD_SDK into the Mer SDK
  156. exit
  157. SFE_SB2_TARGET=$MER_ROOT/targets/$VENDOR-$DEVICE-$PORT_ARCH
  158. TARBALL_URL=http://releases.sailfishos.org/sdk/latest/targets/targets.json
  159. TARBALL=$(curl $TARBALL_URL | grep "$PORT_ARCH.tar.bz2" | cut -d\" -f4)
  160. +verbose Downloading the SDK tarball for Sailfish OS
  161. curl -O $TARBALL
  162. +verbose Making a directory called SFE_SB2_TARGET
  163. sudo mkdir -p $SFE_SB2_TARGET
  164. +verbose Unpacking the downloaded tarball to the SFE_SB2_TARGET directory
  165. sudo tar --numeric-owner -pxjf $(basename $TARBALL) -C $SFE_SB2_TARGET
  166. +verbose Changing user priveligies to every file in the $SFE_SB2_TARGET directory
  167. sudo chown -R $USER $SFE_SB2_TARGET
  168. +verbose Entering the $SFE_SB2_TARGET directory
  169. cd $SFE_SB2_TARGET
  170. grep :$(id -u): /etc/passwd >> etc/passwd
  171. grep :$(id -g): /etc/group >> etc/group
  172. sb2-init -d -L "--sysroot=/" -C "--sysroot=/" \
  173. -c /usr/bin/qemu-arm-dynamic -m sdk-build \
  174. -n -N -t / $VENDOR-$DEVICE-$PORT_ARCH \
  175. /opt/cross/bin/$PORT_ARCH-meego-linux-gnueabi-gcc
  176. +verbose Rebuilding the rpm database
  177. sb2 -t $VENDOR-$DEVICE-$PORT_ARCH -m sdk-install -R rpm --rebuilddb
  178. sb2 -t $VENDOR-$DEVICE-$PORT_ARCH -m sdk-install -R zypper ar \
  179. -G http://repo.merproject.org/releases/mer-tools/rolling/builds/$PORT_ARCH/packages/ \
  180. mer-tools-rolling
  181. sb2 -t $VENDOR-$DEVICE-$PORT_ARCH -m sdk-install -R zypper ref --force
  182. cd $HOME
  183. +verbose Creating the Hello World-script...
  184. cat > main.c << EOF
  185. #include <stdlib.h>
  186. #include <stdio.h>
  187. int main(void) {
  188. printf("Hello, world!\n");
  189. return EXIT_SUCCESS;
  190. }
  191. EOF
  192. +verbose Compiling the Hello World script
  193. sb2 -t $VENDOR-$DEVICE-$PORT_ARCH gcc main.c -o test
  194. +verbose Running the Hello World script as a test which should show "Hello World!"
  195. sb2 -t $VENDOR-$DEVICE-$PORT_ARCH ./test
  196. sudo zypper ref; sudo zypper dup
  197. cd $HOME
  198. +verbose Making the directory called devel in $MER_ROOT
  199. sudo mkdir -p $MER_ROOT/devel
  200. +verbose Changing user priveligies to the devel directory
  201. sudo chown -R $USER mer/devel
  202. sb2 -t $VENDOR-$DEVICE-$PORT_ARCH -R -m sdk-install ssu ar common http://repo.merproject.org/obs/nemo:/devel:/hw:/common/sailfish_latest_armv7hl/
  203. cd $ANDROID_ROOT
  204. +verbose Running the build_packages script
  205. rpm/dhd/helpers/build_packages.sh
  206. +verbose Press Ctrl C to stop this process if you at some point end up with what looks as a freeze and rerun rpm/dhd/helpers/build_packages.sh
  207. +verbose Creating a directory called tmp
  208. mkdir -p tmp
  209. HA_REPO="repo --name=adaptation0-$DEVICE-@RELEASE@"
  210. KS="Jolla-@RELEASE@-$DEVICE-@ARCH@.ks"
  211. sed -e "s|^$HA_REPO.*$|$HA_REPO --baseurl=file://$ANDROID_ROOT/droid-local-repo/$DEVICE|" $ANDROID_ROOT/hybris/droid-configs/installroot/usr/share/kickstarts/$KS > tmp/$KS
  212. RELEASE=2.0.1.11
  213. EXTRA_NAME=-my1
  214. sudo mic create fs --arch $PORT_ARCH \
  215. --debug \
  216. --tokenmap=ARCH:$PORT_ARCH,RELEASE:$RELEASE,EXTRA_NAME:$EXTRA_NAME \
  217. --record-pkgs=name,url \
  218. --outdir=sfe-$DEVICE-$RELEASE$EXTRA_NAME \
  219. --pack-to=sfe-$DEVICE-$RELEASE$EXTRA_NAME.tar.bz2 \
  220. $ANDROID_ROOT/tmp/Jolla-@RELEASE@-$DEVICE-@ARCH@.ks
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement