516 lines
23 KiB
Bash
516 lines
23 KiB
Bash
#!/usr/bin/env bash
|
|
#
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
#
|
|
# Copyright (c) 2026 AMLOGIC
|
|
#
|
|
# Vendor files build script for AMLbian
|
|
# This script installs vendor configuration files for Amlogic soc_names
|
|
|
|
set -e
|
|
|
|
# Get script directory
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
AMLBIAN_DIR="$(dirname "${SCRIPT_DIR}")"
|
|
AMLBIAN_DIR="$(dirname "${AMLBIAN_DIR}")" # Go up one more level from multimedia/tvserver
|
|
AMLBIAN_DIR="$(dirname "${AMLBIAN_DIR}")" # Go up one more level from scripts
|
|
BUILD_DIR="${AMLBIAN_DIR}/../build"
|
|
|
|
# Source common functions
|
|
if [[ -f "${AMLBIAN_DIR}/lib/function-common.sh" ]]; then
|
|
source "${AMLBIAN_DIR}/lib/function-common.sh"
|
|
fi
|
|
|
|
# ==============================================================================
|
|
# Section 2: Default Configuration
|
|
# ==============================================================================
|
|
|
|
BOARD="${BOARD:-s6-bq201}"
|
|
DEB_VERSION="${VENDOR_FILES_VERSION:-1.0.0}"
|
|
ARCH="${ARCH:-arm64}"
|
|
|
|
# DISTRO_FEATURES from environment
|
|
DISTRO_FEATURES="${DISTRO_FEATURES:-}"
|
|
# MACHINE_EXTRA_RRECOMMENDS from environment
|
|
MACHINE_EXTRA_RRECOMMENDS="${MACHINE_EXTRA_RRECOMMENDS:-}"
|
|
|
|
# ==============================================================================
|
|
# Section 3: soc_name Mapping Functions
|
|
# ==============================================================================
|
|
|
|
# Check if DISTRO_FEATURES contains a specific feature
|
|
function __distro_feature_contains() {
|
|
local feature="$1"
|
|
is_feature_contains "${DISTRO_FEATURES}" "${feature}"
|
|
return $?
|
|
}
|
|
|
|
# Check if MACHINE_EXTRA_RRECOMMENDS contains a specific item
|
|
function __machine_extra_rrecommends_contains() {
|
|
local item="$1"
|
|
is_feature_contains "${MACHINE_EXTRA_RRECOMMENDS}" "${item}"
|
|
return $?
|
|
}
|
|
|
|
# ==============================================================================
|
|
# Section 4: Vendor Files Build Functions
|
|
# ==============================================================================
|
|
|
|
function __vendor_files_prepare_source {
|
|
local build_dir="${1}"
|
|
|
|
local aml_comp_path="$(amlbian_get_aml_comp_dir)"
|
|
if [[ -z "${aml_comp_path}" ]] || [[ ! -d "${aml_comp_path}" ]]; then
|
|
display_alert "VENDOR-FILES" "aml-comp not found: ${aml_comp_path}" "err"
|
|
exit 1
|
|
fi
|
|
|
|
local source_dir="${aml_comp_path}/prebuilt/vendor"
|
|
|
|
if [[ ! -d "${source_dir}" ]]; then
|
|
display_alert "VENDOR-FILES" "Source directory not found: ${source_dir}" "err"
|
|
exit 1
|
|
fi
|
|
|
|
display_alert "VENDOR-FILES" "Copying source from ${source_dir} to ${build_dir}" "info"
|
|
|
|
# 清空构建目录
|
|
rm -rf "${build_dir}"
|
|
mkdir -p "${build_dir}"
|
|
|
|
# 复制源代码到构建目录
|
|
cp -r "${source_dir}"/* "${build_dir}/" 2>/dev/null || true
|
|
|
|
display_alert "VENDOR-FILES" "Source prepared successfully" "success"
|
|
}
|
|
|
|
function __vendor_files_install {
|
|
local build_dir="${1}"
|
|
local install_dir="${2}"
|
|
|
|
display_alert "VENDOR-FILES" "Installing vendor configuration files..." "info"
|
|
|
|
# 获取soc_name
|
|
local soc_name="${CHIPSET_NAME,,}"
|
|
display_alert "VENDOR-FILES" "Using soc_name: ${soc_name} for board: ${BOARD}" "info"
|
|
|
|
# 创建基本目录结构
|
|
mkdir -p "${install_dir}/vendor/etc"
|
|
mkdir -p "${install_dir}/vendor/etc/halaudio"
|
|
mkdir -p "${install_dir}/vendor/etc/tvconfig/pq"
|
|
mkdir -p "${install_dir}/vendor/firmware"
|
|
mkdir -p "${install_dir}/vendor/firmware/wireless"
|
|
mkdir -p "${install_dir}/lib/firmware"
|
|
|
|
local source_tvconfig="${build_dir}/etc/tvconfig"
|
|
|
|
# 检查soc_name目录是否存在
|
|
if [[ -d "${source_tvconfig}/${soc_name}" ]]; then
|
|
# audio_effects.xml
|
|
if [[ -e "${source_tvconfig}/${soc_name}/audio_effects.xml" ]]; then
|
|
install -m 0644 -D "${source_tvconfig}/${soc_name}/audio_effects.xml" "${install_dir}/vendor/etc/audio_effects.xml"
|
|
display_alert "VENDOR-FILES" "Installed audio_effects.xml" "debug"
|
|
fi
|
|
|
|
# ms12_tuning.dat
|
|
if [[ -e "${source_tvconfig}/${soc_name}/ms12_tuning.dat" ]]; then
|
|
install -m 0644 -D "${source_tvconfig}/${soc_name}/ms12_tuning.dat" "${install_dir}/vendor/etc/ms12_tuning.dat"
|
|
display_alert "VENDOR-FILES" "Installed ms12_tuning.dat" "debug"
|
|
fi
|
|
|
|
# ms12_tuning_v28.dat
|
|
if [[ -e "${source_tvconfig}/${soc_name}/ms12_tuning_v28.dat" ]]; then
|
|
install -m 0644 -D "${source_tvconfig}/${soc_name}/ms12_tuning_v28.dat" "${install_dir}/vendor/etc/ms12_tuning_v28.dat"
|
|
display_alert "VENDOR-FILES" "Installed ms12_tuning_v28.dat" "debug"
|
|
fi
|
|
|
|
# aml_audio_config.json
|
|
if [[ -e "${source_tvconfig}/${soc_name}/aml_audio_config.json" ]]; then
|
|
if __distro_feature_contains "disable-audio-server"; then
|
|
if [[ -e "${source_tvconfig}/${soc_name}/aml_audio_config.zapper.json" ]]; then
|
|
install -m 0644 -D "${source_tvconfig}/${soc_name}/aml_audio_config.zapper.json" "${install_dir}/vendor/etc/halaudio/aml_audio_config.json"
|
|
display_alert "VENDOR-FILES" "Installed aml_audio_config.zapper.json (disable-audio-server)" "debug"
|
|
else
|
|
install -m 0644 -D "${source_tvconfig}/${soc_name}/aml_audio_config.json" "${install_dir}/vendor/etc/halaudio/aml_audio_config.json"
|
|
display_alert "VENDOR-FILES" "Installed aml_audio_config.json" "debug"
|
|
fi
|
|
else
|
|
install -m 0644 -D "${source_tvconfig}/${soc_name}/aml_audio_config.json" "${install_dir}/vendor/etc/halaudio/aml_audio_config.json"
|
|
display_alert "VENDOR-FILES" "Installed aml_audio_config.json" "debug"
|
|
fi
|
|
else
|
|
if [[ -e "${source_tvconfig}/default_conf/aml_audio_config.json" ]]; then
|
|
install -m 0644 -D "${source_tvconfig}/default_conf/aml_audio_config.json" "${install_dir}/vendor/etc/halaudio/aml_audio_config.json"
|
|
display_alert "VENDOR-FILES" "Installed default aml_audio_config.json" "debug"
|
|
fi
|
|
fi
|
|
|
|
# 低内存配置调整
|
|
if __distro_feature_contains "low-memory"; then
|
|
if [[ -e "${install_dir}/vendor/etc/halaudio/aml_audio_config.json" ]]; then
|
|
sed -i '/Codec_Support_List/i \\t"Audio_Delay_Max":100,' "${install_dir}/vendor/etc/halaudio/aml_audio_config.json"
|
|
display_alert "VENDOR-FILES" "Applied low-memory configuration to aml_audio_config.json" "debug"
|
|
fi
|
|
fi
|
|
|
|
# mixer_paths.xml
|
|
if [[ -e "${source_tvconfig}/${soc_name}/mixer_paths.xml" ]]; then
|
|
install -m 0644 -D "${source_tvconfig}/${soc_name}/mixer_paths.xml" "${install_dir}/vendor/etc/mixer_paths.xml"
|
|
display_alert "VENDOR-FILES" "Installed mixer_paths.xml" "debug"
|
|
else
|
|
if [[ -e "${source_tvconfig}/default_conf/mixer_paths.xml" ]]; then
|
|
install -m 0644 -D "${source_tvconfig}/default_conf/mixer_paths.xml" "${install_dir}/vendor/etc/mixer_paths.xml"
|
|
display_alert "VENDOR-FILES" "Installed default mixer_paths.xml" "debug"
|
|
fi
|
|
fi
|
|
|
|
# audio_hal_delay_base.json
|
|
if [[ -e "${source_tvconfig}/${soc_name}/audio_hal_delay_base.json" ]]; then
|
|
install -m 0644 -D "${source_tvconfig}/${soc_name}/audio_hal_delay_base.json" "${install_dir}/vendor/etc/halaudio/audio_hal_delay_base.json"
|
|
display_alert "VENDOR-FILES" "Installed audio_hal_delay_base.json" "debug"
|
|
else
|
|
if [[ -e "${source_tvconfig}/default_conf/audio_hal_delay_base.json" ]]; then
|
|
install -m 0644 -D "${source_tvconfig}/default_conf/audio_hal_delay_base.json" "${install_dir}/vendor/etc/halaudio/audio_hal_delay_base.json"
|
|
display_alert "VENDOR-FILES" "Installed default audio_hal_delay_base.json" "debug"
|
|
fi
|
|
fi
|
|
|
|
# ms12_audio_profiles.ini
|
|
if [[ -e "${source_tvconfig}/default_conf/ms12_audio_profiles.ini" ]]; then
|
|
install -m 0644 -D "${source_tvconfig}/default_conf/ms12_audio_profiles.ini" "${install_dir}/vendor/etc/halaudio/ms12_audio_profiles.ini"
|
|
display_alert "VENDOR-FILES" "Installed ms12_audio_profiles.ini" "debug"
|
|
fi
|
|
|
|
# aml_audio_default_ui.ini
|
|
if [[ -e "${source_tvconfig}/default_conf/aml_audio_default_ui.ini" ]]; then
|
|
install -m 0644 -D "${source_tvconfig}/default_conf/aml_audio_default_ui.ini" "${install_dir}/vendor/etc/halaudio/aml_audio_default_ui.ini"
|
|
display_alert "VENDOR-FILES" "Installed aml_audio_default_ui.ini" "debug"
|
|
fi
|
|
|
|
# PQ配置文件
|
|
if [[ -e "${source_tvconfig}/${soc_name}/PQ" ]]; then
|
|
display_alert "VENDOR-FILES" "Installing PQ configuration files" "info"
|
|
|
|
# pq_default.ini
|
|
if [[ -e "${source_tvconfig}/${soc_name}/PQ/pq_default.ini" ]]; then
|
|
install -m 0644 -D "${source_tvconfig}/${soc_name}/PQ/pq_default.ini" "${install_dir}/vendor/etc/tvconfig/pq/pq_default.ini"
|
|
display_alert "VENDOR-FILES" "Installed pq_default.ini" "debug"
|
|
fi
|
|
|
|
# pq.db处理
|
|
if [[ -e "${source_tvconfig}/${soc_name}/PQ/pq.db" ]]; then
|
|
if __distro_feature_contains "pq-compress-db"; then
|
|
# 压缩pq.db
|
|
(cd "${source_tvconfig}/${soc_name}/PQ" && \
|
|
/usr/bin/zip "${install_dir}/vendor/etc/tvconfig/pq/pq.db.zip" pq.db && \
|
|
md5sum pq.db > "${install_dir}/vendor/etc/tvconfig/pq/pq.db.md5")
|
|
display_alert "VENDOR-FILES" "Compressed pq.db to pq.db.zip" "debug"
|
|
|
|
# 更新pq_default.ini中的路径
|
|
if [[ -e "${install_dir}/vendor/etc/tvconfig/pq/pq_default.ini" ]]; then
|
|
sed -i '/pq_db_config_path/d' "${install_dir}/vendor/etc/tvconfig/pq/pq_default.ini"
|
|
sed -i "/^\[PQ\]/a pq_db_config_path = ${PQ_DB_EXTRACT_DEST:-/vendor/etc/tvconfig/pq}" \
|
|
"${install_dir}/vendor/etc/tvconfig/pq/pq_default.ini"
|
|
fi
|
|
else
|
|
# 直接复制
|
|
install -m 0644 -D "${source_tvconfig}/${soc_name}/PQ/pq.db" "${install_dir}/vendor/etc/tvconfig/pq/pq.db"
|
|
display_alert "VENDOR-FILES" "Installed pq.db" "debug"
|
|
|
|
if [[ -e "${source_tvconfig}/${soc_name}/PQ/UI_PQSetting.bin" ]]; then
|
|
install -m 0644 -D "${source_tvconfig}/${soc_name}/PQ/UI_PQSetting.bin" "${install_dir}/vendor/etc/tvconfig/pq/UI_PQSetting.bin"
|
|
display_alert "VENDOR-FILES" "Installed UI_PQSetting.bin" "debug"
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
# overscan.db
|
|
if [[ -e "${source_tvconfig}/${soc_name}/PQ/overscan.db" ]]; then
|
|
install -m 0644 -D "${source_tvconfig}/${soc_name}/PQ/overscan.db" "${install_dir}/vendor/etc/tvconfig/pq/overscan.db"
|
|
display_alert "VENDOR-FILES" "Installed overscan.db" "debug"
|
|
fi
|
|
|
|
# 更新vendor分区路径
|
|
if ! __distro_feature_contains "vendor-partition"; then
|
|
if [[ -e "${install_dir}/vendor/etc/tvconfig/pq/pq_default.ini" ]]; then
|
|
sed -i 's|/vendor/etc/tvconfig/pq|/etc/tvconfig/pq|g' "${install_dir}/vendor/etc/tvconfig/pq/pq_default.ini"
|
|
display_alert "VENDOR-FILES" "Updated vendor partition paths in pq_default.ini" "debug"
|
|
fi
|
|
fi
|
|
|
|
# 添加用户数据和工厂数据路径
|
|
if [[ -e "${install_dir}/vendor/etc/tvconfig/pq/pq_default.ini" ]]; then
|
|
sed -i '/pq_uiSettingDataFile_path/d; /pq_FactorywhiteBalance_path/d' \
|
|
"${install_dir}/vendor/etc/tvconfig/pq/pq_default.ini"
|
|
sed -i "/^\[PQ\]/a pq_uiSettingDataFile_path = ${PQ_USER_DATA_PATH:-/data/pq_user_data}\npq_FactorywhiteBalance_path = ${PQ_FACTORY_DATA_PATH:-/data/pq_factory_data}" \
|
|
"${install_dir}/vendor/etc/tvconfig/pq/pq_default.ini"
|
|
display_alert "VENDOR-FILES" "Added PQ data paths to pq_default.ini" "debug"
|
|
fi
|
|
fi
|
|
|
|
# tvconfig目录文件
|
|
if [[ -e "${source_tvconfig}/${soc_name}/tvconfig" ]]; then
|
|
display_alert "VENDOR-FILES" "Installing tvconfig files" "info"
|
|
cd "${source_tvconfig}/${soc_name}/tvconfig"
|
|
find . -type f | while read -r file; do
|
|
install -m 0644 -D "${file}" "${install_dir}/vendor/etc/tvconfig/${file}"
|
|
done
|
|
display_alert "VENDOR-FILES" "Installed tvconfig files" "debug"
|
|
fi
|
|
|
|
# Soundbar配置
|
|
if __distro_feature_contains "soundbar"; then
|
|
local soundbar_conf="${source_tvconfig}/${soc_name}/soundbar_conf"
|
|
if [[ -d "${soundbar_conf}" ]]; then
|
|
display_alert "VENDOR-FILES" "Installing soundbar configuration" "info"
|
|
|
|
if [[ -e "${soundbar_conf}/audio_effects.xml" ]]; then
|
|
install -m 0644 -D "${soundbar_conf}/audio_effects.xml" "${install_dir}/vendor/etc/audio_effects.xml"
|
|
display_alert "VENDOR-FILES" "Installed soundbar audio_effects.xml" "debug"
|
|
fi
|
|
|
|
if [[ -e "${soundbar_conf}/mixer_paths.xml" ]]; then
|
|
install -m 0644 -D "${soundbar_conf}/mixer_paths.xml" "${install_dir}/vendor/etc/mixer_paths.xml"
|
|
display_alert "VENDOR-FILES" "Installed soundbar mixer_paths.xml" "debug"
|
|
fi
|
|
|
|
if [[ -e "${soundbar_conf}/aml_audio_config.json" ]]; then
|
|
install -m 0644 -D "${soundbar_conf}/aml_audio_config.json" "${install_dir}/vendor/etc/halaudio/aml_audio_config.json"
|
|
display_alert "VENDOR-FILES" "Installed soundbar aml_audio_config.json" "debug"
|
|
fi
|
|
|
|
if [[ -e "${soundbar_conf}/ms12_tuning_2_0.dat" ]]; then
|
|
install -m 0644 -D "${soundbar_conf}/ms12_tuning_2_0.dat" "${install_dir}/vendor/etc/ms12_tuning.dat"
|
|
display_alert "VENDOR-FILES" "Installed soundbar ms12_tuning_2_0.dat" "debug"
|
|
fi
|
|
|
|
if [[ -e "${soundbar_conf}/ms12_tuning_4_0.dat" ]]; then
|
|
install -m 0644 -D "${soundbar_conf}/ms12_tuning_4_0.dat" "${install_dir}/vendor/etc/ms12_tuning_4_0.dat"
|
|
display_alert "VENDOR-FILES" "Installed soundbar ms12_tuning_4_0.dat" "debug"
|
|
fi
|
|
fi
|
|
fi
|
|
else
|
|
# soc_name目录不存在的情况
|
|
display_alert "VENDOR-FILES" "soc_name directory ${soc_name} not found, creating dummy files" "warn"
|
|
|
|
# 创建虚拟文件
|
|
install -d "${install_dir}/vendor/etc/tvconfig/"
|
|
touch "${install_dir}/vendor/etc/tvconfig/dummy"
|
|
|
|
# 检查是否有直接的soc_name目录
|
|
if [[ -d "${build_dir}/${soc_name}" ]]; then
|
|
install -d "${install_dir}/vendor/p1_pxp"
|
|
cd "${build_dir}/${soc_name}"
|
|
find . -type f | while read -r file; do
|
|
install -m 0644 -D "${file}" "${install_dir}/vendor/p1_pxp/${file}"
|
|
done
|
|
display_alert "VENDOR-FILES" "Installed files to p1_pxp directory" "debug"
|
|
fi
|
|
fi
|
|
|
|
# 安装蓝牙固件
|
|
if __distro_feature_contains "bluetooth"; then
|
|
if [[ -e "${build_dir}/firmware/remote_ota.bin" ]]; then
|
|
install -m 0644 "${build_dir}/firmware/remote_ota.bin" "${install_dir}/vendor/firmware/"
|
|
display_alert "VENDOR-FILES" "Installed remote_ota.bin" "debug"
|
|
fi
|
|
fi
|
|
|
|
# 安装无线固件
|
|
if __machine_extra_rrecommends_contains "aml-bt-w2"; then
|
|
if __distro_feature_contains "amlogic-tv"; then
|
|
if [[ -d "${build_dir}/wireless" ]]; then
|
|
# 安装W2蓝牙固件
|
|
for fw_file in "${build_dir}/wireless/bt_firmware/w2_bt_"*"usb.bin"; do
|
|
if [[ -e "${fw_file}" ]]; then
|
|
install -m 0644 "${fw_file}" "${install_dir}/vendor/firmware/wireless/"
|
|
display_alert "VENDOR-FILES" "Installed W2 BT firmware: $(basename "${fw_file}")" "debug"
|
|
fi
|
|
done
|
|
|
|
# 安装蓝牙配置文件
|
|
if [[ -e "${build_dir}/wireless/aml_bt.conf" ]]; then
|
|
install -m 0644 "${build_dir}/wireless/aml_bt.conf" "${install_dir}/vendor/firmware/wireless/"
|
|
display_alert "VENDOR-FILES" "Installed aml_bt.conf" "debug"
|
|
fi
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
if __machine_extra_rrecommends_contains "aml-bt-w2l"; then
|
|
if __distro_feature_contains "amlogic-tv"; then
|
|
if [[ -d "${build_dir}/wireless" ]]; then
|
|
# 安装W2L蓝牙固件
|
|
for fw_file in "${build_dir}/wireless/bt_firmware/w2l_bt_"*"usb.bin"; do
|
|
if [[ -e "${fw_file}" ]]; then
|
|
install -m 0644 "${fw_file}" "${install_dir}/vendor/firmware/wireless/"
|
|
display_alert "VENDOR-FILES" "Installed W2L BT firmware: $(basename "${fw_file}")" "debug"
|
|
fi
|
|
done
|
|
|
|
# 安装蓝牙配置文件
|
|
if [[ -e "${build_dir}/wireless/aml_bt.conf" ]]; then
|
|
install -m 0644 "${build_dir}/wireless/aml_bt.conf" "${install_dir}/vendor/firmware/wireless/"
|
|
display_alert "VENDOR-FILES" "Installed aml_bt.conf" "debug"
|
|
fi
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
if __distro_feature_contains "audio-sed"; then
|
|
if [[ -e "${build_dir}/firmware/audio/sed.bin" ]]; then
|
|
install -m 0644 "${build_dir}/firmware/audio/sed.bin" "${install_dir}/lib/firmware"
|
|
display_alert "VENDOR-FILES" "Applied audio-sed configuration to lib/firmware" "debug"
|
|
fi
|
|
fi
|
|
|
|
display_alert "VENDOR-FILES" "Installation completed successfully" "success"
|
|
return 0
|
|
}
|
|
|
|
function __vendor_files_create_deb {
|
|
local build_dir="${1}"
|
|
local install_dir="${2}"
|
|
|
|
# 设置必要的变量
|
|
local pkg_name="vendor-files"
|
|
local version="${DEB_VERSION}"
|
|
local architecture="${ARCH}"
|
|
local maintainer="Armbian Build <[email protected]>"
|
|
local description="Vendor configuration files for Amlogic platforms"
|
|
local description_long="This package provides vendor configuration files (audio, video, bluetooth, etc.) for Amlogic platforms."
|
|
|
|
display_alert "VENDOR-FILES" "Creating Debian package for ${pkg_name} ${version}..." "info"
|
|
|
|
# 创建Debian包控制文件
|
|
local deb_dir="${build_dir}/deb/${pkg_name}-${version}"
|
|
local debian_dir="${deb_dir}/DEBIAN"
|
|
|
|
mkdir -p "${debian_dir}"
|
|
|
|
# 将安装目录的内容复制到debian-root
|
|
if [[ -d "${install_dir}" ]] && [[ "$(ls -A "${install_dir}")" ]]; then
|
|
cp -r "${install_dir}"/* "${deb_dir}/" 2>/dev/null || true
|
|
display_alert "VENDOR-FILES" "Copied installed files to ${deb_dir}" "info"
|
|
else
|
|
display_alert "VENDOR-FILES" "No installed files found in ${install_dir}" "warn"
|
|
return 0
|
|
fi
|
|
|
|
# 创建control文件
|
|
cat > "${debian_dir}/control" <<EOF
|
|
Package: ${pkg_name}
|
|
Version: ${version}
|
|
Architecture: ${architecture}
|
|
Maintainer: ${maintainer}
|
|
Description: ${description}
|
|
${description_long}
|
|
Depends: libc6
|
|
Section: misc
|
|
Priority: optional
|
|
EOF
|
|
|
|
# 创建postinst脚本
|
|
cat > "${debian_dir}/postinst" <<EOF
|
|
#!/bin/sh
|
|
set -e
|
|
|
|
if [ "\$1" = "configure" ]; then
|
|
echo "Vendor files installed successfully"
|
|
fi
|
|
|
|
exit 0
|
|
EOF
|
|
|
|
chmod 755 "${debian_dir}/postinst"
|
|
|
|
# 创建prerm脚本
|
|
cat > "${debian_dir}/prerm" <<EOF
|
|
#!/bin/sh
|
|
set -e
|
|
|
|
if [ "\$1" = "remove" ] || [ "\$1" = "deconfigure" ]; then
|
|
echo "Removing vendor files"
|
|
fi
|
|
|
|
exit 0
|
|
EOF
|
|
|
|
chmod 755 "${debian_dir}/prerm"
|
|
|
|
display_alert "VENDOR-FILES" "Building Debian package..." "info"
|
|
|
|
# 构建Debian包
|
|
cd "${build_dir}/deb"
|
|
dpkg-deb --build "${pkg_name}-${version}"
|
|
|
|
local deb_file="${pkg_name}-${version}.deb"
|
|
if [[ -f "${deb_file}" ]]; then
|
|
local output_dir="${BUILD_DIR}/output"
|
|
mkdir -p "${output_dir}"
|
|
mv "${deb_file}" "${output_dir}/linux-${pkg_name}-${BOARD}-amlbian_${version}_${architecture}.deb"
|
|
display_alert "VENDOR-FILES" "Debian package created: ${output_dir}/linux-${pkg_name}-${BOARD}-amlbian_${version}_${architecture}.deb" "success"
|
|
else
|
|
display_alert "VENDOR-FILES" "Failed to build Debian package" "err"
|
|
return 1
|
|
fi
|
|
|
|
return 0
|
|
}
|
|
|
|
function amlbian_build_vendor_files {
|
|
if ! is_unit_enabled "vendor-files"; then
|
|
display_alert "[SKIP] >> vendor-files disable in BUILD_UNITS" "" "info"
|
|
return
|
|
fi
|
|
|
|
if ! is_feature_contains "$DISTRO_FEATURES" "vendor-files"; then
|
|
display_alert "[SKIP] >> vendor-files disable in DISTRO_FEATURES" "" "info"
|
|
return
|
|
fi
|
|
|
|
display_alert "AMLOGIC: Building vendor files ${DEB_VERSION} ${BOARD}" "info"
|
|
|
|
# Define all directory paths (in .tmp directory)
|
|
local build_root="${BUILD_DIR}/.tmp/vendor-files-build-${ARCH:-arm64}"
|
|
local build_dir="${build_root}/build" # Build directory with source code
|
|
local install_dir="${build_root}/install" # Install directory
|
|
|
|
rm -rf "${build_root}"
|
|
|
|
# 创建目录
|
|
mkdir -p "${build_dir}" "${install_dir}"
|
|
|
|
display_alert "AMLOGIC: build_dir ${build_dir}" "info"
|
|
display_alert "AMLOGIC: install_dir ${install_dir}" "info"
|
|
display_alert "AMLOGIC: output_dir ${BUILD_DIR}/output" "info"
|
|
|
|
# 准备源代码
|
|
__vendor_files_prepare_source "${build_dir}"
|
|
|
|
# 安装文件
|
|
if ! __vendor_files_install "${build_dir}" "${install_dir}"; then
|
|
display_alert "AMLOGIC: Vendor files installation failed" "err"
|
|
return 1
|
|
fi
|
|
|
|
display_alert "AMLOGIC: Creating Debian package..." "info"
|
|
__vendor_files_create_deb "${build_dir}" "${install_dir}"
|
|
|
|
return 0
|
|
}
|
|
|
|
# ==============================================================================
|
|
# Section 5: Main
|
|
# ==============================================================================
|
|
|
|
display_alert "AMLIbian Vendor Files Build Script" "Version: ${DEB_VERSION}, Board: ${BOARD}" "info"
|
|
|
|
amlbian_build_vendor_files
|
|
|
|
display_alert "AMLOGIC: Vendor files build completed" "${BUILD_DIR}/output" "info"
|
|
|
|
# ==============================================================================
|
|
# End of build-vendor-files.sh
|
|
# ============================================================================== |