1
0
mirror of https://github.com/stucki/docker-lineageos synced 2024-12-19 17:12:29 -05:00

Merge pull request #12 from MichalCz/feature/rebuild-switch-and-completion

Add a rebuild switch and bash completion for "repo"
This commit is contained in:
Michael Stucki 2016-04-05 21:42:48 +02:00
commit 23270ee993
4 changed files with 34 additions and 4 deletions

5
CHANGELOG.md Normal file → Executable file
View File

@ -3,6 +3,11 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased][unreleased]
### Added
- Use -f to force rebuild the source.
- If build fails don't remove intermediate containers
- Added bash completion, wget and nano
- Simplier home creation
## [0.5.0] - 2016-03-14
### Added

View File

@ -17,8 +17,9 @@ RUN apt-get install -y g++-multilib gcc-multilib lib32ncurses5-dev lib32readline
RUN apt-get install -y ccache rsync tig
RUN apt-get install -y android-tools-adb android-tools-fastboot
RUN apt-get install -y bc bsdmainutils file screen
RUN apt-get install -y bash-completion wget nano
RUN mkdir -p /home/cmbuild && useradd --no-create-home cmbuild && rsync -a /etc/skel/ /home/cmbuild/
RUN useradd cmbuild && rsync -a /etc/skel/ /home/cmbuild/
RUN mkdir /home/cmbuild/bin
RUN curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > /home/cmbuild/bin/repo

2
bash_completion Normal file
View File

@ -0,0 +1,2 @@
. android-completion/android
. android-completion/repo

28
run.sh
View File

@ -2,8 +2,8 @@
cd $(dirname $0)
SOURCE=$(pwd)/android
CCACHE=$(pwd)/ccache
SOURCE=$(readlink -f $(pwd)/android)
CCACHE=$(readlink -f $(pwd)/ccache)
CONTAINER_HOME=/home/cmbuild
CONTAINER=cyanogenmod
REPOSITORY=stucki/cyanogenmod
@ -27,6 +27,23 @@ while [[ $# > 0 ]]; do
shift
done
while [[ $# > 0 ]]
do
key="$1"
case $key in
-r|--rebuild)
FORCE_BUILD=1
;;
*)
shift # past argument or value
;;
esac
shift
done
# Create shared folders
mkdir -p $SOURCE
mkdir -p $CCACHE
@ -43,14 +60,19 @@ elif [[ $FORCE_BUILD = 1 ]] || ! echo "$IMAGE_EXISTS" | grep -q "$TAG"; then
echo "Building Docker image $REPOSITORY:$TAG..."
docker build -t $REPOSITORY:$TAG .
OK=$?
# After successful build, delete existing containers
IS_EXISTING=$(docker inspect -f '{{.Id}}' $CONTAINER 2>/dev/null)
if [[ -n "$IS_EXISTING" ]]; then
if [[ $OK -eq 0 ]] && [[ -n "$IS_EXISTING" ]]; then
docker rm $CONTAINER
fi
fi
if [[ $OK -ne 0 ]]; then
exit 1;
fi
# With the given name $CONTAINER, reconnect to running container, start
# an existing/stopped container or run a new one if one does not exist.
IS_RUNNING=$(docker inspect -f '{{.State.Running}}' $CONTAINER 2>/dev/null)