Categories
android bash cyanogenmod repo shell

repo: command not found in automated bash script to build cyanogenmod

I am running linux mint 17.2, I have repo installed and the path to repo is added to my .bashrc. I have previously initiated my repo.

I have followed the instructions on the Android Source Downloading and How to Build CyanogenMod pages.

The problem is: I have written a bash script to automate a number of the commands I would like to use to start a build. My script in a simple form is the following:

#!/bin/bash
cd ~/Android/Cyanogenmod/cm12_1/android/system
source build/envsetup.sh
repo sync --force-sync -j8
exec $SHELL

When I run this, it reports:

/home/username/Desktop/Cyanogenmod_cm12_1_Grouper_Build : line 4 repo: command not found

If I copy and paste each line into a fresh terminal instance (or by just running a script of #!/bin/bash exec $SHELL to open a terminal) it works perfectly.

What I have tried: I have tried including a sleep 10 before the repo sync --force-sync -j8 but that made no difference. I have also tried explicitly initiating the repo and force adding it to my PATH for the current terminal session directly before attempting the repo sync --force-sync -j8. The code for that test was the following:

#!/bin/bash
mkdir -p ~/Android/Cyanogenmod/bin
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/Android/Cyanogenmod/bin/repo
chmod a+x ~/Android/Cyanogenmod/bin/repo
cd ~/Android/Cyanogenmod/cm12_1/android/system/
source build/envsetup.sh
PATH=~/Android/Cyanogenmod/bin/repo:$PATH
repo sync --force-sync -j8
exec $SHELL

The following 2 questions have a similar title, but neither are my question, this and this.

Any help or suggestions would be great, thank you!