563 lines
19 KiB
Bash
563 lines
19 KiB
Bash
#!/usr/bin/env bash
|
|
#
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
#
|
|
# Copyright (c) 2026 AMLOGIC
|
|
#
|
|
# AML TVServer build script for AMLbian
|
|
# This script builds aml-tvserver for Amlogic SoCs
|
|
# Based on aml-tvserver_dbus.1.0.bb functionality
|
|
|
|
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="${SRC}"
|
|
|
|
# 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}"
|
|
TVSERVER_VERSION="${TVSERVER_VERSION:-1.0.0}"
|
|
: "${ARCH:=arm64}"
|
|
KERNEL_VERSION="${KERNEL_VERSION:-6.12}"
|
|
|
|
# tvserver video output options
|
|
# mvideo, default
|
|
# wayland
|
|
# displayadapter
|
|
TVSERVER_VIDEO_BACKEND="${TVSERVER_VIDEO_BACKEND:-mvideo}"
|
|
|
|
# ==============================================================================
|
|
# Section 4: TVServer Build Functions
|
|
# ==============================================================================
|
|
|
|
function __unset_tvserver_config {
|
|
# Clean up any environment variables set during build
|
|
unset EXTRA_OEMAKE
|
|
unset SYSROOT
|
|
unset CFLAGS
|
|
unset CXXFLAGS
|
|
unset LDFLAGS
|
|
}
|
|
|
|
function __tvserver_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 "TVSERVER" "aml-comp not found: ${aml_comp_path}" "err"
|
|
exit 1
|
|
fi
|
|
|
|
local source_dir="${aml_comp_path}/vendor/amlogic/aml_tvserver"
|
|
|
|
if [[ ! -d "${source_dir}" ]]; then
|
|
display_alert "TVSERVER" "Source directory not found: ${source_dir}" "err"
|
|
exit 1
|
|
fi
|
|
|
|
display_alert "TVSERVER" "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
|
|
|
|
# Check for necessary source files
|
|
if [[ ! -f "${build_dir}/Makefile.dbus" ]] && [[ ! -f "${build_dir}/include/tvapi.h" ]]; then
|
|
display_alert "TVSERVER" "Makefile.dbus or tvapi.h not found in source" "err"
|
|
exit 1
|
|
fi
|
|
|
|
display_alert "TVSERVER" "Source prepared successfully" "success"
|
|
}
|
|
|
|
function __tvserver_build_depend {
|
|
local build_dir="${1}"
|
|
|
|
# Dependencies from aml-tvserver_dbus.1.0.bb
|
|
local dependencies=("systemd" "aml-audio-service" "linux-uapi-headers" "aml-ubootenv" "aml-mediahal-sdk")
|
|
|
|
# Video backend specific dependencies
|
|
if [[ "${TVSERVER_VIDEO_BACKEND}" == "wayland" ]]; then
|
|
dependencies+=("wayland" "wayland-protocols" "wayland-native" "libdrm")
|
|
elif [[ "${TVSERVER_VIDEO_BACKEND}" == "displayadapter" ]]; then
|
|
dependencies+=("libdisplayadapter")
|
|
else
|
|
export CFLAGS="${CFLAGS} -DUSE_AMVIDEO=1"
|
|
fi
|
|
|
|
return 0
|
|
}
|
|
|
|
function __tvserver_build {
|
|
local build_dir="${1}"
|
|
|
|
display_alert "TVSERVER" "Starting tvserver build with VIDEO_BACKEND=${TVSERVER_VIDEO_BACKEND}..." "info"
|
|
|
|
if [[ ! -d "${build_dir}" ]]; then
|
|
display_alert "TVSERVER" "Build directory not found: ${build_dir}" "err"
|
|
return 1
|
|
fi
|
|
|
|
# Set build environment
|
|
: "${ARCH:=arm64}"
|
|
CROSS_COMPILE="${CROSS_COMPILE:-aarch64-linux-gnu-}"
|
|
|
|
export ARCH
|
|
export CROSS_COMPILE="${CROSS_COMPILE}"
|
|
export VIDEO_BACKEND="${TVSERVER_VIDEO_BACKEND}"
|
|
|
|
#amlbian_checkout_toolchain
|
|
|
|
export SYSROOT="${SYSROOT:-${TOOLCHAIN_PATH}/${CROSS_PREFIX}}"
|
|
# Check if ROOTFS_TEMP exists, use it as sysroot, otherwise error
|
|
# local SYSROOT=""
|
|
|
|
if [[ -n "${ROOTFS_TEMP}" ]] && [[ -d "${ROOTFS_TEMP}" ]] && [[ -d "${ROOTFS_TEMP}/usr/lib/aarch64-linux-gnu" ]]; then
|
|
SYSROOT="${ROOTFS_TEMP}"
|
|
display_alert "TVSERVER" "Using ROOTFS_TEMP as sysroot: ${SYSROOT}" "info"
|
|
else
|
|
display_alert "TVSERVER" "ROOTFS_TEMP not found or invalid: ${ROOTFS_TEMP}" "err"
|
|
display_alert "TVSERVER" "ROOTFS_TEMP should be created by create_base_rootfs function" "err"
|
|
return 1
|
|
fi
|
|
|
|
export CFLAGS="--sysroot=${SYSROOT} -fPIC"
|
|
export CFLAGS="${CFLAGS} -Wall -Wno-unknown-pragmas -Wno-format -Wno-format-security"
|
|
export CFLAGS="${CFLAGS} -O3 -fexceptions -fnon-call-exceptions -D_GNU_SOURCE"
|
|
|
|
# 添加源代码包含路径
|
|
export CFLAGS="${CFLAGS} -I${build_dir}/common -I${build_dir}/include"
|
|
export CFLAGS="${CFLAGS} -I${build_dir}/libtv/tvutils -I${build_dir}/libtv/panel"
|
|
|
|
__tvserver_build_depend "${build_dir}"
|
|
|
|
# Use sysroot configuration
|
|
display_alert "TVSERVER" "Using sysroot: ${SYSROOT}" "info"
|
|
|
|
export PKG_CONFIG=/usr/bin/pkg-config
|
|
export PKG_CONFIG_SYSROOT_DIR="${SYSROOT}"
|
|
export PKG_CONFIG_LIBDIR="${SYSROOT}/usr/lib/aarch64-linux-gnu/pkgconfig:${SYSROOT}/usr/share/pkgconfig"
|
|
unset PKG_CONFIG_PATH
|
|
|
|
# Set up flags with sysroot
|
|
export CPPFLAGS="${CPPFLAGS} --sysroot=${SYSROOT}"
|
|
export CFLAGS="${CFLAGS} --sysroot=${SYSROOT} -fPIC"
|
|
export CXXFLAGS="${CXXFLAGS} --sysroot=${SYSROOT} -fPIC"
|
|
export LDFLAGS="${LDFLAGS} --sysroot=${SYSROOT}"
|
|
|
|
local include_flags="-I${ROOTFS_TEMP}/usr/include/aarch64-linux-gnu \
|
|
-I${ROOTFS_TEMP}/usr/include/glib-2.0 \
|
|
-I${ROOTFS_TEMP}/usr/lib/aarch64-linux-gnu/glib-2.0/include"
|
|
|
|
export CPPFLAGS="${CPPFLAGS} ${include_flags}"
|
|
export CFLAGS="${CFLAGS} ${include_flags}"
|
|
export CXXFLAGS="${CXXFLAGS} ${include_flags}"
|
|
|
|
export LDFLAGS="${LDFLAGS} -L${ROOTFS_TEMP}/usr/lib/aarch64-linux-gnu -L${ROOTFS_TEMP}/usr/aarch64-linux-gnu/lib"
|
|
export LDFLAGS="${LDFLAGS} -Wl,-rpath-link,${ROOTFS_TEMP}/usr/lib/aarch64-linux-gnu"
|
|
|
|
cd "${build_dir}"
|
|
|
|
# Create output directory
|
|
#local out_dir="${build_dir}/output"
|
|
local out_dir="${build_dir}"
|
|
mkdir -p "${out_dir}"
|
|
|
|
# Set compiler
|
|
export CC="${CROSS_COMPILE}gcc"
|
|
export CXX="${CROSS_COMPILE}g++"
|
|
export AR="${CROSS_COMPILE}ar"
|
|
|
|
display_alert "TVSERVER" "Building using Makefile.dbus..." "info"
|
|
display_alert "TVSERVER" "CC=${CC}, VIDEO_BACKEND=${VIDEO_BACKEND}" "debug"
|
|
|
|
export REMOVE_AUDIO=1
|
|
|
|
if [[ -f "${build_dir}/Makefile.dbus" ]]; then
|
|
display_alert "TVSERVER" "Fixing Makefile.dbus library linking order..." "info"
|
|
|
|
sed -i \
|
|
-e '/^libtvclient\.so:/,/^libtv\.so:/{
|
|
s/\$(CFLAGS) \$(LDFLAGS) -lsystemd -shared/\$(CFLAGS) -shared/
|
|
s/-o \$(OUT_DIR)\/\$@ \$\^ \$(LDLIBS)/-o $(OUT_DIR)\/$@ $^ $(LDFLAGS) -lsystemd $(LDLIBS)/
|
|
}' \
|
|
-e '/^libtv\.so:/,/^tvservice:/{
|
|
s/\$(CFLAGS) \$(LDFLAGS) -lubootenv -shared -lmediahal_resman/\$(CFLAGS) -shared/
|
|
s/\$(TV_LDFLAGS) -o \$(OUT_DIR)\/\$@ \$\^ \$(LDLIBS)/-o $(OUT_DIR)\/$@ $^ $(LDFLAGS) -lubootenv -lmediahal_resman $(TV_LDFLAGS) $(LDLIBS)/
|
|
}' \
|
|
-e '/^tvservice:/,/^tvtest:/{
|
|
s/\$(CXXFLAGS) \$(CFLAGS) \$(LDFLAGS)/\$(CXXFLAGS) \$(CFLAGS)/
|
|
s/-L\$(LOCAL_PATH) -ltv -lsystemd -o \$(OUT_DIR)\/\$@ \$(filter-out %\.so,\$^) \$(LDLIBS)/-o $(OUT_DIR)\/$@ $(filter-out %.so,$^) $(LDFLAGS) -L$(LOCAL_PATH) -ltv -lsystemd $(LDLIBS)/
|
|
}' \
|
|
-e '/^tvtest:/,/^all:/{
|
|
s/\$(tvcommon_HEADERS) -L\$(LOCAL_PATH) \\/\$(tvcommon_HEADERS) \\/
|
|
s/-ltvclient \$(LDFLAGS) -o \$(OUT_DIR)\/\$@ \$(filter-out %\.so,\$^) \$(LDLIBS)/\$(LDFLAGS) -o $(OUT_DIR)\/$@ $(filter-out %.so,$^) -L$(LOCAL_PATH) -ltvclient $(LDLIBS)/
|
|
}' \
|
|
"${build_dir}/Makefile.dbus"
|
|
|
|
display_alert "TVSERVER" "Makefile.dbus library linking order fixed" "success"
|
|
fi
|
|
|
|
export LDFLAGS="${LDFLAGS} -Wl,--no-as-needed -lstdc++ -lpthread -lz -ldl -lrt"
|
|
|
|
# Add include paths
|
|
export CFLAGS="${CFLAGS} -I${build_dir}/common -I${build_dir}/include \
|
|
-I${build_dir}/libtv/tvutils -I${build_dir}/libtv/panel"
|
|
|
|
# Set make variables
|
|
export OUT_DIR="${out_dir}"
|
|
export STAGING_DIR="${BUILD_DIR}/staging"
|
|
export TARGET_DIR="${build_dir}/install"
|
|
|
|
mkdir -p "${STAGING_DIR}/usr/include"
|
|
mkdir -p "${STAGING_DIR}/usr/lib"
|
|
|
|
# Build
|
|
make -f Makefile.dbus \
|
|
OUT_DIR="${out_dir}" \
|
|
STAGING_DIR="${STAGING_DIR}" \
|
|
TARGET_DIR="${TARGET_DIR}" \
|
|
VIDEO_BACKEND="${VIDEO_BACKEND}" \
|
|
CC="${CC}" \
|
|
CXX="${CXX}" \
|
|
CFLAGS="${CFLAGS}" \
|
|
LDFLAGS="${LDFLAGS}" \
|
|
-j$(nproc) \
|
|
all 2>&1 | tee "${out_dir}/make.log" || {
|
|
display_alert "TVSERVER" "Build failed" "err"
|
|
return 1
|
|
}
|
|
|
|
# Verify the libraries were created
|
|
local build_success=true
|
|
if [[ ! -f "${out_dir}/libtv.so" ]]; then
|
|
display_alert "TVSERVER" "Library libtv.so not created" "err"
|
|
build_success=false
|
|
fi
|
|
|
|
if [[ ! -f "${out_dir}/libtvclient.so" ]]; then
|
|
display_alert "TVSERVER" "Library libtvclient.so not created" "err"
|
|
build_success=false
|
|
fi
|
|
|
|
if [[ ! -f "${out_dir}/tvservice" ]]; then
|
|
display_alert "TVSERVER" "Binary tvservice not created" "err"
|
|
build_success=false
|
|
fi
|
|
|
|
if [[ ! -f "${out_dir}/tvtest" ]]; then
|
|
display_alert "TVSERVER" "Binary tvtest not created" "warn"
|
|
fi
|
|
|
|
if [[ "${build_success}" == "true" ]]; then
|
|
display_alert "TVSERVER" "Build completed successfully" "success"
|
|
display_alert "TVSERVER" "Libraries: ${out_dir}/libtv.so, ${out_dir}/libtvclient.so" "info"
|
|
display_alert "TVSERVER" "Binary: ${out_dir}/tvservice" "info"
|
|
else
|
|
display_alert "TVSERVER" "Build partially failed" "err"
|
|
return 1
|
|
fi
|
|
|
|
return 0
|
|
}
|
|
|
|
function __tvserver_install {
|
|
local build_dir="${1}"
|
|
local install_dir="${2}"
|
|
|
|
display_alert "TVSERVER" "Installing tvserver..." "info"
|
|
|
|
#local out_dir="${build_dir}/output"
|
|
local out_dir="${build_dir}"
|
|
|
|
if [[ ! -d "${out_dir}" ]]; then
|
|
display_alert "TVSERVER" "Output directory not found: ${out_dir}" "err"
|
|
return 1
|
|
fi
|
|
|
|
# Create installation directories
|
|
mkdir -p "${install_dir}/usr/lib"
|
|
mkdir -p "${install_dir}/usr/bin"
|
|
mkdir -p "${install_dir}/usr/include"
|
|
mkdir -p "${install_dir}/etc/dbus-1/system.d"
|
|
mkdir -p "${install_dir}/lib/systemd/system"
|
|
|
|
# Install libraries
|
|
display_alert "TVSERVER" "Installing libraries..." "info"
|
|
|
|
local lib_tv="${out_dir}/libtv.so"
|
|
if [[ -f "${lib_tv}" ]]; then
|
|
install -m 0644 "${lib_tv}" "${install_dir}/usr/lib/"
|
|
display_alert "TVSERVER" "Installed libtv.so to ${install_dir}/usr/lib/" "debug"
|
|
else
|
|
display_alert "TVSERVER" "Library file not found: ${lib_tv}" "warn"
|
|
fi
|
|
|
|
local lib_tvclient="${out_dir}/libtvclient.so"
|
|
if [[ -f "${lib_tvclient}" ]]; then
|
|
install -m 0644 "${lib_tvclient}" "${install_dir}/usr/lib/"
|
|
display_alert "TVSERVER" "Installed libtvclient.so to ${install_dir}/usr/lib/" "debug"
|
|
else
|
|
display_alert "TVSERVER" "Library file not found: ${lib_tvclient}" "warn"
|
|
fi
|
|
|
|
# Install binaries
|
|
display_alert "TVSERVER" "Installing binaries..." "info"
|
|
|
|
local tvservice_bin="${out_dir}/tvservice"
|
|
if [[ -f "${tvservice_bin}" ]]; then
|
|
install -m 0755 "${tvservice_bin}" "${install_dir}/usr/bin/"
|
|
display_alert "TVSERVER" "Installed tvservice to ${install_dir}/usr/bin/" "debug"
|
|
else
|
|
display_alert "TVSERVER" "Binary file not found: ${tvservice_bin}" "warn"
|
|
fi
|
|
|
|
local tvtest_bin="${out_dir}/tvtest"
|
|
if [[ -f "${tvtest_bin}" ]]; then
|
|
install -m 0755 "${tvtest_bin}" "${install_dir}/usr/bin/"
|
|
display_alert "TVSERVER" "Installed tvtest to ${install_dir}/usr/bin/" "debug"
|
|
fi
|
|
|
|
# Install headers
|
|
display_alert "TVSERVER" "Installing headers..." "info"
|
|
for header_file in "${build_dir}/include"/*.h; do
|
|
if [[ -f "${header_file}" ]]; then
|
|
install -m 0644 -D "${header_file}" "${install_dir}/usr/include/"
|
|
display_alert "TVSERVER" "Installed $(basename "${header_file}") to ${install_dir}/usr/include/" "debug"
|
|
fi
|
|
done
|
|
|
|
# Install dbus configuration
|
|
local dbus_conf="${build_dir}/dbus/amlogic.yocto.tvserver.conf"
|
|
if [[ -f "${dbus_conf}" ]]; then
|
|
install -m 0644 -D "${dbus_conf}" "${install_dir}/etc/dbus-1/system.d/"
|
|
display_alert "TVSERVER" "Installed dbus config to ${install_dir}/etc/dbus-1/system.d/" "debug"
|
|
else
|
|
display_alert "TVSERVER" "DBus config file not found: ${dbus_conf}" "warn"
|
|
fi
|
|
|
|
# Install systemd service
|
|
local service_file="${SCRIPT_DIR}/files/tvserver.service"
|
|
if [[ -f "${service_file}" ]]; then
|
|
install -m 0644 -D "${service_file}" "${install_dir}/lib/systemd/system/tvserver.service"
|
|
display_alert "TVSERVER" "Installed systemd service to ${install_dir}/lib/systemd/system/tvserver.service" "debug"
|
|
|
|
# Create service.d directory and debug config
|
|
mkdir -p "${install_dir}/etc/systemd/system/tvserver.service.d"
|
|
|
|
# Determine log level based on BUILD_TYPE
|
|
local tv_log_level="5" # default debug
|
|
if [[ "${BUILD_TYPE:-user}" == "user" ]]; then
|
|
tv_log_level="0"
|
|
fi
|
|
|
|
cat > "${install_dir}/etc/systemd/system/tvserver.service.d/tvserver-debug.conf" << EOF
|
|
[Service]
|
|
Environment="TV_LOG_LEVEL=${tv_log_level}"
|
|
EOF
|
|
|
|
# Check for non-root feature
|
|
if [[ "${NON_ROOT:-false}" == "true" ]]; then
|
|
cat > "${install_dir}/etc/systemd/system/tvserver.service.d/non-root.conf" << EOF
|
|
[Service]
|
|
User=system
|
|
AmbientCapabilities=CAP_DAC_OVERRIDE
|
|
CapabilityBoundingSet=CAP_DAC_OVERRIDE
|
|
EOF
|
|
fi
|
|
else
|
|
display_alert "TVSERVER" "Systemd service file not found: ${service_file}" "warn"
|
|
fi
|
|
|
|
display_alert "TVSERVER" "Installation completed successfully" "success"
|
|
return 0
|
|
}
|
|
|
|
function __tvserver_create_deb {
|
|
local build_dir="${1}"
|
|
local install_dir="${2}"
|
|
|
|
# Package details
|
|
local pkg_name="aml-tvserver"
|
|
local version="${TVSERVER_VERSION}"
|
|
local architecture="${ARCH:-arm64}"
|
|
local maintainer="Amlbian Builder <[email protected]>"
|
|
local description="Amlogic TV Server"
|
|
local description_long="This package provides the Amlogic TV Server for multimedia applications."
|
|
|
|
display_alert "TVSERVER" "Creating Debian package for ${pkg_name} ${version}..." "info"
|
|
|
|
# Create Debian package directory structure
|
|
local deb_dir="${build_dir}/deb/${pkg_name}-${version}"
|
|
local debian_dir="${deb_dir}/DEBIAN"
|
|
|
|
mkdir -p "${debian_dir}"
|
|
|
|
# Copy installed files to package directory
|
|
if [[ -d "${install_dir}" ]] && [[ "$(ls -A "${install_dir}")" ]]; then
|
|
cp -r "${install_dir}"/* "${deb_dir}/" 2>/dev/null || true
|
|
display_alert "TVSERVER" "Copied installed files to ${deb_dir}" "info"
|
|
else
|
|
display_alert "TVSERVER" "No installed files found in ${install_dir}" "warning"
|
|
return 0
|
|
fi
|
|
|
|
# Create control file
|
|
cat > "${debian_dir}/control" <<EOF
|
|
Package: ${pkg_name}
|
|
Version: ${version}
|
|
Architecture: ${architecture}
|
|
Maintainer: ${maintainer}
|
|
Description: ${description}
|
|
${description_long}
|
|
Depends: libc6, liblog, systemd, aml-ubootenv, aml-mediahal-sdk
|
|
Section: libs
|
|
Priority: optional
|
|
EOF
|
|
|
|
# Create postinst script for ldconfig and systemd
|
|
cat > "${debian_dir}/postinst" << 'POSTINST_EOF'
|
|
#!/bin/sh
|
|
set -e
|
|
|
|
if [ "$1" = "configure" ]; then
|
|
# Update ldconfig cache
|
|
if command -v ldconfig >/dev/null 2>&1; then
|
|
ldconfig
|
|
fi
|
|
|
|
# Reload systemd and enable service
|
|
if command -v systemctl >/dev/null 2>&1; then
|
|
systemctl daemon-reload
|
|
systemctl enable tvserver.service 2>/dev/null || true
|
|
fi
|
|
fi
|
|
|
|
exit 0
|
|
POSTINST_EOF
|
|
|
|
chmod 755 "${debian_dir}/postinst"
|
|
|
|
# Create prerm script
|
|
cat > "${debian_dir}/prerm" << 'PRERM_EOF'
|
|
#!/bin/sh
|
|
set -e
|
|
|
|
if [ "$1" = "remove" ] || [ "$1" = "deconfigure" ]; then
|
|
# Disable service before removal
|
|
if command -v systemctl >/dev/null 2>&1; then
|
|
systemctl stop tvserver.service 2>/dev/null || true
|
|
systemctl disable tvserver.service 2>/dev/null || true
|
|
fi
|
|
|
|
# Update ldconfig
|
|
if command -v ldconfig >/dev/null 2>&1; then
|
|
ldconfig
|
|
fi
|
|
fi
|
|
|
|
exit 0
|
|
PRERM_EOF
|
|
|
|
chmod 755 "${debian_dir}/prerm"
|
|
|
|
display_alert "TVSERVER" "Building Debian package..." "info"
|
|
|
|
# Build Debian package
|
|
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"
|
|
chmod 755 "${output_dir}/linux-${pkg_name}-${BOARD}-amlbian_${version}_${architecture}.deb"
|
|
display_alert "TVSERVER" "Debian package created: ${output_dir}/linux-${pkg_name}-${BOARD}-amlbian_${version}_${architecture}.deb" "success"
|
|
else
|
|
display_alert "TVSERVER" "Failed to build Debian package" "err"
|
|
return 1
|
|
fi
|
|
|
|
return 0
|
|
}
|
|
|
|
function amlbian_build_tvserver {
|
|
if ! is_unit_enabled "tvserver"; then
|
|
display_alert "[SKIP] >> tvserver disable in BUILD_UNITS" "" "info"
|
|
return
|
|
fi
|
|
|
|
if ! is_feature_contains "$DISTRO_FEATURES" "tvserver"; then
|
|
display_alert "[SKIP] >> tvserver disable in DISTRO_FEATURES" "" "info"
|
|
return
|
|
fi
|
|
|
|
display_alert "AMLOGIC: Building tvserver ${TVSERVER_VERSION} ${BOARD}" "info"
|
|
|
|
# Define all directory paths (in .tmp directory)
|
|
local build_root="${BUILD_DIR}/.tmp/tvserver-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"
|
|
|
|
# 准备源代码
|
|
__tvserver_prepare_source "${build_dir}"
|
|
|
|
# 构建
|
|
if ! __tvserver_build "${build_dir}"; then
|
|
display_alert "AMLOGIC: tvserver build failed" "err"
|
|
return 1
|
|
fi
|
|
|
|
# 安装到安装目录
|
|
if ! __tvserver_install "${build_dir}" "${install_dir}"; then
|
|
display_alert "AMLOGIC: tvserver installation failed" "err"
|
|
return 1
|
|
fi
|
|
|
|
display_alert "AMLOGIC: Creating Debian package..." "info"
|
|
__tvserver_create_deb "${build_dir}" "${install_dir}"
|
|
|
|
__unset_tvserver_config
|
|
|
|
rm -rf "${build_root}"
|
|
|
|
return 0
|
|
}
|
|
|
|
# ==============================================================================
|
|
# Section 5: Main
|
|
# ==============================================================================
|
|
|
|
display_alert "AMLbian TVServer Build Script" "Version: ${TVSERVER_VERSION}, Board: ${BOARD}, Video Backend: ${TVSERVER_VIDEO_BACKEND}" "info"
|
|
|
|
amlbian_build_tvserver
|
|
|
|
display_alert "AMLOGIC: tvserver build completed" "${BUILD_DIR}/output" "info"
|
|
|
|
# ==============================================================================
|
|
# End of build-aml-tvserver.sh
|
|
# ============================================================================== |