mirror of
https://github.com/lineageos4microg/docker-lineage-cicd
synced 2024-11-09 10:09:56 +01:00
First commit
This commit is contained in:
parent
23e4754a3d
commit
71d28d2203
153
Dockerfile
Normal file
153
Dockerfile
Normal file
@ -0,0 +1,153 @@
|
||||
FROM finalduty/archlinux
|
||||
MAINTAINER Julian Xhokaxhiu <info at julianxhokaxhiu dot com>
|
||||
|
||||
# Environment variables
|
||||
#######################
|
||||
|
||||
ENV SRC_DIR /srv/src
|
||||
ENV CCACHE_DIR /srv/ccache
|
||||
ENV OUT_DIR /srv/out
|
||||
|
||||
# Configurable environment variables
|
||||
####################################
|
||||
|
||||
# By default we want to use CCACHE, you can disable this
|
||||
# WARNING: disabling this may slow down a lot your builds!
|
||||
ENV USE_CCACHE 1
|
||||
|
||||
# Environment for the LineageOS Branch name
|
||||
ENV BRANCH_NAME 'cm-14.1'
|
||||
|
||||
# Environment for the device list ( separate by comma if more than one)
|
||||
# eg. DEVICE_LIST=hammerhead,bullhead,angler
|
||||
ENV DEVICE_LIST ''
|
||||
|
||||
# OTA URL that will be used inside CMUpdater
|
||||
# Use this in combination with LineageOTA to make sure your device can auto-update itself from this buildbot
|
||||
ENV OTA_URL ''
|
||||
|
||||
# User identity
|
||||
ENV USER_NAME 'LineageOS Buildbot'
|
||||
ENV USER_MAIL 'lineageos-buildbot@docker.host'
|
||||
|
||||
# If you want to start always fresh ( re-download all the source code everytime ) set this to 'true'
|
||||
ENV CLEAN_SRCDIR false
|
||||
|
||||
# If you want to preserve old ZIPs set this to 'false'
|
||||
ENV CLEAN_OUTDIR true
|
||||
|
||||
# Change this cron rule to what fits best for you
|
||||
# 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
|
||||
############################
|
||||
|
||||
VOLUME $SRC_DIR
|
||||
VOLUME $CCACHE_DIR
|
||||
VOLUME $OUT_DIR
|
||||
|
||||
# Copy required files and fix permissions
|
||||
#####################
|
||||
|
||||
COPY src/* /root/
|
||||
RUN chmod 0755 /root/*.sh
|
||||
|
||||
# Create missing directories
|
||||
############################
|
||||
|
||||
RUN mkdir -p $SRC_DIR
|
||||
RUN mkdir -p $CCACHE_DIR
|
||||
RUN mkdir -p $OUT_DIR
|
||||
|
||||
# Set the work directory
|
||||
########################
|
||||
|
||||
WORKDIR $SRC_DIR
|
||||
|
||||
# Fix permissions
|
||||
#################
|
||||
|
||||
RUN chmod 0755 /root/build.sh
|
||||
RUN chmod 0644 /etc/cron.d/crontab
|
||||
|
||||
# Get the repo CLI tool from Google
|
||||
###################################
|
||||
|
||||
ADD https://storage.googleapis.com/git-repo-downloads/repo /usr/local/bin/
|
||||
RUN chmod 0755 /usr/local/bin/repo
|
||||
|
||||
# Enable multilib support
|
||||
#########################
|
||||
|
||||
RUN sed -i "/\[multilib\]/,/Include/"'s/^#//' /etc/pacman.conf
|
||||
|
||||
# Replace conflicting packages
|
||||
##############################
|
||||
|
||||
RUN yes | pacman -Sy --needed gcc-multilib
|
||||
|
||||
# Install AUR package manager
|
||||
#############################
|
||||
|
||||
RUN pacman -U --noconfirm /root/apacman-3.1-1-any.pkg.tar.xz \
|
||||
&& rm /root/apacman-3.1-1-any.pkg.tar.xz
|
||||
|
||||
# Install missing AUR packages
|
||||
##############################
|
||||
|
||||
RUN apacman -S --noconfirm \
|
||||
ncurses5-compat-libs \
|
||||
lib32-ncurses5-compat-libs \
|
||||
jdk
|
||||
|
||||
# Install required Android AOSP packages
|
||||
########################################
|
||||
|
||||
RUN pacman -Sy --needed --noconfirm \
|
||||
git \
|
||||
gnupg \
|
||||
flex \
|
||||
bison \
|
||||
gperf \
|
||||
sdl \
|
||||
wxgtk \
|
||||
squashfs-tools \
|
||||
curl \
|
||||
ncurses \
|
||||
zlib \
|
||||
schedtool \
|
||||
perl-switch \
|
||||
zip \
|
||||
unzip \
|
||||
libxslt \
|
||||
bc \
|
||||
lib32-zlib \
|
||||
lib32-ncurses \
|
||||
lib32-readline \
|
||||
rsync \
|
||||
maven \
|
||||
repo \
|
||||
imagemagick \
|
||||
ccache \
|
||||
libxml2 \
|
||||
cronie \
|
||||
ninja
|
||||
|
||||
# Create missing symlink to python2
|
||||
###################################
|
||||
RUN ln -s /usr/bin/python2 /usr/local/bin/python
|
||||
|
||||
# Cleanup
|
||||
#########
|
||||
|
||||
RUN yes | pacman -Scc \
|
||||
&& yes | pacman -Sc --cachedir=/var/cache/apacman/pkg
|
||||
|
||||
# Set the entry point to init.sh
|
||||
###########################################
|
||||
|
||||
ENTRYPOINT /root/init.sh
|
42
README.md
42
README.md
@ -1,2 +1,44 @@
|
||||
# docker-lineage-cicd
|
||||
|
||||
Docker microservice for LineageOS Continuous Integration and Continous Deployment
|
||||
|
||||
## Why
|
||||
|
||||
Because I always believe that even advanced technologies should be available to everyone. This is a tentative to offer everyone the possibility to build his own images of LineageOS, when he wants, how he wants. You don't have to wait anymore for build bots. No more scene drama. Just build and enjoy your favourite Android ROM.
|
||||
|
||||
## Why Docker?
|
||||
|
||||
Because I'm a big fan of isolating everything if possible. I don't want to reinstall my OS or triage with dirty packages, just because today I need somethng, and tomorrow I'll need something else.
|
||||
|
||||
## How it works
|
||||
|
||||
This docker will autobuild any device list given for a specified branch every midnight at 02:00 UTC. In the end, any built ZIP will be moved to the relative volume mapped directory to `/srv/out`.
|
||||
|
||||
## How to use
|
||||
|
||||
### Simple mode
|
||||
build LineageOS for `hammerhead` with default settings
|
||||
```
|
||||
docker run \
|
||||
--restart=always \
|
||||
-d \
|
||||
-e "DEVICE_LIST=hammerhead" \
|
||||
-v "/home/user/ccache:/srv/ccache" \
|
||||
-v "/home/user/source:/srv/src" \
|
||||
-v "/home/user/zips:/srv/out" \
|
||||
julianxhokaxhiu/docker-lineage-cicd
|
||||
```
|
||||
|
||||
### Advanced mode
|
||||
build cm-13.0 LineageOS for `hammerhead` and `bullhead`
|
||||
```
|
||||
docker run \
|
||||
--restart=always \
|
||||
-d \
|
||||
-e "BRANCH_NAME=cm-13.0" \
|
||||
-e "DEVICE_LIST=hammerhead,bullhead" \
|
||||
-v "/home/user/ccache:/srv/ccache" \
|
||||
-v "/home/user/source:/srv/src" \
|
||||
-v "/home/user/zips:/srv/out" \
|
||||
julianxhokaxhiu/docker-lineage-cicd
|
||||
```
|
BIN
src/apacman-3.1-1-any.pkg.tar.xz
Normal file
BIN
src/apacman-3.1-1-any.pkg.tar.xz
Normal file
Binary file not shown.
46
src/build.sh
Normal file
46
src/build.sh
Normal file
@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Build script
|
||||
#
|
||||
###########################################################
|
||||
|
||||
if ! [ -z "$DEVICE_LIST" ]; then
|
||||
|
||||
# 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
|
||||
|
||||
# Sync the source code
|
||||
repo sync
|
||||
|
||||
# If requested, clean the OUT dir in order to avoid clutter
|
||||
if [ "$CLEAN_OUTDIR" = true ]; then
|
||||
rm -Rf "$OUT_DIR/*"
|
||||
fi
|
||||
|
||||
# Prepare the environment
|
||||
source build/envsetup.sh
|
||||
|
||||
# Cycle DEVICE_LIST environment variable, to know which one may be executed next
|
||||
IFS=','
|
||||
for codename in $DEVICE_LIST; do
|
||||
if ! [ -z "$codename" ]; then
|
||||
# Start the build
|
||||
brunch $codename
|
||||
|
||||
# Move produced ZIP files to the main OUT directory
|
||||
find out/target/product/$codename/ -name '*UNOFFICIAL*.zip*' -exec mv {} $OUT_DIR \;
|
||||
|
||||
# Clean everything, in order to start fresh on next build
|
||||
cd $SRC_DIR
|
||||
make clean
|
||||
fi
|
||||
done
|
||||
|
||||
# Clean the src directory if requested
|
||||
if [ "$CLEAN_SRCDIR" = true ]; then
|
||||
rm -Rf "$SRC_DIR/*"
|
||||
fi
|
||||
fi
|
25
src/init.sh
Normal file
25
src/init.sh
Normal file
@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Init script
|
||||
#
|
||||
###########################################################
|
||||
|
||||
# Set a custom updater URI if a OTA URL is provided
|
||||
if ! [ -z "$OTA_URL" ]; then
|
||||
export ADDITIONAL_DEFAULT_PROPERTIES="cm.updater.uri=$OTA_URL"
|
||||
fi
|
||||
|
||||
# Initialize CCache if it will be used
|
||||
if [ "$USE_CCACHE" = 1 ]; then
|
||||
ccache -M 50G
|
||||
fi
|
||||
|
||||
# Initialize Git user information
|
||||
git config --global user.name $USER_NAME
|
||||
git config --global user.email $USER_MAIL
|
||||
|
||||
# Initialize the cronjob
|
||||
echo -e "$CRONTAB_TIME /usr/bin/flock -n /tmp/lock.build /root/build.sh\n" > /etc/cron.d/crontab
|
||||
|
||||
# Start the cron job service
|
||||
cron -f
|
Loading…
Reference in New Issue
Block a user