Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

script: double change #89

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 34 additions & 4 deletions build-dakkar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ elif [[ $(uname -s) = "Linux" ]];then
fi

## handle command line arguments
read -p "Do you want to sync? " choice
read -p "[Phhusson magic-wand] Do you want to sync the whole jazz? " choice
read -p "[Phhusson magic-wand] Do you have a reference path? " refchoice
if [[ $refchoice == *"y"* ]];then
read -p "[Phhusson magic-wand] Insert your path including the home path, eg. /home/user/dirtoreference " refpath
fi

function help() {
cat <<EOF
Expand Down Expand Up @@ -100,14 +104,13 @@ function get_rom_type() {
mainrepo="https://github.com/PixelExperience/manifest"
mainbranch="oreo-mr1"
localManifestBranch="android-8.1"
treble_generate="pixel"
extra_make_options="WITHOUT_CHECK_API=true"
treble_generate=""
;;
crdroid)
mainrepo="https://github.com/crdroidandroid/android"
mainbranch="8.1"
localManifestBranch="android-8.1"
treble_generate="crdroid"
treble_generate="lineage"
extra_make_options="WITHOUT_CHECK_API=true"
;;
mokee)
Expand Down Expand Up @@ -225,6 +228,10 @@ function init_main_repo() {
repo init -u "$mainrepo" -b "$mainbranch"
}

function init_main_repo_ref() {
repo init -u "$mainrepo" -b "$mainbranch" --reference=$refpath
}

function clone_or_checkout() {
local dir="$1"
local repo="$2"
Expand Down Expand Up @@ -300,6 +307,23 @@ function jack_env() {
fi
}

function save_the_dev() {
if [ -d device/phh/treble ];then
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please invert this to reduce indentation and for better clarity

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

invert?
What do you mean ?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something like
[ -d device/phh/treble] && return

cd device/phh/treble
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use a subshell, instead of cd xxx; .... ; cd $curpath which is error prone

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a function doesn't automatically assume to execute stuff in subshell?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if that's the case, you can just drop the cd $oldpwd

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stuff is, the execution of this script is in the root of sync, if I drop the cd it will stash on the whole rom files and not only on DT

if ! git stash -u;then
stashstatus=empty
fi

fi
}

function restore_the_dev() {
if [ -d device/phh/treble ] && [ -z "$stashstatus" ];then
cd device/phh/treble
git stash apply
fi
}

parse_options "$@"
get_rom_type "$@"
get_variants "$@"
Expand All @@ -311,10 +335,16 @@ fi

if [[ $choice == *"y"* ]];then
init_release
if [[ -z "$refpath" ]];then
init_main_repo
else
init_main_repo_ref
fi
init_local_manifest
init_patches
save_the_dev
sync_repo
restore_the_dev
fi
patch_things
jack_env
Expand Down