|
|
|
@@ -14,11 +14,8 @@ set -e
|
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
|
AMLBIAN_DIR="$(dirname "$(dirname "${SCRIPT_DIR}")")"
|
|
|
|
|
BASE_DIR="$(dirname "$(dirname "${AMLBIAN_DIR}")")"
|
|
|
|
|
MODULE_BUILD_DIR="${SRC}/output/.tmp"
|
|
|
|
|
|
|
|
|
|
# Source common functions
|
|
|
|
|
if [[ -f "${AMLBIAN_DIR}/lib/function-common.sh" ]]; then
|
|
|
|
|
source "${AMLBIAN_DIR}/lib/function-common.sh"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# ==============================================================================
|
|
|
|
|
# Shared Helper Functions
|
|
|
|
@@ -48,16 +45,15 @@ function _modules_load_init_package_info() {
|
|
|
|
|
# Create layered build directory structure
|
|
|
|
|
# Parameters:
|
|
|
|
|
# $1 - base name (e.g. "${PKG_NAME}_${PKG_VERSION}_${PKG_ARCH}")
|
|
|
|
|
# Sets: TMP_DIR, BASE_BUILD_DIR, SOURCE_DIR, BUILD_DIR, INSTALL_DIR, PATCH_DIR,
|
|
|
|
|
# Sets: MODULE_BUILD_DIR, BASE_BUILD_DIR, SOURCE_DIR, BUILD_DIR, INSTALL_DIR, PATCH_DIR,
|
|
|
|
|
# DEB_PACKAGE_DIR, DEBIAN_DIR
|
|
|
|
|
function _modules_load_create_build_dirs() {
|
|
|
|
|
local base_name="$1"
|
|
|
|
|
|
|
|
|
|
TMP_DIR="${AMLBIAN_DIR}/.tmp"
|
|
|
|
|
mkdir -p "${TMP_DIR}"
|
|
|
|
|
mkdir -p "${MODULE_BUILD_DIR}"
|
|
|
|
|
|
|
|
|
|
# 基础构建目录
|
|
|
|
|
BASE_BUILD_DIR="${TMP_DIR}/${base_name}"
|
|
|
|
|
BASE_BUILD_DIR="${MODULE_BUILD_DIR}/${base_name}"
|
|
|
|
|
|
|
|
|
|
rm -rf ${BASE_BUILD_DIR}
|
|
|
|
|
|
|
|
|
@@ -83,6 +79,7 @@ function _modules_load_create_build_dirs() {
|
|
|
|
|
mkdir -p "${INSTALL_DIR}/etc"
|
|
|
|
|
mkdir -p "${INSTALL_DIR}/usr/bin"
|
|
|
|
|
mkdir -p "${INSTALL_DIR}/usr/chinese-fonts"
|
|
|
|
|
mkdir -p "${INSTALL_DIR}/etc/systemd/system"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Display build directory info
|
|
|
|
@@ -90,12 +87,12 @@ function _modules_load_create_build_dirs() {
|
|
|
|
|
# $1 - log prefix
|
|
|
|
|
function _modules_load_display_build_info() {
|
|
|
|
|
local log_prefix="$1"
|
|
|
|
|
display_alert "${log_prefix} Source dir: ${SOURCE_DIR}" "info"
|
|
|
|
|
display_alert "${log_prefix} Build dir: ${BUILD_DIR}" "info"
|
|
|
|
|
display_alert "${log_prefix} Install dir: ${INSTALL_DIR}" "info"
|
|
|
|
|
display_alert "${log_prefix} Patch dir: ${PATCH_DIR}" "info"
|
|
|
|
|
display_alert "${log_prefix} Deb package dir: ${DEB_PACKAGE_DIR}" "info"
|
|
|
|
|
display_alert "${log_prefix} Modules source dir: ${MODULES_SRC_DIR}" "info"
|
|
|
|
|
aml_log debug "${log_prefix} Source dir: ${SOURCE_DIR}"
|
|
|
|
|
aml_log debug "${log_prefix} Build dir: ${BUILD_DIR}"
|
|
|
|
|
aml_log debug "${log_prefix} Install dir: ${INSTALL_DIR}"
|
|
|
|
|
aml_log debug "${log_prefix} Patch dir: ${PATCH_DIR}"
|
|
|
|
|
aml_log debug "${log_prefix} Deb package dir: ${DEB_PACKAGE_DIR}"
|
|
|
|
|
aml_log debug "${log_prefix} Modules source dir: ${MODULES_SRC_DIR}"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
@@ -104,14 +101,14 @@ function _modules_load_display_build_info() {
|
|
|
|
|
|
|
|
|
|
# Validate and copy modules-load.sh
|
|
|
|
|
function _modules_load_copy_modules_load_sh() {
|
|
|
|
|
display_alert "COMPILE-${COMPONENT} Copying modules-load.sh from ${MODULES_SRC_DIR}" "info"
|
|
|
|
|
aml_log info "COMPILE-${COMPONENT} Copying modules-load.sh from ${MODULES_SRC_DIR}"
|
|
|
|
|
|
|
|
|
|
if [[ -f "${MODULES_SRC_DIR}/modules-load.sh" ]]; then
|
|
|
|
|
cp "${MODULES_SRC_DIR}/modules-load.sh" "${INSTALL_DIR}/etc/"
|
|
|
|
|
chmod 0755 "${INSTALL_DIR}/etc/modules-load.sh"
|
|
|
|
|
display_alert "COMPILE-${COMPONENT} Copied modules-load.sh" "info"
|
|
|
|
|
aml_log info "COMPILE-${COMPONENT} Copied modules-load.sh"
|
|
|
|
|
else
|
|
|
|
|
display_alert "COMPILE-${COMPONENT} modules-load.sh not found at ${MODULES_SRC_DIR}/modules-load.sh" "error"
|
|
|
|
|
aml_log error "COMPILE-${COMPONENT} modules-load.sh not found at ${MODULES_SRC_DIR}/modules-load.sh"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
@@ -119,42 +116,62 @@ function _modules_load_copy_modules_load_sh() {
|
|
|
|
|
|
|
|
|
|
# Validate and copy install_chinese_font.sh
|
|
|
|
|
function _modules_load_copy_install_chinese_font_sh() {
|
|
|
|
|
display_alert "COMPILE-${COMPONENT} Copying install_chinese_font.sh from ${MODULES_SRC_DIR}" "info"
|
|
|
|
|
aml_log info "COMPILE-${COMPONENT} Copying install_chinese_font.sh from ${MODULES_SRC_DIR}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [[ -f "${MODULES_SRC_DIR}/install_chinese_font.sh" ]]; then
|
|
|
|
|
cp "${MODULES_SRC_DIR}/install_chinese_font.sh" "${INSTALL_DIR}/usr/chinese-fonts/"
|
|
|
|
|
chmod 0755 "${INSTALL_DIR}/usr/chinese-fonts/install_chinese_font.sh"
|
|
|
|
|
display_alert "COMPILE-${COMPONENT} Copied install_chinese_font.sh" "info"
|
|
|
|
|
aml_log info "COMPILE-${COMPONENT} Copied install_chinese_font.sh"
|
|
|
|
|
else
|
|
|
|
|
display_alert "COMPILE-${COMPONENT} install_chinese_font.sh not found at ${MODULES_SRC_DIR}/install_chinese_font.sh" "error"
|
|
|
|
|
aml_log error "COMPILE-${COMPONENT} install_chinese_font.sh not found at ${MODULES_SRC_DIR}/install_chinese_font.sh"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
# Validate and copy aml_wifi_load.sh
|
|
|
|
|
function _modules_load_copy_aml_wifi_load_sh() {
|
|
|
|
|
display_alert "COMPILE-${COMPONENT} Copying aml_wifi_load.sh from ${MODULES_SRC_DIR}" "info"
|
|
|
|
|
aml_log info "COMPILE-${COMPONENT} Copying aml_wifi_load.sh from ${MODULES_SRC_DIR}"
|
|
|
|
|
|
|
|
|
|
if [[ -f "${MODULES_SRC_DIR}/aml_wifi_load.sh" ]]; then
|
|
|
|
|
cp "${MODULES_SRC_DIR}/aml_wifi_load.sh" "${INSTALL_DIR}/usr/bin/"
|
|
|
|
|
chmod 0755 "${INSTALL_DIR}/usr/bin/aml_wifi_load.sh"
|
|
|
|
|
display_alert "COMPILE-${COMPONENT} Copied aml_wifi_load.sh" "info"
|
|
|
|
|
aml_log info "COMPILE-${COMPONENT} Copied aml_wifi_load.sh"
|
|
|
|
|
else
|
|
|
|
|
display_alert "COMPILE-${COMPONENT} aml_wifi_load.sh not found at ${MODULES_SRC_DIR}/aml_wifi_load.sh" "error"
|
|
|
|
|
aml_log error "COMPILE-${COMPONENT} aml_wifi_load.sh not found at ${MODULES_SRC_DIR}/aml_wifi_load.sh"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Validate and copy set-usb-serial.sh
|
|
|
|
|
function _modules_load_copy_aml_usb_serial_load_sh() {
|
|
|
|
|
display_alert "COMPILE-${COMPONENT} Copying set-usb-serial.sh from ${MODULES_SRC_DIR}" "info"
|
|
|
|
|
aml_log info "COMPILE-${COMPONENT} Copying set-usb-serial.sh from ${MODULES_SRC_DIR}"
|
|
|
|
|
|
|
|
|
|
if [[ -f "${MODULES_SRC_DIR}/set-usb-serial.sh" ]]; then
|
|
|
|
|
cp "${MODULES_SRC_DIR}/set-usb-serial.sh" "${INSTALL_DIR}/usr/bin/"
|
|
|
|
|
chmod 0755 "${INSTALL_DIR}/usr/bin/set-usb-serial.sh"
|
|
|
|
|
display_alert "COMPILE-${COMPONENT} Copied set-usb-serial.sh" "info"
|
|
|
|
|
aml_log info "COMPILE-${COMPONENT} Copied set-usb-serial.sh"
|
|
|
|
|
else
|
|
|
|
|
display_alert "COMPILE-${COMPONENT} set-usb-serial.sh not found at ${MODULES_SRC_DIR}/set-usb-serial.sh" "error"
|
|
|
|
|
aml_log error "COMPILE-${COMPONENT} set-usb-serial.sh not found at ${MODULES_SRC_DIR}/set-usb-serial.sh"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Validate and copy set_rt_conf.sh
|
|
|
|
|
function _modules_load_copy_aml_rt_conf_sh() {
|
|
|
|
|
if [ "$RT_LINUX" != "yes" ]; then
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
mkdir -p "${INSTALL_DIR}/etc/kernel/realtime"
|
|
|
|
|
|
|
|
|
|
aml_log info "COMPILE-${COMPONENT} Copying set_rt_conf.sh from ${MODULES_SRC_DIR}"
|
|
|
|
|
|
|
|
|
|
if [[ -f "${MODULES_SRC_DIR}/set_rt_conf.sh" ]]; then
|
|
|
|
|
cp "${MODULES_SRC_DIR}/set_rt_conf.sh" "${INSTALL_DIR}/usr/bin/"
|
|
|
|
|
chmod 0755 "${INSTALL_DIR}/usr/bin/set_rt_conf.sh"
|
|
|
|
|
cp "${MODULES_SRC_DIR}/set-rt-conf.service" "${INSTALL_DIR}/etc/systemd/system"
|
|
|
|
|
aml_log info "COMPILE-${COMPONENT} Copied set_rt_conf.sh"
|
|
|
|
|
else
|
|
|
|
|
aml_log error "COMPILE-${COMPONENT} set_rt_conf.sh not found at ${MODULES_SRC_DIR}/set_rt_conf.sh"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
@@ -165,7 +182,7 @@ function _modules_load_copy_aml_usb_serial_load_sh() {
|
|
|
|
|
|
|
|
|
|
# Create Debian control file
|
|
|
|
|
function _modules_load_create_control_file() {
|
|
|
|
|
display_alert "COMPILE-${COMPONENT} Creating control file DEBIAN/control" "info"
|
|
|
|
|
aml_log info "COMPILE-${COMPONENT} Creating control file DEBIAN/control"
|
|
|
|
|
cat > "${DEBIAN_DIR}/control" <<EOF
|
|
|
|
|
Package: ${PKG_NAME}
|
|
|
|
|
Version: ${PKG_VERSION}
|
|
|
|
@@ -186,7 +203,7 @@ EOF
|
|
|
|
|
|
|
|
|
|
# Create post-installation script
|
|
|
|
|
function _modules_load_create_postinst() {
|
|
|
|
|
display_alert "COMPILE-${COMPONENT} Creating post-installation script DEBIAN/postinst" "info"
|
|
|
|
|
aml_log info "COMPILE-${COMPONENT} Creating post-installation script DEBIAN/postinst"
|
|
|
|
|
cat > "${DEBIAN_DIR}/postinst" << EOF
|
|
|
|
|
#!/bin/sh
|
|
|
|
|
set -e
|
|
|
|
@@ -204,16 +221,29 @@ if [ "\$1" = "configure" ]; then
|
|
|
|
|
echo "Modules load scripts installed successfully"
|
|
|
|
|
echo "Main script: /etc/modules-load.sh"
|
|
|
|
|
echo "WiFi loader: /usr/bin/aml_wifi_load.sh"
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
if [ "${RT_LINUX}" = "yes" ]; then
|
|
|
|
|
cat >> "${DEBIAN_DIR}/postinst" <<'EOF'
|
|
|
|
|
|
|
|
|
|
systemctl daemon-reload
|
|
|
|
|
systemctl enable set-rt-conf.service
|
|
|
|
|
EOF
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
cat >> "${DEBIAN_DIR}/postinst" <<'EOF'
|
|
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
chmod 755 "${DEBIAN_DIR}/postinst"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Create pre-removal script
|
|
|
|
|
function _modules_load_create_prerm() {
|
|
|
|
|
display_alert "COMPILE-${COMPONENT} Creating pre-removal script DEBIAN/prerm" "info"
|
|
|
|
|
aml_log info "COMPILE-${COMPONENT} Creating pre-removal script DEBIAN/prerm"
|
|
|
|
|
cat > "${DEBIAN_DIR}/prerm" << EOF
|
|
|
|
|
#!/bin/sh
|
|
|
|
|
set -e
|
|
|
|
@@ -246,11 +276,11 @@ function _modules_load_build_deb_package() {
|
|
|
|
|
local output_deb_name="$2"
|
|
|
|
|
|
|
|
|
|
# 将install目录内容拷贝到deb目录
|
|
|
|
|
display_alert "${log_prefix} Copying install directory to deb package directory" "info"
|
|
|
|
|
aml_log info "${log_prefix} Copying install directory to deb package directory"
|
|
|
|
|
cp -r "${INSTALL_DIR}/"* "${DEB_PACKAGE_DIR}/"
|
|
|
|
|
|
|
|
|
|
# 基于deb目录打包
|
|
|
|
|
display_alert "${log_prefix} Building Debian package from deb directory" "info"
|
|
|
|
|
aml_log info "${log_prefix} Building Debian package from deb directory"
|
|
|
|
|
dpkg-deb --build "${DEB_PACKAGE_DIR}"
|
|
|
|
|
|
|
|
|
|
# Move to output directory
|
|
|
|
@@ -258,8 +288,8 @@ function _modules_load_build_deb_package() {
|
|
|
|
|
mkdir -p "$(dirname "${OUTPUT_DEB}")"
|
|
|
|
|
mv "${DEB_PACKAGE_DIR}.deb" "${OUTPUT_DEB}"
|
|
|
|
|
|
|
|
|
|
display_alert "${log_prefix} Package built successfully ${output_deb_name}" "info"
|
|
|
|
|
display_alert "${log_prefix} Build directory preserved ${BASE_BUILD_DIR}" "info"
|
|
|
|
|
aml_log info "${log_prefix} Package built successfully ${output_deb_name}"
|
|
|
|
|
aml_log info "${log_prefix} Build directory preserved ${BASE_BUILD_DIR}"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
@@ -268,9 +298,9 @@ function _modules_load_build_deb_package() {
|
|
|
|
|
|
|
|
|
|
# Display installation information
|
|
|
|
|
function _modules_load_display_install_info() {
|
|
|
|
|
display_alert "COMPILE-${COMPONENT} Modules load scripts will be installed to:" "info"
|
|
|
|
|
display_alert "COMPILE-${COMPONENT} - /etc/modules-load.sh" "info"
|
|
|
|
|
display_alert "COMPILE-${COMPONENT} - /usr/bin/aml_wifi_load.sh" "info"
|
|
|
|
|
aml_log debug "COMPILE-${COMPONENT} Modules load scripts will be installed to:"
|
|
|
|
|
aml_log debug "COMPILE-${COMPONENT} - /etc/modules-load.sh"
|
|
|
|
|
aml_log debug "COMPILE-${COMPONENT} - /usr/bin/aml_wifi_load.sh"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# ==============================================================================
|
|
|
|
@@ -288,7 +318,7 @@ function amlbian_build_modules_load() {
|
|
|
|
|
# ---- Step 1: Package Information ----
|
|
|
|
|
_modules_load_init_package_info
|
|
|
|
|
|
|
|
|
|
display_alert "COMPILE-${COMPONENT} Building modules load scripts package version ${PKG_VERSION}" "info"
|
|
|
|
|
aml_log info "COMPILE-${COMPONENT} Building modules load scripts package version ${PKG_VERSION}"
|
|
|
|
|
|
|
|
|
|
# ---- Step 2: Build Directory Setup ----
|
|
|
|
|
_modules_load_create_build_dirs "${PKG_NAME}_${PKG_VERSION}_${PKG_ARCH}"
|
|
|
|
@@ -299,6 +329,7 @@ function amlbian_build_modules_load() {
|
|
|
|
|
_modules_load_copy_aml_wifi_load_sh
|
|
|
|
|
_modules_load_copy_aml_usb_serial_load_sh
|
|
|
|
|
_modules_load_copy_install_chinese_font_sh
|
|
|
|
|
_modules_load_copy_aml_rt_conf_sh
|
|
|
|
|
|
|
|
|
|
# ---- Step 4: Debian Packaging Scripts ----
|
|
|
|
|
_modules_load_create_control_file
|
|
|
|
@@ -319,6 +350,6 @@ function amlbian_build_modules_load() {
|
|
|
|
|
# Main Execution
|
|
|
|
|
# ==============================================================================
|
|
|
|
|
|
|
|
|
|
display_alert "AMLbian Modules Load Build Script" "Starting modules load scripts build" "info"
|
|
|
|
|
aml_log info "AMLbian Modules Load Build Script" "Starting modules load scripts build"
|
|
|
|
|
amlbian_build_modules_load
|
|
|
|
|
display_alert "AMLOGIC: Modules load scripts build completed" "Check output directory for packages" "info"
|
|
|
|
|
aml_log info "AMLOGIC: Modules load scripts build completed" "Check output directory for packages"
|
|
|
|
|