add divestos bin
This commit is contained in:
parent
febfe1291b
commit
af63979692
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,6 +1,7 @@
|
||||
*
|
||||
!Dockerfile
|
||||
!configs
|
||||
!configs/divestos
|
||||
!.envrc
|
||||
!flake.lock
|
||||
!flake.nix
|
||||
|
235
configs/divestos
Normal file
235
configs/divestos
Normal file
@ -0,0 +1,235 @@
|
||||
#!/bin/bash -li
|
||||
|
||||
# ARGUMENTS
|
||||
INIT=0
|
||||
INIT_REPO=0
|
||||
# SYNC=0
|
||||
# BUILD=0
|
||||
# FORCE_CLEAN=0
|
||||
|
||||
USAGE="$(basename "$0") <arg> -- Helper for divestos compilation tool
|
||||
|
||||
where <arg> can be :
|
||||
-c|--clean -- Cleans the DivestOS repository folder
|
||||
i|init -- Init some setting, like git and gpg (automatically start with container)
|
||||
r|init-repo -- Init DivestOS repo
|
||||
b|build -- Compiles DivestOS repo
|
||||
s|sync -- Syncs DivestOS repo repo
|
||||
all -- shortcut for performing 'DivestOS init build'
|
||||
"
|
||||
|
||||
# Argparse
|
||||
while [[ $# > 0 ]]; do
|
||||
key="$1"
|
||||
shift
|
||||
case $key in
|
||||
i|init)
|
||||
INIT=1
|
||||
;;
|
||||
r|init-repo)
|
||||
INIT_REPO=1
|
||||
;;
|
||||
# b|build)
|
||||
# BUILD=1
|
||||
# ;;
|
||||
# all)
|
||||
# INIT=1
|
||||
# BUILD=1
|
||||
# ;;
|
||||
# s|sync)
|
||||
# SYNC=1
|
||||
# ;;
|
||||
# -c|--clean)
|
||||
# FORCE_CLEAN=1
|
||||
# ;;
|
||||
# -h|--help)
|
||||
# echo "$USAGE"
|
||||
# ;;
|
||||
*)
|
||||
echo "[ERROR] Options not found."
|
||||
echo "$USAGE"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
############################
|
||||
# VARS
|
||||
#
|
||||
|
||||
BASHRC=$BASE_DIR/.bashrc
|
||||
|
||||
function config_git {
|
||||
if [[ ! -z $GIT_USER_NAME ]]; then
|
||||
git config --global user.name "$GIT_USER_NAME";
|
||||
fi
|
||||
|
||||
if [[ ! -z $GIT_USER_EMAIL ]]; then
|
||||
git config --global user.email "$GIT_USER_EMAIL";
|
||||
fi
|
||||
git-lfs install
|
||||
}
|
||||
|
||||
function import_gpg_keys {
|
||||
if [[ ! -z $GPG_PASSWORD ]]; then
|
||||
echo "$GPG_PASSWORD" | gpg --home $GNUPGHOME --batch --yes --allow-secret-key-import --import $GPG_KEY_FILE
|
||||
fi
|
||||
}
|
||||
|
||||
function config_ccache {
|
||||
[[ ! -z $CCACHE_COMPRESS ]] && ccache -o compression=$CCACHE_COMPRESS
|
||||
[[ ! -z $CCACHE_COMPRESSLEVEL ]] && ccache -o compression_level=$CCACHE_COMPRESSLEVEL
|
||||
[[ ! -z $CCACHE_MAX_SIZE ]] && ccache -M $CCACHE_MAX_SIZE
|
||||
[[ ! -z $CCACHE_DIR ]] && ccache -o cache_dir=$CCACHE_DIR
|
||||
}
|
||||
|
||||
function init {
|
||||
echo "[INIT] configure git"
|
||||
config_git;
|
||||
echo "[INIT] import gpg keys"
|
||||
import_gpg_keys;
|
||||
echo "[INIT] setup ccache"
|
||||
config_ccache;
|
||||
echo "[INIT] init done"
|
||||
}
|
||||
|
||||
function extract_blobs {
|
||||
cd $DOS_WORKSPACE_ROOT/Build/LineageOS-$LINEAGEOS_VERSION
|
||||
source $DOS_WORKSPACE_ROOT/Scripts/init.sh
|
||||
source build/envsetup.sh
|
||||
breakfast $DEVICE
|
||||
if [[ ! -z $PROPRIETARY_BLOBS_REPO ]]; then
|
||||
echo "[INIT REPO] cloning device's proprietary blobs"
|
||||
if [ ! -d "$PROPRIETARY_BLOBS_DIR" ]; then
|
||||
git clone -b $PROPRIETARY_BLOBS_BRANCH --single-branch $PROPRIETARY_BLOBS_REPO $PROPRIETARY_BLOBS_DIR
|
||||
else
|
||||
git -C $PROPRIETARY_BLOBS_DIR pull
|
||||
fi
|
||||
echo "[INIT REPO] copying device's proprietary blobs"
|
||||
cd $DOS_BUILD_BASE/$LINEAGEOS_DEVICE_DIR
|
||||
set -e
|
||||
./extract-files.sh $PROPRIETARY_BLOBS_DIR
|
||||
set +e
|
||||
fi
|
||||
cd $DOS_BUILD_BASE
|
||||
}
|
||||
|
||||
function mount_gocryptfs {
|
||||
if [[ ! -z $GOCRYPTFS_PASS ]]; then
|
||||
echo "$GOCRYPTFS_PASS" | gocryptfs $GOCRYPTFS_DIR $DOS_SIGNING_KEYS
|
||||
fi
|
||||
}
|
||||
|
||||
function unmount_gocryptfs {
|
||||
if [[ ! -z $GOCRYPTFS_PASS ]]; then
|
||||
fusermount -u $DOS_SIGNING_KEYS
|
||||
fi
|
||||
}
|
||||
|
||||
function init_repo {
|
||||
SECONDS=0
|
||||
|
||||
echo "[INIT REPO] clone DivestOS repo"
|
||||
git clone $DIVESTOS_REPO $DOS_WORKSPACE_ROOT
|
||||
git -C $DOS_WORKSPACE_ROOT/PrebuiltApps lfs pull
|
||||
cd $DOS_WORKSPACE_ROOT
|
||||
git submodule update --init --recursive
|
||||
mkdir -p Build/LineageOS-$LINEAGEOS_VERSION/.repo/local_manifests
|
||||
mkdir -p $DOS_BUILDS $DOS_SIGNING_KEYS
|
||||
if [[ ! -z $GOCRYPTFS_PASS ]]; then
|
||||
echo "[INIT REPO] setup gocryptfs"
|
||||
mkdir -p $GOCRYPTFS_DIR
|
||||
echo "$GOCRYPTFS_PASS" | gocryptfs -init $GOCRYPTFS_DIR
|
||||
echo "$GOCRYPTFS_PASS" | gocryptfs $GOCRYPTFS_DIR $DOS_SIGNING_KEYS
|
||||
fi
|
||||
cd Build/LineageOS-$LINEAGEOS_VERSION
|
||||
if [[ ! -z $LOCAL_MANIFEST_REPO ]]; then
|
||||
git clone $LOCAL_MANIFEST_REPO .repo/local_manifests -b $LOCAL_MANIFEST_BRANCH
|
||||
elif [[ ! -z $LOCALMANIFEST_PATH ]]; then
|
||||
cat $LOCALMANIFEST_PATH > .repo/local_manifests/local_manifest.xml
|
||||
else
|
||||
cat ../../Manifests/Manifest_LAOS-$LINEAGEOS_VERSION.xml > .repo/local_manifests/local_manifest.xml
|
||||
fi
|
||||
echo "[INIT REPO] init LineageOS repo"
|
||||
yes | repo init -u $LINEAGEOS_REPO -b $LINEAGEOS_BRANCH
|
||||
echo "[INIT REPO] sync LineageOS repo (this will take a while)"
|
||||
[[ $(nproc) -gt 8 ]] && repo sync -j8 -c || repo sync -j$(nproc) -c
|
||||
extract_blobs;
|
||||
|
||||
ELAPSED="$(($SECONDS / 3600))hrs $((($SECONDS / 60) % 60))min $(($SECONDS % 60))sec"
|
||||
echo "[INIT REPO] repo init finished in $ELAPSED"
|
||||
unmount_gocryptfs;
|
||||
}
|
||||
|
||||
function gen_sign_keys {
|
||||
mount_gocryptfs;
|
||||
SECONDS=0
|
||||
|
||||
echo "[GEN KEYS] start generate signing keys"
|
||||
cd $DOS_WORKSPACE_ROOT/Build/LineageOS-$LINEAGEOS_VERSION
|
||||
source $DOS_WORKSPACE_ROOT/Scripts/init.sh
|
||||
source build/envsetup.sh
|
||||
breakfast $DEVICE
|
||||
make -j$(($(nproc)+2)) generate_verity_key
|
||||
sh $DOS_WORKSPACE_ROOT/Scripts/Generate_Signing_Keys.sh $DEVICE
|
||||
|
||||
ELAPSED="$(($SECONDS / 3600))hrs $((($SECONDS / 60) % 60))min $(($SECONDS % 60))sec"
|
||||
|
||||
echo "[GEN KEYS] generate signing keys done in $ELAPSED"
|
||||
unmount_gocryptfs;
|
||||
}
|
||||
|
||||
function build {
|
||||
mount_gocryptfs;
|
||||
SECONDS=0
|
||||
|
||||
echo "[BUILD] building DivestOS for $DEVICE"
|
||||
cd $DOS_WORKSPACE_ROOT/Build/LineageOS-$LINEAGEOS_VERSION
|
||||
source $DOS_WORKSPACE_ROOT/Scripts/init.sh
|
||||
source build/envsetup.sh
|
||||
breakfast $DEVICE
|
||||
resetWorkspace
|
||||
patchWorkspace
|
||||
read -p "> Do you want to continue building?" -n 1 -r
|
||||
[[ "$DOS_AVB_BUILD" != false ]] && buildDevice $DEVICE avb || buildDevice $DEVICE
|
||||
|
||||
ELAPSED="$(($SECONDS / 3600))hrs $((($SECONDS / 60) % 60))min $(($SECONDS % 60))sec"
|
||||
|
||||
echo "[BUILD] done building in $ELAPSED"
|
||||
unmount_gocryptfs;
|
||||
}
|
||||
|
||||
# function build_ota {
|
||||
# https://source.android.com/docs/core/ota/tools#incremental-updates
|
||||
# }
|
||||
|
||||
function delete_build {
|
||||
source "$DOS_WORKSPACE_ROOT/Scripts/init.sh"
|
||||
local OUT_DIR="$DOS_BUILD_BASE/out/target/product/$DEVICE/"
|
||||
rm -rf --one-file-system "$OUT_DIR"
|
||||
}
|
||||
|
||||
############################
|
||||
# Script options
|
||||
#
|
||||
|
||||
pushd $BASE_DIR > /dev/null 2>&1
|
||||
if [[ $INIT == 1 ]]; then
|
||||
init;
|
||||
fi
|
||||
|
||||
if [[ $INIT_REPO == 1 ]]; then
|
||||
init_repo;
|
||||
gen_sign_keys;
|
||||
fi
|
||||
|
||||
# # if sync repo passes forces a lineage repo sync
|
||||
# if [[ $SYNC == 1 ]]; then
|
||||
# sync;
|
||||
# fi
|
||||
|
||||
# # if sync repo passes forces a lineage repo sync
|
||||
# if [[ $BUILD == 1 ]]; then
|
||||
# build;
|
||||
# fi
|
||||
|
||||
popd > /dev/null 2>&1
|
Loading…
x
Reference in New Issue
Block a user