mirror of
https://github.com/lineageos4microg/docker-lineage-cicd
synced 2024-11-09 10:09:56 +01:00
Improve overall logging
This commit is contained in:
parent
d6e53000ff
commit
7f5ef167ea
45
src/build.sh
45
src/build.sh
@ -4,9 +4,10 @@
|
|||||||
#
|
#
|
||||||
###########################################################
|
###########################################################
|
||||||
|
|
||||||
OUTPUT=/dev/null
|
DOCKER_LOG=/var/log/docker.log
|
||||||
|
DEBUG_LOG=/dev/null
|
||||||
if [ "$DEBUG" = true ]; then
|
if [ "$DEBUG" = true ]; then
|
||||||
OUTPUT=/var/log/docker.log
|
DEBUG_LOG=$DOCKER_LOG
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! [ -z "$DEVICE_LIST" ]; then
|
if ! [ -z "$DEVICE_LIST" ]; then
|
||||||
@ -17,41 +18,41 @@ if ! [ -z "$DEVICE_LIST" ]; then
|
|||||||
# If the source directory is empty
|
# If the source directory is empty
|
||||||
if ! [ "$(ls -A $SRC_DIR)" ]; then
|
if ! [ "$(ls -A $SRC_DIR)" ]; then
|
||||||
# Initialize repository
|
# Initialize repository
|
||||||
echo ">> [$(date)] Initializing repository"
|
echo ">> [$(date)] Initializing repository" >> $DOCKER_LOG
|
||||||
yes | repo init -u git://github.com/lineageos/android.git -b $BRANCH_NAME 2>&1 >&$OUTPUT
|
yes | repo init -u git://github.com/lineageos/android.git -b $BRANCH_NAME 2>&1 >&$DEBUG_LOG
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Copy local manifests to the appropriate folder in order take them into consideration
|
# Copy local manifests to the appropriate folder in order take them into consideration
|
||||||
echo ">> [$(date)] Copying '$LMANIFEST_DIR/*.xml' to '$SRC_DIR/.repo/local_manifests/'"
|
echo ">> [$(date)] Copying '$LMANIFEST_DIR/*.xml' to '$SRC_DIR/.repo/local_manifests/'" >> $DOCKER_LOG
|
||||||
cp $LMANIFEST_DIR/*.xml $SRC_DIR/.repo/local_manifests/ >&$OUTPUT
|
cp $LMANIFEST_DIR/*.xml $SRC_DIR/.repo/local_manifests/ >&$DEBUG_LOG
|
||||||
|
|
||||||
# Go to "vendor/cm" and reset it's current git status ( remove previous changes ) only if the directory exists
|
# Go to "vendor/cm" and reset it's current git status ( remove previous changes ) only if the directory exists
|
||||||
if [ -d "vendor/cm" ]; then
|
if [ -d "vendor/cm" ]; then
|
||||||
cd vendor/cm
|
cd vendor/cm
|
||||||
git reset --hard 2>&1 >&$OUTPUT
|
git reset --hard 2>&1 >&$DEBUG_LOG
|
||||||
cd $SRC_DIR
|
cd $SRC_DIR
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Sync the source code
|
# Sync the source code
|
||||||
echo ">> [$(date)] Syncing repository"
|
echo ">> [$(date)] Syncing repository" >> $DOCKER_LOG
|
||||||
repo sync 2>&1 >&$OUTPUT
|
repo sync 2>&1 >&$DEBUG_LOG
|
||||||
|
|
||||||
# If requested, clean the OUT dir in order to avoid clutter
|
# If requested, clean the OUT dir in order to avoid clutter
|
||||||
if [ "$CLEAN_OUTDIR" = true ]; then
|
if [ "$CLEAN_OUTDIR" = true ]; then
|
||||||
echo ">> [$(date)] Cleaning '$ZIP_DIR'"
|
echo ">> [$(date)] Cleaning '$ZIP_DIR'" >> $DOCKER_LOG
|
||||||
cd $ZIP_DIR
|
cd $ZIP_DIR
|
||||||
rm *
|
rm *
|
||||||
cd $SRC_DIR
|
cd $SRC_DIR
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Prepare the environment
|
# Prepare the environment
|
||||||
echo ">> [$(date)] Preparing build environment"
|
echo ">> [$(date)] Preparing build environment" >> $DOCKER_LOG
|
||||||
source build/envsetup.sh 2>&1 >&$OUTPUT
|
source build/envsetup.sh 2>&1 >&$DEBUG_LOG
|
||||||
|
|
||||||
# Set a custom updater URI if a OTA URL is provided
|
# Set a custom updater URI if a OTA URL is provided
|
||||||
if ! [ -z "$OTA_URL" ]; then
|
if ! [ -z "$OTA_URL" ]; then
|
||||||
echo ">> [$(date)] Adding OTA URL '$OTA_URL' to build.prop"
|
echo ">> [$(date)] Adding OTA URL '$OTA_URL' to build.prop" >> $DOCKER_LOG
|
||||||
sed -i "1s;^;PRODUCT_PROPERTY_OVERRIDES += cm.updater.uri=$OTA_URL\n\n;" vendor/cm/config/common.mk >&$OUTPUT
|
sed -i "1s;^;PRODUCT_PROPERTY_OVERRIDES += cm.updater.uri=$OTA_URL\n\n;" vendor/cm/config/common.mk >&$DEBUG_LOG
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Cycle DEVICE_LIST environment variable, to know which one may be executed next
|
# Cycle DEVICE_LIST environment variable, to know which one may be executed next
|
||||||
@ -59,22 +60,22 @@ if ! [ -z "$DEVICE_LIST" ]; then
|
|||||||
for codename in $DEVICE_LIST; do
|
for codename in $DEVICE_LIST; do
|
||||||
if ! [ -z "$codename" ]; then
|
if ! [ -z "$codename" ]; then
|
||||||
# Start the build
|
# Start the build
|
||||||
echo ">> [$(date)] Starting build for $codename"
|
echo ">> [$(date)] Starting build for $codename" >> $DOCKER_LOG
|
||||||
if brunch $codename 2>&1 >&$OUTPUT; then
|
if brunch $codename 2>&1 >&$DEBUG_LOG; then
|
||||||
# Move produced ZIP files to the main OUT directory
|
# Move produced ZIP files to the main OUT directory
|
||||||
echo ">> [$(date)] Moving build artifacts for $codename to '$ZIP_DIR'"
|
echo ">> [$(date)] Moving build artifacts for $codename to '$ZIP_DIR'" >> $DOCKER_LOG
|
||||||
cd $SRC_DIR
|
cd $SRC_DIR
|
||||||
find out/target/product/$codename -name '*UNOFFICIAL*.zip*' -exec mv {} $ZIP_DIR \; >&$OUTPUT
|
find out/target/product/$codename -name '*UNOFFICIAL*.zip*' -exec mv {} $ZIP_DIR \; >&$DEBUG_LOG
|
||||||
|
|
||||||
# Clean everything, in order to start fresh on next build
|
# Clean everything, in order to start fresh on next build
|
||||||
if [ "$CLEAN_AFTER_BUILD" = true ]; then
|
if [ "$CLEAN_AFTER_BUILD" = true ]; then
|
||||||
echo ">> [$(date)] Cleaning build for $codename"
|
echo ">> [$(date)] Cleaning build for $codename" >> $DOCKER_LOG
|
||||||
make clean 2>&1 >&$OUTPUT
|
make clean 2>&1 >&$DEBUG_LOG
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo ">> [$(date)] Failed build for $codename"
|
echo ">> [$(date)] Failed build for $codename" >> $DOCKER_LOG
|
||||||
fi
|
fi
|
||||||
echo ">> [$(date)] Finishing build for $codename"
|
echo ">> [$(date)] Finishing build for $codename" >> $DOCKER_LOG
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
10
src/init.sh
10
src/init.sh
@ -4,9 +4,15 @@
|
|||||||
#
|
#
|
||||||
###########################################################
|
###########################################################
|
||||||
|
|
||||||
|
DOCKER_LOG=/var/log/docker.log
|
||||||
|
DEBUG_LOG=/dev/null
|
||||||
|
if [ "$DEBUG" = true ]; then
|
||||||
|
DEBUG_LOG=$DOCKER_LOG
|
||||||
|
fi
|
||||||
|
|
||||||
# Initialize CCache if it will be used
|
# Initialize CCache if it will be used
|
||||||
if [ "$USE_CCACHE" = 1 ]; then
|
if [ "$USE_CCACHE" = 1 ]; then
|
||||||
ccache -M 50G
|
ccache -M 50G 2>&1 >&$DEBUG_LOG
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Initialize Git user information
|
# Initialize Git user information
|
||||||
@ -17,7 +23,7 @@ git config --global user.email $USER_MAIL
|
|||||||
cronFile=/tmp/buildcron
|
cronFile=/tmp/buildcron
|
||||||
printf "SHELL=/bin/bash\n" > $cronFile
|
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
|
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 >> /var/log/docker.log 2>&1\n" >> $cronFile
|
printf "\n$CRONTAB_TIME /usr/bin/flock -n /tmp/lock.build /root/build.sh\n" >> $cronFile
|
||||||
crontab $cronFile
|
crontab $cronFile
|
||||||
rm $cronFile
|
rm $cronFile
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user