refactor
This commit is contained in:
parent
b5372832e5
commit
3c5688012f
14 changed files with 67 additions and 226 deletions
|
|
@ -1,10 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
# global definitions:
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
NC='\033[0m'
|
||||
|
||||
# check the parameters
|
||||
if [ $# != 2 ]; then
|
||||
echo "usage : $0 <project_root> <python_package>"
|
||||
|
|
@ -15,15 +10,7 @@ project_root="$1"
|
|||
python_package="$2"
|
||||
|
||||
# check the required tools
|
||||
TOOL_LIST="unzip sed"
|
||||
for tool_name in $TOOL_LIST; do
|
||||
echo "Checking tool: $tool_name"
|
||||
tool_path=$(which "$tool_name")
|
||||
if [ -z "$tool_path" ]; then
|
||||
echo -e "${RED}ERROR: Missing tool '$tool_name' ${NC}"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
check_tools "unzip sed"
|
||||
|
||||
# check the project root folder
|
||||
if [ ! -d "$project_root" ]; then
|
||||
|
|
@ -32,7 +19,7 @@ if [ ! -d "$project_root" ]; then
|
|||
fi
|
||||
|
||||
# check the python package folder
|
||||
python_package_folder="${project_root}/RESOURCES/OPTIONS/python/${python_package}"
|
||||
python_package_folder="${OPTIONS_DIR}/python/${python_package}"
|
||||
if [ ! -d "$python_package_folder" ]; then
|
||||
echo -e "${RED}ERROR: Cannot find the folder '$python_package_folder' ${NC}"
|
||||
exit 4
|
||||
|
|
@ -46,7 +33,7 @@ if [ ! -f "$python_package_file" ]; then
|
|||
fi
|
||||
|
||||
# check the target folder
|
||||
target_folder="$project_root/unpacked/squashfs-root"
|
||||
target_folder="$ROOTFS_DIR"
|
||||
if [ ! -d "$target_folder" ]; then
|
||||
echo -e "${RED}ERROR: Cannot find the target folder '$target_folder' ${NC}"
|
||||
exit 6
|
||||
|
|
@ -57,7 +44,7 @@ current_folder="$PWD"
|
|||
cd "$target_folder" || exit 7
|
||||
unzip -o "$python_package_file"
|
||||
# extend the PATH to $project_root/unpacked/squashfs-root/etc/profile
|
||||
sed -i 's#export PATH="/usr/sbin:/usr/bin:/sbin:/bin"#export PATH="/usr/sbin:/usr/bin:/sbin:/bin:/opt/sbin:/opt/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"#' "$project_root/unpacked/squashfs-root/etc/profile"
|
||||
sed -i 's#export PATH="/usr/sbin:/usr/bin:/sbin:/bin"#export PATH="/usr/sbin:/usr/bin:/sbin:/bin:/opt/sbin:/opt/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"#' "$ROOTFS_DIR/etc/profile"
|
||||
cd "$current_folder" || exit 8
|
||||
|
||||
echo -e "${GREEN}The python package has been successfully installed ${NC}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue