mirror of
https://github.com/lineageos4microg/docker-lineage-cicd
synced 2024-11-09 10:09:56 +01:00
Add support for delta files
This commit is contained in:
parent
c841a467c6
commit
7403fce5c8
42
Dockerfile
42
Dockerfile
@ -8,6 +8,8 @@ ENV SRC_DIR /srv/src
|
||||
ENV CCACHE_DIR /srv/ccache
|
||||
ENV ZIP_DIR /srv/zips
|
||||
ENV LMANIFEST_DIR /srv/local_manifests
|
||||
ENV DELTA_DIR /srv/delta
|
||||
ENV KEYS_DIR /srv/keys
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
ENV USER root
|
||||
|
||||
@ -61,7 +63,7 @@ ENV ANDROID_JACK_VM_ARGS "-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4G"
|
||||
ENV CUSTOM_PACKAGES ''
|
||||
|
||||
# Key path (from the root of the android source)
|
||||
ENV KEYS_DIR ''
|
||||
ENV SIGN_BUILDS false
|
||||
|
||||
# Move the resulting zips to $ZIP_DIR/$codename instead of $ZIP_DIR/
|
||||
ENV ZIP_SUBDIR false
|
||||
@ -71,6 +73,9 @@ ENV ZIP_SUBDIR false
|
||||
# permission only to the privileged apps)
|
||||
ENV SIGNATURE_SPOOFING "no"
|
||||
|
||||
# Generate delta files (saved in $ZIP_DIR/delta)
|
||||
ENV BUILD_DELTA false
|
||||
|
||||
# Create Volume entry points
|
||||
############################
|
||||
|
||||
@ -78,6 +83,8 @@ VOLUME $SRC_DIR
|
||||
VOLUME $CCACHE_DIR
|
||||
VOLUME $ZIP_DIR
|
||||
VOLUME $LMANIFEST_DIR
|
||||
VOLUME $DELTA_DIR
|
||||
VOLUME $KEYS_DIR
|
||||
|
||||
# Copy required files and fix permissions
|
||||
#####################
|
||||
@ -91,11 +98,8 @@ RUN mkdir -p $SRC_DIR
|
||||
RUN mkdir -p $CCACHE_DIR
|
||||
RUN mkdir -p $ZIP_DIR
|
||||
RUN mkdir -p $LMANIFEST_DIR
|
||||
|
||||
# Set the work directory
|
||||
########################
|
||||
|
||||
WORKDIR $SRC_DIR
|
||||
RUN mkdir -p $DELTA_DIR
|
||||
RUN mkdir -p $KEYS_DIR
|
||||
|
||||
# Fix permissions
|
||||
#################
|
||||
@ -119,6 +123,32 @@ RUN apt-get install -y bc bison build-essential ccache cron curl flex \
|
||||
RUN curl https://storage.googleapis.com/git-repo-downloads/repo > /usr/local/bin/repo
|
||||
RUN chmod a+x /usr/local/bin/repo
|
||||
|
||||
# Download and build delta tools
|
||||
################################
|
||||
RUN cd /root/ && \
|
||||
mkdir delta && \
|
||||
git clone https://github.com/omnirom/android_packages_apps_OpenDelta.git OpenDelta && \
|
||||
cd OpenDelta/jni && \
|
||||
gcc -o /root/delta/zipadjust zipadjust.c zipadjust_run.c -lz && \
|
||||
cd xdelta3* && \
|
||||
chmod +x configure && \
|
||||
./configure && \
|
||||
make && \
|
||||
cp xdelta3 /root/OpenDelta/server/minsignapk.jar /root/OpenDelta/server/opendelta.sh /root/delta/ && \
|
||||
rm -rf /root/OpenDelta && \
|
||||
chmod +x /root/delta/opendelta.sh && \
|
||||
sed -i -e 's/^\s*HOME=.*/HOME=\/root/' /root/delta/opendelta.sh && \
|
||||
sed -i -e 's/^\s*FILE_MATCH=.*/FILE_MATCH=lineage-\*.zip/' /root/delta/opendelta.sh && \
|
||||
sed -i -e 's/^\s*PATH_CURRENT=.*/PATH_CURRENT=$SRC_DIR\/out\/target\/product\/$DEVICE/' /root/delta/opendelta.sh && \
|
||||
sed -i -e 's/^\s*PATH_LAST=.*/PATH_LAST=$SRC_DIR\/delta_last\/$DEVICE/' /root/delta/opendelta.sh && \
|
||||
sed -i -e 's/^\s*KEY_X509=.*/KEY_X509=$KEYS_DIR\/releasekey.x509.pem/' /root/delta/opendelta.sh && \
|
||||
sed -i -e 's/^\s*KEY_PK8=.*/KEY_PK8=$KEYS_DIR\/releasekey.pk8/' /root/delta/opendelta.sh && \
|
||||
sed -i -e 's/publish/$DELTA_DIR/g' /root/delta/opendelta.sh
|
||||
|
||||
# Set the work directory
|
||||
########################
|
||||
WORKDIR $SRC_DIR
|
||||
|
||||
# Allow redirection of stdout to docker logs
|
||||
############################################
|
||||
|
||||
|
51
src/build.sh
51
src/build.sh
@ -82,6 +82,11 @@ if ! [ -z "$DEVICE_LIST" ]; then
|
||||
sed -i "1s;^;PRODUCT_PACKAGES += $CUSTOM_PACKAGES\n\n;" vendor/cm/config/common.mk
|
||||
fi
|
||||
|
||||
if [ "$SIGN_BUILDS" = true ]; then
|
||||
echo ">> [$(date)] Adding keys path ($KEYS_DIR)" >> $DOCKER_LOG
|
||||
sed -i "1s;^;PRODUCT_DEFAULT_DEV_CERTIFICATE := $KEYS_DIR/releasekey\nPRODUCT_OTA_PUBLIC_KEYS := $KEYS_DIR/releasekey\n\n;" vendor/cm/config/common.mk
|
||||
fi
|
||||
|
||||
# Cycle DEVICE_LIST environment variable, to know which one may be executed next
|
||||
IFS=','
|
||||
for codename in $DEVICE_LIST; do
|
||||
@ -93,42 +98,32 @@ if ! [ -z "$DEVICE_LIST" ]; then
|
||||
zipsubdir=
|
||||
fi
|
||||
# Start the build
|
||||
if [ -z "$KEYS_DIR" ]; then
|
||||
echo ">> [$(date)] Starting build for $codename" >> $DOCKER_LOG
|
||||
if brunch $codename 2>&1 >&$DEBUG_LOG; then
|
||||
if [ "$BUILD_DELTA" = true ]; then
|
||||
if [ -d "$SRC_DIR/delta_last/$codename/" ]; then
|
||||
# If not the first build, create delta files
|
||||
echo ">> [$(date)] Generating delta files for $codename" >> $DOCKER_LOG
|
||||
cd /root/delta
|
||||
if ./opendelta.sh $codename >&$DEBUG_LOG; then
|
||||
echo ">> [$(date)] Delta generation for $codename completed" >> $DOCKER_LOG
|
||||
else
|
||||
echo ">> [$(date)] Delta generation for $codename failed" >> $DOCKER_LOG
|
||||
fi
|
||||
else
|
||||
# If the first build, copy the current full zip in $SRC_DIR/delta_last/$codename/
|
||||
echo ">> [$(date)] No previous build for $codename; using current build as base for the next delta" >> $DOCKER_LOG
|
||||
mkdir -p $SRC_DIR/delta_last/$codename/
|
||||
find out/target/product/$codename -name '*UNOFFICIAL*.zip*' -exec cp {} $SRC_DIR/delta_last/$codename/ \;
|
||||
fi
|
||||
fi
|
||||
# Move produced ZIP files to the main OUT directory
|
||||
echo ">> [$(date)] Moving build artifacts for $codename to '$ZIP_DIR/$zipsubdir'" >> $DOCKER_LOG
|
||||
cd $SRC_DIR
|
||||
find out/target/product/$codename -name '*UNOFFICIAL*.zip*' -exec sh -c 'sha256sum {} > $ZIP_DIR/$zipsubdir/{}.sha256sum && mv {} $ZIP_DIR/$zipsubdir/' \; >&$DEBUG_LOG
|
||||
find out/target/product/$codename -name '*UNOFFICIAL*.zip*' -exec mv {} $ZIP_DIR/$zipsubdir/ \; >&$DEBUG_LOG
|
||||
else
|
||||
echo ">> [$(date)] Failed build for $codename" >> $DOCKER_LOG
|
||||
fi
|
||||
else
|
||||
echo ">> [$(date)] Starting build for $codename" >> $DOCKER_LOG
|
||||
if breakfast $codename 2>&1 >&$DEBUG_LOG && \
|
||||
mka target-files-package dist 2>&1 >&$DEBUG_LOG; then
|
||||
echo ">> [$(date)] Signing build output for $codename" >> $DOCKER_LOG
|
||||
build_number=$(<$SRC_DIR/out/build_number.txt)
|
||||
if $SRC_DIR/build/tools/releasetools/sign_target_files_apks -o -d $SRC_DIR/$KEYS_DIR \
|
||||
$SRC_DIR/out/dist/lineage_$codename-target_files-$build_number.zip \
|
||||
$SRC_DIR/out/dist/lineage_$codename-signed_target_files-$build_number.zip 2>&1 >&$DEBUG_LOG && \
|
||||
$SRC_DIR/build/tools/releasetools/ota_from_target_files -k $SRC_DIR/$KEYS_DIR/releasekey --block --backup=true \
|
||||
$SRC_DIR/out/dist/lineage_$codename-signed_target_files-$build_number.zip \
|
||||
$ZIP_DIR/$zipsubdir/lineage-14.1-$builddate-UNOFFICIAL-$codename-signed.zip 2>&1 >&$DEBUG_LOG; then
|
||||
cd $ZIP_DIR/$zipsubdir
|
||||
md5sum lineage-14.1-$builddate-UNOFFICIAL-$codename-signed.zip > lineage-14.1-$builddate-UNOFFICIAL-$codename-signed.zip.md5sum
|
||||
sha256sum lineage-14.1-$builddate-UNOFFICIAL-$codename-signed.zip > lineage-14.1-$builddate-UNOFFICIAL-$codename-signed.zip.sha256sum
|
||||
cd $SRC_DIR
|
||||
echo ">> [$(date)] Build completed for $codename" >> $DOCKER_LOG
|
||||
else
|
||||
echo ">> [$(date)] Failed signing for $codename" >> $DOCKER_LOG
|
||||
fi
|
||||
rm -f $SRC_DIR/out/dist/lineage_$codename-target_files-$build_number.zip
|
||||
rm -f $SRC_DIR/out/dist/lineage_$codename-signed_target_files-$build_number.zip
|
||||
else
|
||||
echo ">> [$(date)] Failed build for $codename" >> $DOCKER_LOG
|
||||
fi
|
||||
fi
|
||||
# Clean everything, in order to start fresh on next build
|
||||
if [ "$CLEAN_AFTER_BUILD" = true ]; then
|
||||
echo ">> [$(date)] Cleaning build for $codename" >> $DOCKER_LOG
|
||||
|
Loading…
Reference in New Issue
Block a user