Skip to content

Commit

Permalink
Enhancements 21
Browse files Browse the repository at this point in the history
* Introducing Updates!
        - ScriBt checks updates for a newer version based on the Version number mentioned in the VERSION file
        - If Version in the Remote is greater than the Local Version, then User is prompted whether to update ScriBt
        - Work is done by the script upScriBt.sh

ROM.sh first checks for changes in upScriBt.sh and updates it if present.
upScriBt.sh then checks updates based on the above procedure.

* Solve a Pre-Build bug

        I still don't know why, but the first 'if' on function device_info (Now Removed) gets the Value of ROMV to be non-zero. Puzzling!
        So I replaced that check with the ROM Selection Number SBRN instead. I'd look onto it soon.

* Correct a ROM Selection Number typo in vendor_strat_all

* sudo is known to be temporary. A sudo session only lasts for 5-15 minutes depending on the Linux Distro. So removed that single prompt at the start Temporarily.

* NEW SYMBOL

        [#] in PINK color means the 'sudo' prompt. Replaced the '[sudo] password for user:' prompt with this one to make it look better
  • Loading branch information
a7r3 committed Nov 25, 2016
1 parent 68fab43 commit 53e5eb0
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 24 deletions.
18 changes: 18 additions & 0 deletions README.md
Expand Up @@ -117,6 +117,10 @@ bash ROM.sh

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
Expand Down Expand Up @@ -162,6 +166,20 @@ If you want to automate the ScriBt after changing directory, then 3rd Parameter

```bash ROM.sh cd <directory> 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 would prompt the user to update.
If there are modifications present in the old version, then ScriBt moves it to a folder named 'old'. You may see your old Scripts there.

```upScriBt``` does the Updating work.

**ROM.sh** first checks for a newer version of upScriBt.sh and **downloads it** if present.
**upScriBt.sh then **checks updates** for the other files on the basis of above Procedure

#Device Types

* ```full``` - This indicates that the Device has **Adequate Storage Space** for building Entire Android System for it
Expand Down
62 changes: 38 additions & 24 deletions ROM.sh
Expand Up @@ -287,7 +287,7 @@ function sync() # 2

function device_info() # D 3,4
{
[ ! -z "${ROMV}" ] && export ROMNIS="${ROMV}"; # Change ROMNIS
[[ "${SBRN}" =~ 13|30 ]] && export ROMNIS="${ROMV}"; # Change ROMNIS if Zephyr or Flayr
if [ -d ${CALL_ME_ROOT}/vendor/${ROMNIS}/config ]; then
CNF="vendor/${ROMNIS}/config";
elif [ -d ${CALL_ME_ROOT}/vendor/${ROMNIS}/configs ]; then
Expand Down Expand Up @@ -337,7 +337,7 @@ function pre_build() # 3
function vendor_strat_all()
{
case "$SBRN" in
12|27) cd vendor/${ROMV} ;;
13|30) cd vendor/${ROMV} ;;
*) cd vendor/${ROMNIS} ;;
esac
echo -e "${CL_WYT}=========================================================${NONE}\n";
Expand Down Expand Up @@ -804,7 +804,7 @@ function tools() # 5
zlib1g-dev:i386 libbz2-dev libbz2-1.0 libghc-bzlib-dev ) ;;
esac
# Install 'em all
sudo apt-get install -y ${COMMON_PKGS[*]} ${DISTRO_PKGS[*]};
sudo -p $'\033[1;35m[#]\033[0m ' apt-get install -y ${COMMON_PKGS[*]} ${DISTRO_PKGS[*]};
} # installdeps

function installdeps_arch()
Expand Down Expand Up @@ -835,7 +835,7 @@ function tools() # 5
# look for conflicting packages and uninstall them
for item in ${PKGS_CONFLICT}; do
if pacman -Qq ${item} &> /dev/null; then
sudo pacman -Rddns --noconfirm ${item};
sudo -p $'\033[1;35m[#]\033[0m ' pacman -Rddns --noconfirm ${item};
sleep 3;
fi
done
Expand All @@ -855,14 +855,14 @@ function tools() # 5
echo -e "${CL_WYT}================================================================${NONE}\n";
case "${PKGMGR}" in
"apt")
sudo update-alternatives --config java;
sudo -p $'\033[1;35m[#]\033[0m ' update-alternatives --config java;
echo -e "\n${CL_WYT}================================================================${NONE}\n";
sudo update-alternatives --config javac;
sudo -p $'\033[1;35m[#]\033[0m ' update-alternatives --config javac;
;;
"pacman")
archlinux-java status;
read -p "${INF} Please enter desired version (ie. \"java-7-openjdk\"): " ARCHJA;
sudo archlinux-java set ${ARCHJA};
sudo -p $'\033[1;35m[#]\033[0m ' archlinux-java set ${ARCHJA};
;;
esac
echo -e "\n${CL_WYT}================================================================${NONE}";
Expand All @@ -878,8 +878,8 @@ function tools() # 5
case "$REMOJA" in
[yY])
case "${PKGMGR}" in
"apt") sudo apt-get purge openjdk-* icedtea-* icedtea6-* ;;
"pacman") sudo pacman -Rddns $( pacman -Qqs ^jdk ) ;;
"apt") sudo -p $'\033[1;35m[#]\033[0m ' apt-get purge openjdk-* icedtea-* icedtea6-* ;;
"pacman") sudo -p $'\033[1;35m[#]\033[0m ' pacman -Rddns $( pacman -Qqs ^jdk ) ;;
esac
echo -e "\n${SCS} Removed Other Versions successfully"
;;
Expand All @@ -891,13 +891,13 @@ function tools() # 5
esac
echo -e "${CL_WYT}==========================================================${NONE}\n";
case "${PKGMGR}" in
"apt") sudo apt-get update -y ;;
"pacman") sudo pacman -Sy ;;
"apt") sudo -p $'\033[1;35m[#]\033[0m ' apt-get update -y ;;
"pacman") sudo -p $'\033[1;35m[#]\033[0m ' pacman -Sy ;;
esac
echo -e "\n${CL_WYT}==========================================================${NONE}\n";
case "${PKGMGR}" in
"apt") sudo apt-get install openjdk-$1-jdk -y ;;
"pacman") sudo pacman -S jdk$1-openjdk ;;
"apt") sudo -p $'\033[1;35m[#]\033[0m ' apt-get install openjdk-$1-jdk -y ;;
"pacman") sudo -p $'\033[1;35m[#]\033[0m ' pacman -S jdk$1-openjdk ;;
esac
echo -e "\n${CL_WYT}==========================================================${NONE}";
if [[ $( java -version > $TMP && grep -c "java version \"1\.$1" $TMP ) == "1" ]]; then
Expand All @@ -910,11 +910,11 @@ function tools() # 5
{
if [[ ! $(which add-apt-repository) ]]; then
echo -e "${EXE} add-apt-repository not present. Installing it...";
sudo apt-get install software-properties-common;
sudo -p $'\033[1;35m[#]\033[0m ' apt-get install software-properties-common;
fi
sudo add-apt-repository ppa:openjdk-r/ppa -y;
sudo apt-get update -y;
sudo apt-get install openjdk-$1-jdk -y;
sudo -p $'\033[1;35m[#]\033[0m ' add-apt-repository ppa:openjdk-r/ppa -y;
sudo -p $'\033[1;35m[#]\033[0m ' apt-get update -y;
sudo -p $'\033[1;35m[#]\033[0m ' apt-get install openjdk-$1-jdk -y;
} # java_ppa

function java_menu()
Expand Down Expand Up @@ -960,9 +960,9 @@ function tools() # 5
{
echo -e "\n${CL_WYT}==========================================================${NONE}\n";
echo -e "${EXE} Updating / Creating Android USB udev rules (51-android)\n";
sudo curl --create-dirs -L -o /etc/udev/rules.d/51-android.rules -O -L https://raw.githubusercontent.com/snowdream/51-android/master/51-android.rules;
sudo chmod a+r /etc/udev/rules.d/51-android.rules;
sudo service udev restart;
sudo -p $'\033[1;35m[#]\033[0m ' curl --create-dirs -L -o /etc/udev/rules.d/51-android.rules -O -L https://raw.githubusercontent.com/snowdream/51-android/master/51-android.rules;
sudo -p $'\033[1;35m[#]\033[0m ' chmod a+r /etc/udev/rules.d/51-android.rules;
sudo -p $'\033[1;35m[#]\033[0m ' service udev restart;
echo -e "\n${SCS} Done";
echo -e "\n${CL_WYT}==========================================================${NONE}\n";
} # udev_rules
Expand All @@ -974,7 +974,7 @@ function tools() # 5
"3.81") echo -e "\n${SCS} make 3.81 has already been installed" ;;
*)
echo "\n${EXE} Installing make 3.81...";
sudo install utils/make /usr/bin/;
sudo -p $'\033[1;35m[#]\033[0m ' install utils/make /usr/bin/;
;;
esac
[[ "$MKVR" == "3.81" ]] && echo -e "\n${SCS} make 3.81 present";
Expand Down Expand Up @@ -1094,9 +1094,9 @@ 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 echo -e "\n${SCS} Root access OK. You won't be asked again";
export CALL_ME_ROOT="$(pwd)";
# 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;
clear;
Expand All @@ -1110,6 +1110,7 @@ function the_start() # 0
echo -e " ${CL_LRD}███████${NONE}${CL_RED}║╚${NONE}${CL_LRD}██████${NONE}${CL_RED}${NONE}${CL_LRD}██${NONE}${CL_RED}${NONE} ${CL_LRD}██${NONE}${CL_RED}${NONE}${CL_LRD}██${NONE}${CL_RED}${NONE}${CL_LRD}██████${NONE}${CL_RED}╔╝${NONE} ${CL_LRD}██${NONE}${CL_RED}${NONE}";
echo -e " ${CL_RED}╚══════╝ ╚═════╝╚═╝ ╚═╝╚═╝╚═════╝ ╚═╝${NONE}\n";
sleep 1.5;
echo -e " ${CL_WYT}Version 1.34${NONE}\n";
} # the_start

# VROOM!
Expand All @@ -1130,6 +1131,19 @@ 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}'`;
curl -o up.sh https://raw.githubusercontent.com/a7r3/ScriBt/master/upScriBt.sh;
RUSB_VER=`grep 'USB_VER' up.sh | awk '{print $3}'`;
if [[ "$RUSB_VER" > "$LUSB_VER" ]]; then
mv -f up.sh upScriBt.sh;
else
rm -rf up.sh;
fi

# Update us now
source upScriBt.sh $@;

# Where am I ?
echo -e "\n${INF} ${CL_WYT}I'm in $(pwd)${NONE}\n";

Expand Down
1 change: 1 addition & 0 deletions VERSION
@@ -0,0 +1 @@
1.35
39 changes: 39 additions & 0 deletions upScriBt.sh
@@ -0,0 +1,39 @@
#!/bin/bash
#===========================< 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";
if [[ "${RVER}" > "${LVER}" ]]; then
echo -e "${SCS} Update Detected. Version ${RVER}\n";
echo -e "${QN} Do you want to Update";
read UDPR;
case "$UDPR" in
[Yy])
mkdir old;
echo -e "\n${EXE} Updating ScriBt to Version $RVER\n";
for file in ROM.sh ROM.rc PREF.rc README.md VERSION; do
mv ${file} old/${file};
echo -e "${file} `curl -# -s -o ${file} https://raw.githubusercontent.com/a7r3/ScriBt/master/${file}`-> Done.";
done
echo -e "${SCS} ScriBt updated Successfully\n";
echo -e "${INF} Old Version of ScriBt has been moved under ${CL_WYT}old${NONE} folder.\n";
echo -e "\n${EXE} Restarting ScriBt with the provided parameters";
if [[ "$1" == "automate" ]] || [[ "$3" == "automate" ]]; then
echo -e "\n${INF} PREF.rc has been brought back to default";
echo -e "\n${INF} Please make the changes you made in old PREF.rc which is located under the ${CL_WYT}old${NONE} folder";
read ENTER;
echo -e "${SCS} Done.";
fi
exec bash ROM.sh $@;
;;
[Nn])
echo -e "\n${INF} Staying on v${LVER}\n${INF} But it is recommended to update ScriBt\n";
;;
esac
else
echo -e "\n${SCS} ScriBt is up-to-date";
echo -e "\n${EXE} Continuing";
fi

0 comments on commit 53e5eb0

Please sign in to comment.