Skip to content

Commit

Permalink
Switch from SVN to Git
Browse files Browse the repository at this point in the history
  • Loading branch information
ophub committed Dec 6, 2023
1 parent 71d57be commit 98dd3e5
Show file tree
Hide file tree
Showing 5 changed files with 161 additions and 102 deletions.
44 changes: 27 additions & 17 deletions build-armbian/armbian-files/common-files/usr/sbin/armbian-kernel
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ script_name="${script_path}/armbian_compile_kernel_script.sh"
arch_info="$(arch)"

# The compile kernel scripts download repository
script_repo="https://github.com/ophub/amlogic-s9xxx-armbian/tree/main/compile-kernel"
script_repo="https://github.com/ophub/amlogic-s9xxx-armbian.git"
script_dir="compile-kernel"

# Set font color
STEPS="[\033[95m STEPS \033[0m]"
Expand All @@ -53,27 +54,34 @@ error_msg() {
}

update_script() {
cd ${make_path}
echo -e "${STEPS} Start updating the compile kernel scripts..."

# Install subversion
# Install git
echo -e "${INFO} Start installing update dependencies..."
sudo apt-get update
sudo apt-get install -y subversion
[[ "${?}" -ne "0" ]] && error_msg "The [ subversion ] installation failed."
[[ -z "$(dpkg -l | awk '{print $2}' | grep -w "^git$")" ]] && sudo apt-get update && sudo apt-get install -y git

# Convert script repository address to svn format
if [[ "${script_repo}" == http* && -n "$(echo ${script_repo} | grep "tree/main")" ]]; then
script_repo="${script_repo//tree\/main/trunk}"
fi
# Get the latest scripts
echo -e "${INFO} Start syncing latest scripts..."
git_tmp_path="$(mktemp -d)"
cd ${git_tmp_path}
git init --quiet
git remote add origin ${script_repo}
git config core.sparseCheckout true
echo "${script_dir}/*" >>.git/info/sparse-checkout
git pull --quiet --depth=1 origin main
[[ "${?}" -ne "0" ]] && error_msg "Download [ ${script_repo} ] scripts failed."

# Update related files
echo -e "${INFO} Start syncing latest scripts..."
svn export ${script_repo} ${compile_path} --force
cd ${make_path}
mkdir -p ${compile_path}
cp -rf ${git_tmp_path}/${script_dir}/* ${compile_path}
[[ "${?}" -ne "0" ]] && error_msg "Sync [ ${script_repo} ] scripts failed."
cp -f ${script_name} ${compile_script}
chmod +x ${compile_script}

# Clean up temporary files
rm -rf ${git_tmp_path} 2>/dev/null

# Install dependencies
echo -e "${INFO} Start installing compilation dependencies..."
sudo apt-get install -y $(cat ${script_path}/armbian-compile-kernel-depends)
Expand Down Expand Up @@ -128,9 +136,11 @@ remaining_space="$(df -Tk ${make_path} | grep '/dev/' | awk '{print $5}' | echo

# Execute script assist functions
case "${1}" in
-u | --update) update_script ;;
-c | --clean) clean_tmp ;;
-h | --help) help_info ;;
*) [[ -f "${compile_script}" ]] || error_msg "Please run [ armbian-kernel -u ] to update scripts."
cd ${make_path} && sudo ${compile_script} "${@}" ;;
-u | --update) update_script ;;
-c | --clean) clean_tmp ;;
-h | --help) help_info ;;
*)
[[ -f "${compile_script}" ]] || error_msg "Please run [ armbian-kernel -u ] to update scripts."
cd ${make_path} && sudo ${compile_script} "${@}"
;;
esac
43 changes: 26 additions & 17 deletions build-armbian/armbian-files/common-files/usr/sbin/armbian-software
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ ophub_release_file="/etc/ophub-release"
arch_info="$(arch)"
#
# The compile kernel scripts download repository
script_repo="https://github.com/ophub/amlogic-s9xxx-armbian/tree/main/build-armbian/armbian-files/common-files${software_path}"
script_repo="https://github.com/ophub/amlogic-s9xxx-armbian.git"
script_dir="build-armbian/armbian-files/common-files/usr/share/ophub/armbian-software"
#
# Set font color
STEPS="[\033[95m STEPS \033[0m]"
Expand Down Expand Up @@ -69,7 +70,7 @@ check_depends() {
# List of required dependencies
dpkg_packages=(
"curl" "wget" "tar" "software-properties-common" "apt-transport-https" "ca-certificates"
"subversion" "coreutils" "systemd" "net-tools" "cpu-checker" "dnsmasq-base" "dmidecode"
"git" "coreutils" "systemd" "net-tools" "cpu-checker" "dnsmasq-base" "dmidecode"
)
# Cyclic check all dependencies
is_dpkg="0"
Expand Down Expand Up @@ -108,10 +109,10 @@ check_software_status() {
# Check the software installation status by category
check_status="0"
case "${auth_method}" in
dpkg) [[ -n "$(dpkg -l | awk '{print $2}' | grep -w "^${package}$" 2>/dev/null)" ]] && check_status="1" ;;
docker) [[ -n "$(docker ps -q -f name=${package} 2>/dev/null)" ]] && check_status="1" ;;
which) [[ -n "$(which "${package}" 2>/dev/null)" ]] && check_status="1" ;;
*) check_status="0" ;;
dpkg) [[ -n "$(dpkg -l | awk '{print $2}' | grep -w "^${package}$" 2>/dev/null)" ]] && check_status="1" ;;
docker) [[ -n "$(docker ps -q -f name=${package} 2>/dev/null)" ]] && check_status="1" ;;
which) [[ -n "$(which "${package}" 2>/dev/null)" ]] && check_status="1" ;;
*) check_status="0" ;;
esac
# Adjust software installation status
[[ "${check_status}" -eq "1" ]] && {
Expand Down Expand Up @@ -214,17 +215,25 @@ show_software_list() {
update_script() {
echo -e "${STEPS} Start update script..."

# Convert script repository address to svn format
if [[ "${script_repo}" == http* && -n "$(echo ${script_repo} | grep "tree/main")" ]]; then
script_repo="${script_repo//tree\/main/trunk}"
fi
# Get the latest scripts
git_tmp_path="$(mktemp -d)"
cd ${git_tmp_path}
git init --quiet
git config core.sparseCheckout true
echo "${script_dir}/*" >>.git/info/sparse-checkout
git remote add origin ${script_repo}
git pull --quiet --depth=1 origin main
[[ "${?}" -ne "0" ]] && error_msg "Download [ ${script_repo} ] scripts failed."

# Update related files
echo -e "${STEPS} Start syncing files..."
svn export ${script_repo} ${software_path} --force
mkdir -p ${software_path}
cp -rf ${git_tmp_path}/${script_dir}/* ${software_path}
[[ "${?}" -ne "0" ]] && error_msg "Sync [ ${script_repo} ] scripts failed."
find ${software_path} -type f -name '*.sh' -exec chmod +x {} \;

# Clean up temporary files
rm -rf ${git_tmp_path} 2>/dev/null

sync && sleep 3
echo -e "${SUCCESS} Script update complete."
exit 0
Expand Down Expand Up @@ -268,9 +277,9 @@ check_depends

# Execute script assist functions
case "${1}" in
-u | -update) update_script ;;
-c | -clean) clean_tmp ;;
-h | -help) help_info ;;
-q | -quit) echo "quit!" && exit 0 ;;
*) show_software_list ;;
-u | -update) update_script ;;
-c | -clean) clean_tmp ;;
-h | -help) help_info ;;
-q | -quit) echo "quit!" && exit 0 ;;
*) show_software_list ;;
esac
41 changes: 26 additions & 15 deletions build-armbian/armbian-files/common-files/usr/sbin/armbian-sync
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
#
# Armbian firmware config info record file
ophub_release_file="/etc/ophub-release"
# The openvfd files download repository
github_repo="https://github.com/ophub/amlogic-s9xxx-armbian/tree/main/build-armbian/armbian-files"
# The script files download repository
script_repo="https://github.com/ophub/amlogic-s9xxx-armbian.git"
script_dir="build-armbian/armbian-files"
# Operation instruction and service storage path
sbin_path="/usr/sbin"
# Software service storage path
Expand Down Expand Up @@ -72,7 +73,7 @@ check_release() {
check_depends() {
# Check the necessary dependencies for apt install
is_dpkg="0"
dpkg_packages=("subversion" "tar" "coreutils")
dpkg_packages=("git" "tar" "coreutils")
i="1"
for package in ${dpkg_packages[*]}; do
[[ -n "$(dpkg -l | awk '{print $2}' | grep -w "^${package}$" 2>/dev/null)" ]] || is_dpkg="1"
Expand All @@ -91,40 +92,50 @@ check_depends() {
sync_config() {
echo -e "${STEPS} Start syncing all service scripts..."

# Convert script repository address to svn format
if [[ "${github_repo}" == http* && -n "$(echo ${github_repo} | grep "tree/main")" ]]; then
github_repo="${github_repo//tree\/main/trunk}"
fi
# Get the latest scripts
echo -e "${INFO} Start syncing latest scripts..."
git_tmp_path="$(mktemp -d)"
cd ${git_tmp_path}
git init --quiet
git remote add origin ${script_repo}
git config core.sparseCheckout true
echo "${script_dir}/*" >>.git/info/sparse-checkout
git pull --quiet --depth=1 origin main
[[ "${?}" -ne "0" ]] && error_msg "Download [ ${script_repo} ] scripts failed."

# Update operation instruction and service related files
echo -e "${STEPS} Start syncing operation instruction and service script..."
[[ -d "${sbin_path}" ]] || mkdir -p ${sbin_path}
svn export ${github_repo}/common-files${sbin_path} ${sbin_path} --force
[[ "${?}" -ne "0" ]] && error_msg "Sync [ ${github_repo}/common-files${sbin_path} ] scripts failed."
cp -rf ${git_tmp_path}/${script_dir}/common-files${sbin_path}/* ${sbin_path}
[[ "${?}" -ne "0" ]] && error_msg "Sync common-files [ ${sbin_path} ] scripts failed."
chmod +x ${sbin_path}/armbian-*

# Update software service related files
echo -e "${STEPS} Start syncing software service script..."
[[ -d "${share_path}" ]] || mkdir -p ${share_path}
svn export ${github_repo}/common-files${share_path} ${share_path} --force
[[ "${?}" -ne "0" ]] && error_msg "Sync [ ${github_repo}/common-files${share_path} ] scripts failed."
cp -rf ${git_tmp_path}/${script_dir}/common-files${share_path}/* ${share_path}
[[ "${?}" -ne "0" ]] && error_msg "Sync common-files [ ${share_path} ] scripts failed."
find ${share_path} -type f -name '*.sh' -exec chmod +x {} \;

# Update Amlogic platform specific scripts
[[ "${PLATFORM}" == "amlogic" ]] && {
# Update operation instruction and service related files
echo -e "${STEPS} Start syncing Amlogic platform specific scripts..."
svn export ${github_repo}/platform-files/amlogic/rootfs${sbin_path} ${sbin_path} --force
[[ "${?}" -ne "0" ]] && error_msg "Sync [ ${github_repo}/platform-files/amlogic/rootfs${sbin_path} ] scripts failed."
cp -rf ${git_tmp_path}/${script_dir}/platform-files/amlogic/rootfs${sbin_path}/* ${sbin_path}
[[ "${?}" -ne "0" ]] && error_msg "Sync platform-files [ ${sbin_path} ] scripts failed."
chmod +x ${sbin_path}/armbian-*

# Update openvfd related files
echo -e "${STEPS} Start syncing Amlogic platform openvfd service script..."
[[ -d "${openvfd_path}" ]] || mkdir -p ${openvfd_path}
svn export ${github_repo}/platform-files/amlogic/rootfs${openvfd_path} ${openvfd_path} --force
[[ "${?}" -ne "0" ]] && error_msg "Sync [ ${github_repo}/platform-files/amlogic/rootfs${openvfd_path} ] scripts failed."
cp -rf ${git_tmp_path}/${script_dir}/platform-files/amlogic/rootfs${openvfd_path}/* ${openvfd_path}
[[ "${?}" -ne "0" ]] && error_msg "Sync platform-files [ ${openvfd_path} ] scripts failed."
chmod +x ${openvfd_path}/vfdservice
}

# Clean up temporary files
rm -rf ${git_tmp_path} 2>/dev/null

sync && sleep 3
echo -e "${SUCCESS} All service scripts are synchronized successfully."
exit 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
openvfd_path="/usr/share/openvfd"
openvfd_service="${openvfd_path}/vfdservice"
# The openvfd files download repository
openvfd_repo="https://github.com/ophub/amlogic-s9xxx-armbian/tree/main/build-armbian/armbian-files/platform-files/amlogic/rootfs${openvfd_path}"
openvfd_repo="https://github.com/ophub/amlogic-s9xxx-armbian.git"
openvfd_dir="build-armbian/armbian-files/platform-files/amlogic/rootfs/usr/share/openvfd"
#
# Set font color
STEPS="[\033[95m STEPS \033[0m]"
Expand All @@ -53,20 +54,27 @@ do_update_conf() {
echo -e "${STEPS} Start updating the openfvd config files..."

# Check dependencies
[[ -z "$(dpkg -l | awk '{print $2}' | grep -w "^subversion$")" ]] && sudo apt-get update && sudo apt-get install -y subversion

# Convert script repository address to svn format
if [[ "${openvfd_repo}" == http* && -n "$(echo ${openvfd_repo} | grep "tree/main")" ]]; then
openvfd_repo="${openvfd_repo//tree\/main/trunk}"
fi
[[ -z "$(dpkg -l | awk '{print $2}' | grep -w "^git$")" ]] && sudo apt-get update && sudo apt-get install -y git

# Get the latest scripts
git_tmp_path="$(mktemp -d)"
cd ${git_tmp_path}
git init --quiet
git config core.sparseCheckout true
echo "${openvfd_dir}/*" >>.git/info/sparse-checkout
git remote add origin ${openvfd_repo}
git pull --quiet --depth=1 origin main
[[ "${?}" -ne "0" ]] && error_msg "Download [ ${openvfd_repo} ] scripts failed."

# Update related files
echo -e "${STEPS} Start syncing files..."
[[ -d "${openvfd_path}" ]] || mkdir -p ${openvfd_path}
svn export ${openvfd_repo} ${openvfd_path} --force
mkdir -p ${openvfd_path}
cp -rf ${git_tmp_path}/${openvfd_dir}/* ${openvfd_path}
[[ "${?}" -ne "0" ]] && error_msg "Sync [ ${openvfd_repo} ] scripts failed."
chmod +x ${openvfd_path}/vfdservice

# Clean up temporary files
rm -rf ${git_tmp_path} 2>/dev/null

sync && sleep 3
echo -e "${SUCCESS} Openfvd config files update completed."
exit 0
Expand Down Expand Up @@ -125,38 +133,38 @@ do_stop() {
# Call config based on options
do_select_box() {
case "${1}" in
11 | x96max) do_start x96max.conf ;;
12 | x96maxplus) do_start x96maxplus.conf ;;
13 | x96air) do_start x96air.conf ;;
14 | h96max-x3) do_start h96max-x3.conf ;;
15 | hk1-x3) do_start hk1-x3.conf ;;
16 | hk1box) do_start hk1box.conf ;;
17 | tx3) do_start tx3.conf ;;
18 | tx3-mini) do_start tx3-mini.conf ;;
19 | t95) do_start t95.conf ;;
20 | t95z-plus) do_start t95z-plus.conf ;;
21 | tx9-pro) do_start tx9-pro.conf ;;
22 | x92) do_start x92.conf ;;
23 | whale) do_start whale.conf ;;
24 | x88pro-x3) do_start x88pro-x3.conf ;;
99 | diy) do_start diy.conf ;;
0 | stop) do_stop ;;
1 | quit) echo "quit!" && exit 0 ;;
*) error_msg "Invalid input!" ;;
11 | x96max) do_start x96max.conf ;;
12 | x96maxplus) do_start x96maxplus.conf ;;
13 | x96air) do_start x96air.conf ;;
14 | h96max-x3) do_start h96max-x3.conf ;;
15 | hk1-x3) do_start hk1-x3.conf ;;
16 | hk1box) do_start hk1box.conf ;;
17 | tx3) do_start tx3.conf ;;
18 | tx3-mini) do_start tx3-mini.conf ;;
19 | t95) do_start t95.conf ;;
20 | t95z-plus) do_start t95z-plus.conf ;;
21 | tx9-pro) do_start tx9-pro.conf ;;
22 | x92) do_start x92.conf ;;
23 | whale) do_start whale.conf ;;
24 | x88pro-x3) do_start x88pro-x3.conf ;;
99 | diy) do_start diy.conf ;;
0 | stop) do_stop ;;
1 | quit) echo "quit!" && exit 0 ;;
*) error_msg "Invalid input!" ;;
esac
}

# Execute according to the classification of input parameters
case "${1}" in
-u | u | -update | update)
do_update_conf
;;
[0-9]*)
do_select_box "${1}"
;;
*)
clear
cat <<EOF
-u | u | -update | update)
do_update_conf
;;
[0-9]*)
do_select_box "${1}"
;;
*)
clear
cat <<EOF
┌────────[ Enable LED ]─────────┐
│ │
Expand Down Expand Up @@ -185,8 +193,8 @@ case "${1}" in
└───────────────────────────────┘
EOF
echo -ne "${OPTIONS} Please Input ID: "
read boxid
do_select_box "${boxid}"
;;
echo -ne "${OPTIONS} Please Input ID: "
read boxid
do_select_box "${boxid}"
;;
esac
Loading

0 comments on commit 98dd3e5

Please sign in to comment.