From 013c87dc391279dae3508206f58c49c28d45a2c9 Mon Sep 17 00:00:00 2001 From: a7r3 Date: Sun, 11 Dec 2016 17:27:11 +0530 Subject: [PATCH] Enhancements 23 * curl command for downloading upScriBt.sh decides the Internet Connectivity - If it downloaded upScriBt successfully, then ONLINE, else OFFLINE * upScriBt is now force-updated, no checks - Removed USB_VER since it's of no use * CCache Setup working now. - File to grep not mentioned in the grep command, so the output was stuck - Prevent Repeated CCache Additions, working properly - Add CCache configs to only one file, preferred to be in .profile, so swapped the order in 'for' loop * Add prompt for assigning the 'out' directory to some other drive / directory * Fix incomplete Terminal title in the Build option - Before -> _ : In progress - After -> rom_device : In progress * DEPRECATE README.md for Wiki A Wiki Section has been made as a replacement for this file. README.md serves as a minimal description for the project, and links to the Wiki --- README.md | 263 +--------------------------------------------------- ROM.sh | 76 ++++++++++----- VERSION | 2 +- upScriBt.sh | 1 - 4 files changed, 54 insertions(+), 288 deletions(-) diff --git a/README.md b/README.md index cb12b18..90cf7ae 100644 --- a/README.md +++ b/README.md @@ -9,267 +9,8 @@ Ready to use. Extensive Testing needed. **Supports Ubuntu & Debian based Distros, and ArchLinux** -**Tip!** : **ROMNIS** - **ROM** **N**ame **I**n **S**ource - eg. cm, bliss, candy, crdroid etc. +To start with, read the ScriBt wiki, located here -ScriBt consists of five main Actions: - -#1. Init - -a. **Choose** a ROM - -b. **Initialize** its Repo - -c. **Add** a local_manifest for Device Specfic Additions / Changes - -#2. Sync - -**Sync** the Sources - Setting Sync Options / Flags available - -#3. Pre Build - -**The Biggest Part/Function of ScriBt** - -a. **Add Device** to ROM Vendor - -b. Make an **Interactive Makefile** under the Device Tree (Identifiable by ROMs BuildSystem) - - * This was created in order to prevent unnecessary modifications to already present files in the Device Tree and messing it up - - * Idea came into existence, When I saw most of the ROMs (... not having ```products``` folder in ROM vendor && excluding AOSP-CAF/AOSP-RRO) having these lines in one of the BuildSystem's files... - - ```# A ROMNIS build needs only the ROMNIS product makefiles.``` - - ```ifneq ($(ROMNIS_BUILD),) - all_product_configs := $(shell ls device/*/$(ROMNIS_BUILD)/ROMNIS.mk)``` - -#4. Build - -a. Build the Entire ROM - - * **Clean** /out Entirely or only Staging Directories - - * **Start** Build - -b. Make a Particular Module - -c. Setup **CCACHE** - -d. Give **comments** based on the Final Build Status - - * Build Success - - * Arbitrary Error (Can't be helped due to entropy of increase in errors which increases day by day :P) - -#5. Tools - -a. Install Build Dependencies based on Distro Version - -b. Install / Configure **Java** - -c. Setup **android-51** rules (For proper usage of ADB) - -d. Revert to make 3.81 - -e. CCACHE Setup - -f. Add/Update Git Credentials - -#6. Automated Cherry Picking - -# prefGen - -** aka Config Generator ** -* After work's done, ScriBt saves the Configurations for that session, so that it could be automated next time... -This is done on User's wish. -* User should enter the function sequence though (under function automate), Information Gathering is done by ```prefGen``` - -As said before, -#Extensive Testing is needed. - - -#Usage -``` -bash ROM.sh -``` - -##### Why not . /ROM.sh ? -The script terminates with ```exit``` after its run. Unless you run the script under a new shell, it will close your existing shell. - -#What do the colors mean ? - -![Colors](https://cloud.githubusercontent.com/assets/14874906/20798870/6f6693e0-b806-11e6-81cc-9bde431a4e5a.png) - -[!] in.. - - RED - The Particular Task has Failed / User has Entered an Incorrect Value - - BLUE - Information - - GREEN - Task Completed - - YELLOW - Task to be under Execution - - PINK - AutoBot speaks - -[?] in.. - - RED - A Question is asked - -[>] in.. - - CYAN - An Answer is Expected :P - -[#] in.. - - PINK - Root Access Prompt - -This method of coloring is **Relevant_Coloring** and is inspired from [a scene in Person of Interest](https://goo.gl/photos/s8YpQL1eBxSYwCWS7) and ADB Logs on a phone (Log types like E for Error, F for Fatal etc.) - -#Automation Notes - -Users can add their own commands in the default sequence ( I do it ) - -For Automating ScriBt - -1. PREF.rc must have your Desired Values for all Variables listed - -2. Enter this on Terminal to Start with Automation - -``` -bash ROM.sh automate -``` - -#####Functions that can be automated - -* sync -* pre_build **^** -* build -* the_cherries - -**^** - The Device Tree must be Compatible with the ROM you're building (Extra Toolchain Configs, Overlays etc. **ROMNIS-fying is taken care of in Point 3b** ) Else, Issues :) :P - -#Variables necessary for Automation - -Since Vars have been removed from PREF.rc, those info will be seperately provided by me in the snippet below... - -https://gist.github.com/a7r3/9fdbf9cca66c339cc87858960149ac09 - -#Transferability - -```bash ROM.sh cd ``` - -1st Parameter - Indicates that you want to transfer it - alias is 'cd' to make it similiar with the 'cd' command - -2nd Parameter - The directory to which you need to transfer ScriBt - -Make sure you enter a proper directory, which has **read/write permissions**. This action will **transfer** ScriBt to the directory mentioned by the user as well as **execute** it from that directory. - -If you want to automate the ScriBt after changing directory, then 3rd Parameter should be 'automate'. It'd look like this... - -```bash ROM.sh cd automate``` - -# Updates - -ScriBt is updated on the basis of the Version Number mentioned in a file named VERSION - -**Do not try to EDIT it** - -If the Version Number in GitHub is more than the Local Version number, then ScriBt will prompt the user to update. -If there are modifications present in the old version, then ScriBt moves it to a folder named 'old'. You will find your old Scripts there. - -```upScriBt``` does the Updating work. - -**ROM.sh** first checks for a newer version of upScriBt.sh and **downloads it** if available. -**upScriBt.sh then **checks updates** for the other files on the basis of the above Procedure - -#Device Types - -* ```full``` - This indicates that the Device has **Adequate Storage Space** for building Entire Android System for it -* ```mini``` - This indicates that the Device has **Low Storage Space**, so only Android Essentials are built ( Fewer Apps and Stuff ) - -* **common_full_phone, common_mini_phone** - An Android SmartPhone -* **common_full_tablet, common_mini_tablet, common_tablet** - An Android Tablet -* **common_full_tablet_lte** - A Tablet with LTE (4G) Functionality -* **common_full_tablet_wifionly** - A Tablet with Wi-Fi functionality -* **common_full_tv, common_mini_tv** - Android TV -* **common_full_hybrid_wifionly** - Android Device with any Size ( Phone / Tablet ) ( used if Device Type is unknown ) - -* NOTE : IF you're building for a Phone and common_full_phone / common_mini_phone isn't in the list, then press Enter (Leave Blank) as the ROM will consider the Device as a Phone. - -#Building Android - -* **Jack** was introduced as a **Toolchain** from MarshMallow onwards for **Apps and Frameworks**. - - Uses a Java VM for compilation of Java Source Code (.java) to '.dex' (**D**alvik **Ex**ecutable) files - - Recommended for Systems with >8GB RAM. - - Systems with 4GB RAM can use it too, but it may cause lag during compilation, so using Swap is recommended for such users. - -* **Ninja** was introduced from Android Nougat (7.x.x) as an alternative **Build System**. - - No compatibility requirements. - - Some features of it are quicker incremental builds, and showing progress of the build on compilation - -* Companions for Ninja (iirc), which were introduced in Nougat are... - - **Kati** - https://android.googlesource.com/platform/build/kati/#kati - (AFAIK, It Generates a .ninja file, in BluePrint Language, which guides through the build process...) - - **Soong** - https://android.googlesource.com/platform/build/soong#Soong - - **BluePrint** - https://android.googlesource.com/platform/build/blueprint/#Blueprint-Build-System - (A Language...) - -So, the ways of building Android are... - -* Using **Normal** Build System - - **with** Jack Toolchain (MarshMallow onwards) - - **without** Jack Toolchain (Till Nougat) -* Using **Ninja** Build System - - **with** Jack Toolchain (Nougat onwards) - - **without** Jack Toolchain (Nougat onwards) - -#Contributors - -* Arvindraj "a7r3" (Myself) -* Adrian DC "AdrianDC" -* Akhil Narang "akhilnarang" -* Tom Radtke "CubeDev" -* nosedive - -#Supported ROMs - -1. AICP -2. AOKP -3. AOSiP -4. AOSP-CAF -5. AOSP-RRO -6. BlissRoms -7. CandyRoms -8. CarbonROM -9. crDroid -10. Cyanide-L -11. CyanogenMod -12. DirtyUnicorns -13. Flayr OS -14. Krexus-CAF -15. OctOs -16. OmniROM -17. Orion OS -18. OwnROM -19. PAC-ROM -20. AOSPA -21. Resurrection Remix -22. SlimRoms -23. Temasek -24. GZR Tesla -25. Tipsy OS -26. GZR Validus -27. VanirAOSP -28. XenonHD -29. XOSP -30. Zephyr-Os - -**Nexus Only ROMs** - -31. Krexus -32. Nitrogen OS -33. PureNexus - -**More ROMs will be added** +https://github.com/a7r3/ScriBt/wiki #Happy ScriBting! diff --git a/ROM.sh b/ROM.sh index 4b75be1..c47ebb6 100644 --- a/ROM.sh +++ b/ROM.sh @@ -143,14 +143,20 @@ function set_ccache() # D set_ccvars function set_ccvars() # D 4,5 { - echo -e "${INF} \nCCACHE Size must be >50 GB.\n Specify the Size (Number) for Reservation of CCACHE (in GB) : \n"; + echo -e "\n${INF} Specify the Size (Number) for Reservation of CCACHE (in GB)\n${INF} CCACHE Size must be >15-20 GB for ONE ROM\n"; read -p $'\033[1;36m[>]\033[0m ' CCSIZE; - echo -e "${INF} Create a New Folder for CCACHE and Specify it's location from / : \n"; + echo -e "\n${INF} Create a New Folder for CCACHE and Specify it's location from /\n"; read -p $'\033[1;36m[>]\033[0m ' CCDIR; - for RC in .bashrc .profile; do - if [ -f ${HOME}/${RC} ] && [[ $(grep -c 'USE_CCACHE\|CCACHE_DIR') != "1" ]]; then - echo -e "export USE_CCACHE=1\nexport CCACHE_DIR=${CCDIR}" >> ${HOME}/${RC}; - . ${HOME}/${RC}; + for RC in .profile .bashrc; do + if [ -f ${HOME}/${RC} ]; then + if [[ $(grep -c 'USE_CCACHE\|CCACHE_DIR' ${HOME}/${RC}) == 0 ]]; then + echo -e "export USE_CCACHE=1\nexport CCACHE_DIR=${CCDIR}" >> ${HOME}/${RC}; + . ${HOME}/${RC} &> /dev/null; + echo -e "\n${SCS} CCACHE Specific exports added in ${CL_WYT}${RC}${NONE}"; + else + echo -e "\n${SCS} CCACHE Specific exports already enabled in ${CL_WYT}${RC}${NONE}"; + fi + break; # One file, and its done fi done set_ccache; @@ -297,6 +303,7 @@ function sync() # 2 function device_info() # D 3,4 { + echo -ne "\033]0;ScriBt : Device Info\007"; [[ ! -z ${ROMV} ]] && export ROMNIS="${ROMV}"; # Change ROMNIS if Zephyr or Flayr if [ -d ${CALL_ME_ROOT}/vendor/${ROMNIS}/config ]; then CNF="vendor/${ROMNIS}/config"; @@ -339,10 +346,10 @@ function init_bld() # D 3,4 function pre_build() # 3 { - [ ! -z "$automate" ] && teh_action 3; [ -z "$action_1" ] && rom_select; init_bld; device_info; + [ ! -z "$automate" ] && teh_action 3; DEVDIR="device/${SBCM}/${SBDEV}"; function vendor_strat_all() @@ -604,9 +611,9 @@ function pre_build() # 3 function build() # 4 { if [ -d .repo ]; then - [ ! -z "$automate" ] && teh_action 4; [ -z "$action_1" ] && rom_select; [ -z "$action_2" ] && device_info; + [ ! -z "$automate" ] && teh_action 4; else echo -e "${FLD} ROM Source Not Found (Synced)\n${FLD} Please perform an init and sync before doing this"; exitScriBt 1; @@ -728,20 +735,44 @@ function build() # 4 ST="Selected Method"; shut_my_mouth MK "$ST"; case "$SBMK" in "make") - echo -e "${QN} Number of Jobs / Threads"; + echo -e "\n${QN} Number of Jobs / Threads"; BCORES=$(grep -c ^processor /proc/cpuinfo); echo -e "${INF} Maximum No. of Jobs -> ${CL_WYT}${BCORES}${NONE}"; ST="Number of Jobs"; shut_my_mouth NT "$ST"; if [[ "$SBNT" > "$BCORES" ]]; then - echo -e "${FLD} Invalid Response\n"; + echo -e "\n${FLD} Invalid Response\n"; echo -e "${INF} Restart ScriBt from here\n" exitScriBt 1; fi ;; "mka") BCORES="" ;; - *) echo -e "${FLD} Invalid Response\n${INF} Restart ScriBt from here"; + *) + echo -e "\n${FLD} No response received\n"; + echo -e "${EXE} Using ${CL_WYT}mka${NONE}"; + SBMT="mka"; BCORES=""; + ;; esac - echo -e "${QN} Wanna Clean the /out before Building\n${INF} 1 - Remove Staging Dirs | 2 - Full Clean\n"; + echo -e "${QN} Want to keep /out in another directory ${CL_WYT}[y/n]${NONE}"; + echo -e "${INF} Keeping /out in another drive ensures faster builds. But it is ${CL_WYT}not a compulsion${NONE}\n"; + ST="Another /out dir ?"; shut_my_mouth OD "$ST"; + case "$SBOD" in + [Yy]) + echo -e "${INF} Enter the Directory location from / - an ${CL_WYT}out${NONE} folder will be created under that directory\n"; + ST="/out location"; shut_my_mouth OL "$ST"; + if [ -d "$SBOL" ]; then + cd $SBOL; + [ ! -d out ] && mkdir out; + export OUT_DIR="${SBOL}/out"; + cd ${CALL_ME_ROOT}; + else + echo -e "${INF} /out location is unchanged"; + fi + ;; + [Nn]) + echo -e "${INF} /out location is unchanged"; + ;; + esac + echo -e "${QN} Want to Clean the /out before Building\n${INF} 1 - Remove Staging Dirs | 2 - Full Clean | Others - No cleaning\n"; ST="Option Selected"; shut_my_mouth CL "$ST"; if [[ $(grep -c 'BUILD_ID=M\|BUILD_ID=N' ${CALL_ME_ROOT}/build/core/build_id.mk) == "1" ]]; then echo -e "${QN} Use Jack Toolchain ${CL_WYT}[y/n]${NONE}\n"; @@ -752,7 +783,7 @@ function build() # 4 esac fi if [[ $(grep -c 'BUILD_ID=N' ${CALL_ME_ROOT}/build/core/build_id.mk) == "1" ]]; then - echo -e "${QN} Use Ninja to build Android ${CL_WYT}[y/n]${NONE}"; + echo -e "${QN} Use Ninja to build Android ${CL_WYT}[y/n]${NONE}\n"; ST="Use Ninja"; shut_my_mouth NJ "$ST"; case "$SBNJ" in [yY]) @@ -1093,6 +1124,7 @@ function teh_action() # Takes ya Everywhere within ScriBt case "$2" in "COOL") echo -ne "\033]0;${ROMNIS}_${SBDEV} : Success\007"; [ -z "$automate" ] && exitScriBt 0 ;; "FAIL") echo -ne "\033]0;${ROMNIS}_${SBDEV} : Fail\007"; [ -z "$automate" ] && exitScriBt 1 ;; + [qm]m) exitScriBt 0 ;; esac ;; *) @@ -1129,8 +1161,6 @@ function the_start() # 0 echo -e "\n${QN} Before Starting off, shall I remember the responses you'll enter from now \n${INF} So that it can be Automated next time\n"; read -p $'\033[1;36m[>]\033[0m ' RQ_PGN; (set -o posix; set) > ${TV1}; -# echo -e "\n${EXE} Prompting for Root Access\n"; -# sudo -p $'\033[1;35m[#]\033[0m ' echo -e "\n${SCS} Root access OK. You won't be asked again"; [[ "$(pwd)" != "/" ]] && export CALL_ME_ROOT="$(pwd)" || export CALL_ME_ROOT=""; echo -e "\n${EXE} ./action${CL_LRD}.SHOW_LOGO${NONE}"; sleep 2; @@ -1150,6 +1180,7 @@ function the_start() # 0 # VROOM! DNT=`date +'%d/%m/%y %r'`; +echo -ne "\033]0;ScriBt : The Beginning\007"; # Load RIDb and Colors if [ -f ROM.rc ]; then . $(pwd)/ROM.rc; @@ -1166,17 +1197,12 @@ FLD="${CL_LRD}[!]${NONE}"; EXE="${CL_YEL}[!]${NONE}"; QN="${CL_LRD}[?]${NONE}"; -# Update the Updater! -LUSB_VER=`grep 'USB_VER' upScriBt.sh | awk '{print $3}'`; # Local Version of Updater -curl -s -o up.sh https://raw.githubusercontent.com/a7r3/ScriBt/master/upScriBt.sh; # Download the Remote Version of Updater -RUSB_VER=`grep 'USB_VER' up.sh | awk '{print $3}'`; # Remote Version of Updater -if [[ "$RUSB_VER" > "$LUSB_VER" ]]; then - mv -f up.sh upScriBt.sh; # Update eet! -else - rm -rf up.sh; # Good to go! -fi +# Download the Remote Version of Updater, determine the Internet Connectivity by working of this command +curl -fs -o upScriBt.sh https://raw.githubusercontent.com/a7r3/ScriBt/master/upScriBt.sh && \ + echo -e "\n${SCS} Internet Connectivity : ONLINE"|| \ + echo -e "\n${FLD} Internet Connectivity : OFFINE\n\n${INF} Please connect to the Internet for better functioning of ScriBt"; -# Update us now +# Update ScriBt source upScriBt.sh $@; # Where am I ? diff --git a/VERSION b/VERSION index 6477a57..a4c3d07 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.40 +1.41 diff --git a/upScriBt.sh b/upScriBt.sh index 13666bf..b1c0552 100644 --- a/upScriBt.sh +++ b/upScriBt.sh @@ -2,7 +2,6 @@ #===========================< upScriBt >===============================# #===========< Copyright 2016, Arvindraj Thangaraj - "a7r3" >===========# #====================< Part of Projekt ScriBt >========================# -# USB_VER 1 RVER=`curl https://raw.githubusercontent.com/a7r3/ScriBt/master/VERSION -s`; LVER="cat VERSION";