1
0
mirror of https://github.com/lineageos4microg/docker-lineage-cicd synced 2024-11-09 10:09:56 +01:00

A lot of improvements

Fixing cron job, enhancing log output, remove custom manifest URL option ( users can always upload custom manifest by accessing their .repo folder mapped via volume anyway )
This commit is contained in:
Julian Xhokaxhiu 2017-01-15 23:03:17 +01:00
parent 7142edf4dd
commit a156e12764
3 changed files with 23 additions and 19 deletions

@ -41,9 +41,6 @@ ENV CLEAN_OUTDIR true
# By Default = At 10:00 UTC ~ 2am PST/PDT
ENV CRONTAB_TIME '0 10 * * *'
# Set here the URL to your custom manifest in order to use it for your custom builds
ENV CUSTOM_MANIFEST_URL ''
# Create Volume entry points
############################
@ -146,6 +143,10 @@ RUN pacman -Sy --needed --noconfirm --noprogressbar \
###################################
RUN ln -s /usr/bin/python2 /usr/local/bin/python
# Allow redirection of stdout to docker logs
############################################
RUN ln -sf /proc/1/fd/1 /var/log/docker.log
# Cleanup
#########

@ -6,26 +6,26 @@
if ! [ -z "$DEVICE_LIST" ]; then
# cd to working directory
cd $SRC_DIR
# If the source directory is empty
if ! [ "$(ls -A $SRC_DIR)" ]; then
# Initialize repository
yes | repo init -u git://github.com/lineageos/android.git -b $BRANCH_NAME
fi
# If a Custom manifest URL has been specified
if ! [ -z "$CUSTOM_MANIFEST_URL" ]; then
wget -O .repo/local_manifests/local_manifest.xml $CUSTOM_MANIFEST_URL
echo "-------- Initializing repository [$(date)] --------"
yes | repo init -u git://github.com/lineageos/android.git -b $BRANCH_NAME &>/dev/null
fi
# Go to "vendor/cm" and reset it's current git status ( remove previous changes ) only if the directory exists
if [ -d "vendor/cm" ]; then
cd vendor/cm
git reset --hard
git reset --hard &>/dev/null
cd $SRC_DIR
fi
# Sync the source code
repo sync
echo "-------- Syncing repository [$(date)] --------"
repo sync &>/dev/null
# If requested, clean the OUT dir in order to avoid clutter
if [ "$CLEAN_OUTDIR" = true ]; then
@ -33,11 +33,12 @@ if ! [ -z "$DEVICE_LIST" ]; then
fi
# Prepare the environment
source build/envsetup.sh
echo "-------- Preparing build environment [$(date)] --------"
source build/envsetup.sh &>/dev/null
# Set a custom updater URI if a OTA URL is provided
if ! [ -z "$OTA_URL" ]; then
sed -i "1s;^;ADDITIONAL_DEFAULT_PROPERTIES += cm.updater.uri=$OTA_URL\n\n;" vendor/cm/config/common.mk
sed -i "1s;^;ADDITIONAL_DEFAULT_PROPERTIES += cm.updater.uri=$OTA_URL\n\n;" vendor/cm/config/common.mk &>/dev/null
fi
# Cycle DEVICE_LIST environment variable, to know which one may be executed next
@ -45,14 +46,16 @@ if ! [ -z "$DEVICE_LIST" ]; then
for codename in $DEVICE_LIST; do
if ! [ -z "$codename" ]; then
# Start the build
brunch $codename
echo "-------- Starting build for >> $codename << [$(date)] --------"
brunch $codename &>/dev/null
# Move produced ZIP files to the main OUT directory
find out/target/product/$codename/ -name '*UNOFFICIAL*.zip*' -exec mv {} $OUT_DIR \;
find out/target/product/$codename/ -name '*UNOFFICIAL*.zip*' -exec mv {} $OUT_DIR \; &>/dev/null
# Clean everything, in order to start fresh on next build
cd $SRC_DIR
make clean
make clean &>/dev/null
echo "-------- Finishing build for >> $codename << [$(date)] --------"
fi
done
@ -60,4 +63,4 @@ if ! [ -z "$DEVICE_LIST" ]; then
if [ "$CLEAN_SRCDIR" = true ]; then
rm -Rf "$SRC_DIR/*"
fi
fi
fi

@ -17,9 +17,9 @@ git config --global user.email $USER_MAIL
cronFile=/tmp/buildcron
printf "SHELL=/bin/bash\n" > $cronFile
printenv -0 | sed -e 's/=\x0/=""\n/g' | sed -e 's/\x0/\n/g' | sed -e "s/_=/PRINTENV=/g" >> $cronFile
printf "\n$CRONTAB_TIME /usr/bin/flock -n /tmp/lock.build /root/build.sh 2>&1\n" >> $cronFile
printf "\n$CRONTAB_TIME /usr/bin/flock -n /tmp/lock.build /root/build.sh >> /var/log/docker.log 2>&1\n" >> $cronFile
crontab $cronFile
rm $cronFile
# Run crond in foreground
crond -n -m off
crond -n -m off 2>&1