-
-
Notifications
You must be signed in to change notification settings - Fork 62
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
Improvements to UN1CA #279
base: fourteen
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,68 @@ | |
|
||
set -o allexport | ||
|
||
PACKAGES=( | ||
libbrotli-dev liblz4-dev libzstd-dev protobuf-compiler libgtest-dev | ||
ffmpeg webp zipalign clang build-essential cmake openjdk-17-jdk | ||
libncurses-dev bison flex libssl-dev libelf-dev python3 | ||
python-is-python3 cpio attr zip libprotobuf-dev make | ||
libpcre2-dev ccache npm | ||
) | ||
|
||
echo "Checking dependencies..." | ||
|
||
MISSING_PACKAGES=() | ||
for PACKAGE in "${PACKAGES[@]}"; do | ||
if ! dpkg -s "$PACKAGE" >/dev/null 2>&1; then | ||
MISSING_PACKAGES+=("$PACKAGE") | ||
fi | ||
done | ||
|
||
if [ ${#MISSING_PACKAGES[@]} -eq 0 ]; then | ||
echo "All dependencies are already installed." | ||
else | ||
echo "The following packages are missing: ${MISSING_PACKAGES[*]}" | ||
echo "Attempting to install missing packages..." | ||
sudo apt update | ||
sudo apt install "${MISSING_PACKAGES[@]}" | ||
fi | ||
|
||
echo "Checking for missing Git submodules..." | ||
|
||
if [ -f .gitmodules ]; then | ||
UNINITIALIZED_SUBMODULES=$(git submodule status | grep '^-' || true) | ||
|
||
if [ -n "$UNINITIALIZED_SUBMODULES" ]; then | ||
echo "The following submodules are missing or uninitialized:" | ||
echo "$UNINITIALIZED_SUBMODULES" | ||
echo "Initializing and cloning submodules..." | ||
git submodule update --init --recursive | ||
if [ $? -eq 0 ]; then | ||
echo "Submodules initialized and cloned successfully." | ||
else | ||
echo "Failed to clone submodules. Please check your repository configuration." | ||
exit 1 | ||
fi | ||
else | ||
echo "All submodules are already initialized." | ||
fi | ||
else | ||
echo "No submodules found in this repository." | ||
fi | ||
|
||
#create venv if not exist | ||
if [ ! -f "venv/bin/activate" ]; then | ||
echo "Virtual environment not found. Creating a new one..." | ||
python3 -m venv venv | ||
else | ||
echo "Virtual environment already exists." | ||
fi | ||
|
||
source venv/bin/activate | ||
|
||
pip3 install git+https://github.com/ananjaser1211/samloader.git &> /dev/null | ||
|
||
|
||
# [ | ||
SRC_DIR="$(git rev-parse --show-toplevel)" | ||
OUT_DIR="$SRC_DIR/out" | ||
|
@@ -32,14 +94,30 @@ TOOLS_DIR="$OUT_DIR/tools/bin" | |
|
||
PATH="$TOOLS_DIR:$PATH" | ||
|
||
run_cmd() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This breaks workflows. You should change them too. |
||
unica() | ||
{ | ||
local CMD=$1 | ||
local CMDS | ||
CMDS="$(find "scripts" -mindepth 1 -maxdepth 1 -type f -printf '%f\n' | sed "s/.sh//g")" | ||
|
||
local YELLOW="\033[1;33m" | ||
local CYAN="\033[1;36m" | ||
local RESET_COLOR="\033[0m" | ||
|
||
if [ -z "$CMD" ] || [ "$CMD" = "-h" ]; then | ||
echo -e "Available cmds:\n$CMDS" | ||
echo -e "Available cmds:" | ||
for script in "scripts"/*.sh; do | ||
CMD_NAME=$(basename "$script" .sh) | ||
HELP_LINES=$(grep "^# CMD_HELP" "$script" | sed 's/^# CMD_HELP[[:space:]]*//') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a thought of mine, I think creating a function inside each script which prints the help is a bit better than this actual implementation. |
||
|
||
if [ -n "$HELP_LINES" ]; then | ||
echo -e "${YELLOW}$CMD_NAME${RESET_COLOR}:" | ||
echo -e "${CYAN}$HELP_LINES${RESET_COLOR}" | ||
echo "" | ||
else | ||
echo -e "${YELLOW}$CMD_NAME${RESET_COLOR} - No help available" | ||
fi | ||
done | ||
return 1 | ||
elif ! echo "$CMDS" | grep -q -w "$CMD"; then | ||
echo "\"$CMD\" is not valid." | ||
|
@@ -50,31 +128,52 @@ run_cmd() | |
bash -e "$SRC_DIR/scripts/$CMD.sh" "$@" | ||
fi | ||
} | ||
|
||
# ] | ||
|
||
TARGETS="$(ls "$SRC_DIR/target")" | ||
TARGETS=($(ls "$SRC_DIR/target")) | ||
|
||
if [ "$#" != 1 ]; then | ||
if [ "$#" -ne 1 ]; then | ||
echo "Usage: source buildenv.sh <target>" | ||
echo -e "Available devices:\n$TARGETS" | ||
return 1 | ||
elif ! echo "$TARGETS" | grep -q -w "$1"; then | ||
echo "\"$1\" is not valid target." | ||
echo -e "Available devices:\n$TARGETS" | ||
return 1 | ||
echo "No target specified. Please choose from the available devices below:" | ||
|
||
select TARGET in "${TARGETS[@]}"; do | ||
if [ -n "$TARGET" ]; then | ||
echo "You selected: $TARGET" | ||
export SELECTED_TARGET="$TARGET" | ||
break | ||
else | ||
echo "Invalid selection. Please try again." | ||
fi | ||
done | ||
|
||
if [ -z "$SELECTED_TARGET" ]; then | ||
echo "No valid target selected. Exiting." | ||
return 1 | ||
fi | ||
else | ||
mkdir -p "$OUT_DIR" | ||
run_cmd build_dependencies || return 1 | ||
[ -f "$OUT_DIR/config.sh" ] && unset $(sed "/Automatically/d" "$OUT_DIR/config.sh" | cut -d= -f1) | ||
bash "$SRC_DIR/scripts/internal/gen_config_file.sh" "$1" || return 1 | ||
source "$OUT_DIR/config.sh" | ||
|
||
echo "==============================" | ||
sed "/Automatically/d" "$OUT_DIR/config.sh" | ||
echo "==============================" | ||
if ! printf "%s\n" "${TARGETS[@]}" | grep -q -w "$1"; then | ||
echo "\"$1\" is not a valid target." | ||
echo "Available devices:" | ||
printf "%s\n" "${TARGETS[@]}" | ||
return 1 | ||
fi | ||
SELECTED_TARGET="$1" | ||
fi | ||
|
||
mkdir -p "$OUT_DIR" | ||
unica build_dependencies || return 1 | ||
|
||
if [ -f "$OUT_DIR/config.sh" ]; then | ||
unset $(sed "/Automatically/d" "$OUT_DIR/config.sh" | cut -d= -f1) | ||
fi | ||
|
||
unset TARGETS | ||
set +o allexport | ||
bash "$SRC_DIR/scripts/internal/gen_config_file.sh" "$SELECTED_TARGET" || return 1 | ||
source "$OUT_DIR/config.sh" | ||
|
||
echo "==============================" | ||
sed "/Automatically/d" "$OUT_DIR/config.sh" | ||
echo "type "unica -h" for help" | ||
|
||
|
||
return 0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,8 @@ | |
|
||
# shellcheck disable=SC2162 | ||
|
||
# CMD_HELP Extracts downloaded Firmware | ||
|
||
set -e | ||
|
||
# [ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,8 @@ | |
|
||
# shellcheck disable=SC2001 | ||
|
||
# CMD_HELP Prints the available module informations. | ||
|
||
set -Ee | ||
|
||
# [ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This way you are considering that only Debian-based distros will be used for ROM building. You should adapt this logic to check if distro is Debian based. Possibly some packages are also available only in certain distros/releases.
Openjdk 11 is the minimum required version. And if I remember correctly also unzip package has to be installed.