Skip to content

Commit

Permalink
Headers install: write new module, remove old and doubled
Browse files Browse the repository at this point in the history
  • Loading branch information
igorpecovnik committed Nov 29, 2024
1 parent 3769d0f commit 94ff0e0
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 138 deletions.
18 changes: 9 additions & 9 deletions tools/json/config.system.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,21 @@
"id": "SY004",
"description": "Install Linux headers",
"command": [
"Headers_install"
"module_headers install"
],
"status": "Preview",
"author": "@Tearran",
"condition": "! are_headers_installed"
"status": "Stable",
"author": "@igorpecovnik",
"condition": "! module_headers status"
},
{
"id": "SY005",
"description": "Remove Linux headers",
"command": [
"Headers_remove"
"module_headers remove"
],
"status": "Preview",
"author": "@Tearran",
"condition": "are_headers_installed"
"status": "Stable",
"author": "@igorpecovnik",
"condition": "module_headers status"
},
{
"id": "SY006",
Expand All @@ -65,7 +65,7 @@
],
"status": "Preview",
"author": "@igorpecovnik",
"condition": "[[ -f /sbin/armbian-install ]]"
"condition": "[[ -f /sbin/armbian-install || -f /usr/bin/armbian-install ]]"
},
{
"id": "SY007",
Expand Down
23 changes: 0 additions & 23 deletions tools/modules/system/Headers_install.sh

This file was deleted.

27 changes: 0 additions & 27 deletions tools/modules/system/Headers_remove.sh

This file was deleted.

23 changes: 0 additions & 23 deletions tools/modules/system/are_headers_installed.sh

This file was deleted.

12 changes: 10 additions & 2 deletions tools/modules/system/armbian_fw_manipulate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ armbian_fw_manipulate() {
)

# reinstall headers only if they were previously installed
if are_headers_installed; then
local armbian_packages+="linux-headers-${branch}-${LINUXFAMILY}"
if dpkg -l | grep -E "linux-headers" >/dev/null; then
local armbian_packages+=("linux-headers-${branch}-${LINUXFAMILY}")
fi

local packages=""
Expand Down Expand Up @@ -72,5 +72,13 @@ armbian_fw_manipulate() {
*) return ;;
esac
done

# update branch information
BRANCH=$(dpkg -l | grep -E "linux-image" | grep -E "current|legacy|edge" | awk '{print $2}' | cut -d"-" -f3 | head -1)
if grep -q BRANCH /etc/armbian-release; then
[[ -n ${BRANCH} ]] && sed -i "s/BRANCH=.*/BRANCH=$BRANCH/g" /etc/armbian-release
else
[[ -n ${BRANCH} ]] && echo "BRANCH=$BRANCH" >> /etc/armbian-release
fi
}

24 changes: 0 additions & 24 deletions tools/modules/system/get_headers_install.sh

This file was deleted.

55 changes: 55 additions & 0 deletions tools/modules/system/install_headers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
module_options+=(
["module_headers,author"]="@armbian"
["module_headers,feature"]="module_headers"
["module_headers,desc"]="Install headers container"
["module_headers,example"]="install remove status help"
["module_headers,port"]=""
["module_headers,status"]="Active"
["module_headers,arch"]=""
)
#
# Mmodule_headers
#
function module_headers () {
local title="headers"
local condition=$(which "$title" 2>/dev/null)

if [[ -f /etc/armbian-release ]]; then
source /etc/armbian-release
local install_pkg="linux-headers-${BRANCH}-${LINUXFAMILY}"
else
local install_pkg="linux-headers-$(uname -r | sed 's/'-$(dpkg --print-architecture)'//')"
fi

local commands
IFS=' ' read -r -a commands <<< "${module_options["module_headers,example"]}"

case "$1" in
"${commands[0]}")
apt_install_wrapper apt-get -y install ${install_pkg} build-essential git || exit 1
;;
"${commands[1]}")
apt_install_wrapper apt-get -y autopurge ${install_pkg} build-essential || exit 1
rm -rf /usr/src/linux-headers*
;;
"${commands[2]}")
if check_if_installed ${install_pkg}; then
return 0
else
return 1
fi
;;
"${commands[3]}")
echo -e "\nUsage: ${module_options["module_headers,feature"]} <command>"
echo -e "Commands: ${module_options["module_headers,example"]}"
echo "Available commands:"
echo -e "\tinstall\t- Install $title."
echo -e "\tstatus\t- Installation status $title."
echo -e "\tremove\t- Remove $title."
echo
;;
*)
${module_options["module_headers,feature"]} ${commands[3]}
;;
esac
}
30 changes: 0 additions & 30 deletions tools/modules/system/set_header_remove.sh

This file was deleted.

2 changes: 2 additions & 0 deletions tools/modules/system/switch_kernels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ function switch_kernels() {

# we only allow switching kerneles that are in the test pool
[[ -z "${KERNEL_TEST_TARGET}" ]] && KERNEL_TEST_TARGET="legacy,current,edge"
dialog --title "Warning!" --yesno "\nInclude untested kernels on the list?" 7 60
[[ $? -eq 0 ]] && KERNEL_TEST_TARGET="legacy,vendor,current,edge"
local kernel_test_target=$(for x in ${KERNEL_TEST_TARGET//,/ }; do echo "linux-image-$x-${LINUXFAMILY}"; done;)
local installed_kernel_version=$(dpkg -l | grep '^ii' | grep linux-image | awk '{print $2"="$3}')
# just in case current is not installed
Expand Down

0 comments on commit 94ff0e0

Please sign in to comment.