Advertisement
Guest User

Untitled

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