Commit e622a02b33 for freeswitch.com

commit e622a02b33e966bd8d972cf922e94f38474b28ce
Author: s3rj1k <evasive.gyron@gmail.com>
Date:   Mon Mar 17 15:54:01 2025 +0100

    [DOCS] Add guides for building FreeSWITCH build-dependencies

    * [DOCS] Add guides for building FreeSWITCH build-dependencies

    * Add `build-dependencies.sh` script

diff --git a/scripts/packaging/build/README.md b/scripts/packaging/build/README.md
index bc9823b397..36fa648f45 100644
--- a/scripts/packaging/build/README.md
+++ b/scripts/packaging/build/README.md
@@ -1,6 +1,29 @@
 # Building FreeSWITCH packages using `FSDEB`
+## Install build dependencies first
+In order to build FreeSWITCH packages first you need to install build dependencies. There are two ways:
+* [From our FreeSWITCH Debian repository](#install-build-dependencies-from-repo) (using [FSGET](/scripts/packaging) for example) - the simplest way
+* [Manually compile the build dependencies](#manually-compile-build-dependencies)
+
+<a name="install-build-dependencies-from-repo"></a>
+### Configuring FreeSWITCH Debian repo (for dependencies)
+Since we are building a FreeSWITCH release let's configure FreeSWITCH Community Release Debian repo.
+We recommend using [FSGET](/scripts/packaging).
+
+Replace `<PAT or API token>` with your `SignalWire Personal Access Token (PAT)`
+[HOWTO Create a SignalWire Personal Access Token](https://developer.signalwire.com/freeswitch/FreeSWITCH-Explained/Installation/how-to-create-a-personal-access-token/how-to-create-a-personal-access-token)
+```bash
+curl -sSL https://freeswitch.org/fsget | bash -s <PAT or API token>
+```
+Configuring the repo is enough. Dependencies will be installed during the FreeSWITCH building process.
+
+<a name="manually-compile-build-dependencies"></a>
+### Manually compile the build dependencies
+Just follow this [Dependency Building Guide](dependencies/README.md) without the need to set up the FreeSWITCH Debian repo.</br>
+Although we recommend using the FreeSWITCH Debian repo as all the dependencies are already prebuilt for you.
+
+---
 ## Prerequisites
-FreeSWITCH packages can be built when FreeSWITCH is cloned using `git` only.
+FreeSWITCH packages can be built when FreeSWITCH is cloned using `git` only.
 (Methods described here won't work if you download a source tarball and extract it)

 Please make sure you have `git` and `curl` installed:
@@ -17,16 +40,7 @@ cd /usr/src
 git clone https://github.com/signalwire/freeswitch -b v1.10
 ```

-## Configuring FreeSWITCH Debian repo (for dependencies)
-Since we are building a FreeSWITCH release let's configure FreeSWITCH Community Release Debian repo.
-We recommend using [FSGET](/scripts/packaging).
-
-Replace `<PAT or API token>` with your `SignalWire Personal Access Token (PAT)`
-[HOWTO Create a SignalWire Personal Access Token](https://developer.signalwire.com/freeswitch/FreeSWITCH-Explained/Installation/how-to-create-a-personal-access-token/how-to-create-a-personal-access-token)
-```bash
-curl -sSL https://freeswitch.org/fsget | bash -s <PAT or API token>
-```
-
+---
 ## Building packages with `FSDEB`
 ```bash
 curl -sSL https://freeswitch.org/fsdeb | bash -s -- -b 999 -o /usr/src/fsdebs/ -w /usr/src/freeswitch
diff --git a/scripts/packaging/build/dependencies/README.md b/scripts/packaging/build/dependencies/README.md
new file mode 100644
index 0000000000..cbfddd77b2
--- /dev/null
+++ b/scripts/packaging/build/dependencies/README.md
@@ -0,0 +1,61 @@
+# FreeSWITCH Build Dependencies
+
+This directory is organized into subfolders, where each subfolder contains build instructions for a single Debian package. These packages are dependencies required to build FreeSWITCH's Debian packages.
+
+## Recommended order of building:
+
+- [libbroadvoice](libbroadvoice/README.md)
+- [libilbc](libilbc/README.md)
+- [libsilk](libsilk/README.md)
+- [spandsp](spandsp/README.md)
+- [sofia-sip](sofia-sip/README.md)
+- [libks](libks/README.md)
+- [signalwire-c](signalwire-c/README.md)
+- [libv8](libv8/README.md) (only for `AMD64`)
+
+## Build Dependencies Script
+
+A convenient script `build-dependencies.sh` is provided to automate the building of dependencies. This script offers several options to customize the build process.
+
+### Usage
+
+```bash
+./build-dependencies.sh [options] [library_names...]
+```
+
+### Options
+
+- `-h, --help`: Show the help message
+- `-b, --build-number N`: Set build number (default: 42 or env value)
+- `-a, --all`: Build all libraries
+- `-s, --setup`: Set up build environment before building
+- `-o, --output DIR`: Set output directory (default: /var/local/deb)
+- `-p, --prefix DIR`: Set source path prefix (default: /usr/src)
+- `-r, --repo`: Set up local repository after building
+- `-c, --clone`: Clone required repositories before building
+- `-g, --git-https`: Use HTTPS instead of SSH for git cloning
+
+### Examples
+
+Set up environment, clone repositories, and build all dependencies:
+```bash
+./build-dependencies.sh --build-number 123 --setup --all --repo --clone
+```
+
+Complete build with all options (setup environment, build all libraries, create local repo, clone repos with HTTPS):
+```bash
+./build-dependencies.sh --build-number 123 --setup --all --repo --clone --git-https
+```
+
+Build specific libraries with full automation:
+```bash
+./build-dependencies.sh --build-number 123 --setup --repo --clone --git-https libks signalwire-c
+```
+
+### Running in Docker
+
+You can run the build script inside a Docker container for a clean, isolated build environment:
+
+```bash
+docker run -it -v $(pwd):/root/scripts debian:bookworm bash -c "cd /root/scripts && bash"
+```
diff --git a/scripts/packaging/build/dependencies/build-dependencies.sh b/scripts/packaging/build/dependencies/build-dependencies.sh
new file mode 100755
index 0000000000..6e14d3c13d
--- /dev/null
+++ b/scripts/packaging/build/dependencies/build-dependencies.sh
@@ -0,0 +1,465 @@
+#!/bin/bash
+
+## shfmt -w -s -bn -ci -sr -fn scripts/packaging/build/dependencies/build-dependencies.sh
+
+set -e          # Exit immediately if a command exits with a non-zero status
+set -u          # Treat unset variables as an error
+set -o pipefail # Return value of a pipeline is the value of the last (rightmost) command to exit with a non-zero status
+set -x          # Print commands and their arguments as they are executed
+
+# Default values
+BUILD_NUMBER=${BUILD_NUMBER:-42}
+LIBRARIES=()
+BUILD_ALL=false
+SETUP_ENV=false
+OUTPUT_DIR="/var/local/deb"
+SOURCE_PREFIX="/usr/src"
+SETUP_LOCAL_REPO=false
+CLONE_REPOS=false
+GIT_PROTOCOL="ssh"
+
+###################
+# Helper Functions
+###################
+
+# Display script usage information and available options
+function show_usage()
+{
+	echo "Usage: $0 [options] [library_names...]"
+	echo "Options:"
+	echo "  -h, --help            Show this help message"
+	echo "  -b, --build-number N  Set build number (default: 42 or env value)"
+	echo "  -a, --all             Build all libraries"
+	echo "  -s, --setup           Set up build environment before building"
+	echo "  -o, --output DIR      Set output directory (default: /var/local/deb)"
+	echo "  -p, --prefix DIR      Set source path prefix (default: /usr/src)"
+	echo "  -r, --repo            Set up local repository after building"
+	echo "  -c, --clone           Clone required repositories before building"
+	echo "  -g, --git-https       Use HTTPS instead of SSH for git cloning"
+	echo ""
+	echo "Available libraries:"
+	echo "  libbroadvoice"
+	echo "  libilbc"
+	echo "  libsilk"
+	echo "  spandsp"
+	echo "  sofia-sip"
+	echo "  libks"
+	echo "  signalwire-c"
+	echo "  libv8-packaging (or libv8)"
+	echo ""
+}
+
+# Normalize library names, replacing aliases with their canonical names
+function normalize_library_name()
+{
+	local lib_name=$1
+
+	case $lib_name in
+		libv8)
+			echo "libv8-packaging"
+			;;
+		*)
+			echo "$lib_name"
+			;;
+	esac
+}
+
+# Parse command line arguments and set corresponding variables
+function parse_arguments()
+{
+	while [[ $# -gt 0 ]]; do
+		case $1 in
+			-h | --help)
+				show_usage
+				exit 0
+				;;
+			-b | --build-number)
+				BUILD_NUMBER="$2"
+				shift 2
+				;;
+			-a | --all)
+				BUILD_ALL=true
+				shift
+				;;
+			-s | --setup)
+				SETUP_ENV=true
+				shift
+				;;
+			-o | --output)
+				OUTPUT_DIR="$2"
+				shift 2
+				;;
+			-p | --prefix)
+				SOURCE_PREFIX="$2"
+				shift 2
+				;;
+			-r | --repo)
+				SETUP_LOCAL_REPO=true
+				shift
+				;;
+			-c | --clone)
+				CLONE_REPOS=true
+				shift
+				;;
+			-g | --git-https)
+				GIT_PROTOCOL="https"
+				shift
+				;;
+			*)
+				local normalized_name=$(normalize_library_name "$1")
+				LIBRARIES+=("$normalized_name")
+				shift
+				;;
+		esac
+	done
+
+	if [ "$(id -u)" != "0" ]; then
+		echo "Non-root user detected. Execution may fail."
+	fi
+}
+
+# Validate the provided arguments and set defaults if needed
+function validate_arguments()
+{
+	if [ ${#LIBRARIES[@]} -eq 0 ] && [ "$BUILD_ALL" == "false" ]; then
+		echo "Error: No libraries specified"
+		show_usage
+		exit 1
+	fi
+
+	if [ "$BUILD_ALL" == "true" ]; then
+		LIBRARIES=("libbroadvoice" "libilbc" "libsilk" "spandsp" "sofia-sip" "libks" "signalwire-c" "libv8-packaging")
+	fi
+}
+
+# Set up the build environment variables and create output directory
+function setup_environment()
+{
+	export DEBIAN_FRONTEND=noninteractive
+	export BUILD_NUMBER=$BUILD_NUMBER
+	export CODENAME=$(lsb_release -sc)
+
+	mkdir -p "$OUTPUT_DIR"
+}
+
+# Install required build tools and dependencies
+function setup_build_environment()
+{
+	export DEBIAN_FRONTEND=noninteractive
+
+	local tmp_dir="${TMPDIR:-/tmp}"
+
+	echo "Setting up build environment..."
+	apt-get update \
+		&& apt-get -y upgrade \
+		&& apt-get -y install \
+			build-essential \
+			cmake \
+			devscripts \
+			lsb-release \
+			docbook-xsl \
+			pkg-config \
+			git
+
+	if ! git config --global --get-all safe.directory | grep -q '\*'; then
+		echo "Setting git safe.directory configuration..."
+		git config --global --add safe.directory '*'
+	fi
+
+	if [[ " ${LIBRARIES[@]} " =~ " libv8-packaging " ]] || [ "$BUILD_ALL" == "true" ]; then
+		echo "libv8 is in the build list, checking for dependencies..."
+
+		if [ ! -d "$SOURCE_PREFIX/libv8-packaging" ] && [ "$CLONE_REPOS" == "true" ]; then
+			echo "Cloning libv8-packaging repository..."
+			clone_repositories "libv8-packaging"
+		fi
+
+		if [ -d "$SOURCE_PREFIX/libv8-packaging" ] && [ -f "$SOURCE_PREFIX/libv8-packaging/build.sh" ]; then
+			echo "Installing dependencies for libv8..."
+			(cd "$SOURCE_PREFIX/libv8-packaging" && ./build.sh --install-deps)
+
+			echo "Setting up Python environment for libv8..."
+			(cd "$SOURCE_PREFIX/libv8-packaging" && ./build.sh --setup-pyenv)
+			touch "${tmp_dir}/libv8_pyenv_setup_complete"
+		else
+			echo "Warning: libv8-packaging directory not found. Clone the repository first to install its dependencies."
+			echo "You can use the --clone flag or run the script with -c libv8-packaging first."
+		fi
+	fi
+}
+
+# Clone a specific library repository using the configured protocol
+clone_repositories()
+{
+	local lib_name=$1
+	local original_dir=$(pwd)
+	local repo_dir="$SOURCE_PREFIX/$lib_name"
+
+	echo "=== Cloning $lib_name ==="
+
+	if [ -d "$repo_dir" ]; then
+		echo "Directory $repo_dir already exists, skipping clone..."
+		return 0
+	fi
+
+	mkdir -p "$SOURCE_PREFIX"
+	cd "$SOURCE_PREFIX"
+
+	if [ "$GIT_PROTOCOL" == "ssh" ]; then
+		FREESWITCH_BASE="git@github.com:freeswitch"
+		SIGNALWIRE_BASE="git@github.com:signalwire"
+	else
+		FREESWITCH_BASE="https://github.com/freeswitch"
+		SIGNALWIRE_BASE="https://github.com/signalwire"
+	fi
+
+	case $lib_name in
+		libbroadvoice)
+			git clone $FREESWITCH_BASE/libbroadvoice.git
+			;;
+		libilbc)
+			git clone $FREESWITCH_BASE/libilbc.git
+			;;
+		libsilk)
+			git clone $FREESWITCH_BASE/libsilk.git
+			;;
+		spandsp)
+			git clone --branch packages $FREESWITCH_BASE/spandsp.git
+			;;
+		sofia-sip)
+			git clone $FREESWITCH_BASE/sofia-sip.git
+			;;
+		libks)
+			git clone $SIGNALWIRE_BASE/libks.git
+			;;
+		signalwire-c)
+			git clone $SIGNALWIRE_BASE/signalwire-c.git
+			;;
+		libv8-packaging)
+			git clone $FREESWITCH_BASE/libv8-packaging.git
+			;;
+		*)
+			echo "Error: Unknown library for cloning '$lib_name'"
+			return 1
+			;;
+	esac
+
+	cd "$original_dir"
+
+	echo "=== Completed cloning $lib_name ==="
+}
+
+# Set up a local Debian repository for built packages
+setup_local_repository()
+{
+	local original_dir=$(pwd)
+	local abs_output_dir=$(readlink -f "$OUTPUT_DIR")
+
+	echo "Setting up local Debian repository in $abs_output_dir..."
+	cd "$abs_output_dir"
+
+	dpkg-scanpackages -m . | tee Packages \
+		&& gzip -f -k Packages \
+		&& printf "deb [trusted=yes] file:$abs_output_dir /\n" | tee /etc/apt/sources.list.d/local.list \
+		&& apt-get update
+
+	cd "$original_dir"
+
+	echo "Local repository setup complete."
+}
+
+# Build a library using the Debian package build system
+build_deb_library()
+{
+	local lib_name=$1
+	local original_dir=$(pwd)
+
+	echo "=== Building $lib_name ==="
+
+	cd "$SOURCE_PREFIX/$lib_name/"
+
+	export VERSION=$(dpkg-parsechangelog --show-field Version | cut -f1 -d'-')
+	export GIT_SHA=$(git rev-parse --short HEAD)
+
+	echo "Version: $VERSION"
+	echo "Git SHA: $GIT_SHA"
+	echo "Build Number: $BUILD_NUMBER"
+
+	apt-get update \
+		&& mk-build-deps \
+			--install \
+			--remove debian/control \
+			--tool "apt-get -y --no-install-recommends" \
+		&& apt-get -y -f install
+
+	dch \
+		--controlmaint \
+		--distribution "${CODENAME}" \
+		--force-bad-version \
+		--force-distribution \
+		--newversion "${VERSION}-${BUILD_NUMBER}-${GIT_SHA}~${CODENAME}" \
+		"Nightly build, ${GIT_SHA}" \
+		&& debuild \
+			--no-tgz-check \
+			--build=binary \
+			--unsigned-source \
+			--unsigned-changes \
+		&& mv -v ../*.{deb,changes} "$OUTPUT_DIR"/.
+
+	cd "$original_dir"
+
+	echo "=== Completed building $lib_name ==="
+}
+
+# Build a library using the CMake build system
+build_cmake_library()
+{
+	local lib_name=$1
+	local deps=$2
+	local original_dir=$(pwd)
+
+	echo "=== Building $lib_name ==="
+
+	cd "$SOURCE_PREFIX/$lib_name/"
+
+	if [ -n "$deps" ]; then
+		echo "Installing dependencies for $lib_name..."
+		apt-get update && apt-get -y install $deps
+	fi
+
+	export GIT_SHA=$(git rev-parse --short HEAD)
+
+	echo "Git SHA: $GIT_SHA"
+	echo "Build Number: $BUILD_NUMBER"
+
+	PACKAGE_RELEASE="${BUILD_NUMBER}.${GIT_SHA}" cmake . \
+		-DCMAKE_BUILD_TYPE=Debug \
+		-DCMAKE_INSTALL_PREFIX="/usr" \
+		&& make package \
+		&& mv -v *.deb "$OUTPUT_DIR"/.
+
+	cd "$original_dir"
+
+	echo "=== Completed building $lib_name ==="
+}
+
+# Build libv8 using its own build script
+build_libv8()
+{
+	local original_dir=$(pwd)
+	local tmp_dir="${TMPDIR:-/tmp}"
+	local pyenv_marker_file="${tmp_dir}/libv8_pyenv_setup_complete"
+
+	echo "=== Building libv8 ==="
+
+	cd "$SOURCE_PREFIX/libv8-packaging/"
+
+	echo "Building libv8 with build number $BUILD_NUMBER, output to $OUTPUT_DIR..."
+	./build.sh --build-number "$BUILD_NUMBER" --output-dir "$OUTPUT_DIR"
+
+	cd "$original_dir"
+
+	echo "=== Completed building libv8-packaging ==="
+}
+
+# Process dependencies and ensure they're built in the correct order
+function process_dependencies()
+{
+	local NEEDS_LOCAL_REPO=false
+
+	if [[ " ${LIBRARIES[@]} " =~ " signalwire-c " ]]; then
+		NEEDS_LOCAL_REPO=true
+
+		if ! [[ " ${LIBRARIES[@]} " =~ " libks " ]]; then
+			echo "Adding libks as a dependency for signalwire-c"
+			LIBRARIES=("libks" "${LIBRARIES[@]}")
+		fi
+	fi
+
+	echo $NEEDS_LOCAL_REPO
+}
+
+# Clone all the repositories for the specified libraries
+function clone_all_repos()
+{
+	echo "Cloning repositories using ${GIT_PROTOCOL} protocol..."
+	for lib in "${LIBRARIES[@]}"; do
+		clone_repositories "$lib"
+	done
+}
+
+# Build all the specified libraries in the correct order
+function build_all_libraries()
+{
+	local NEEDS_LOCAL_REPO=$(process_dependencies)
+
+	for lib in "${LIBRARIES[@]}"; do
+		case $lib in
+			libbroadvoice | libilbc | libsilk | spandsp | sofia-sip)
+				build_deb_library "$lib"
+				;;
+			libks)
+				build_cmake_library "$lib" "libssl-dev uuid-dev"
+				;;
+			signalwire-c)
+				setup_local_repository
+				build_cmake_library "$lib" "libks2"
+				;;
+			libv8-packaging)
+				build_libv8
+				;;
+			*)
+				echo "Error: Unknown library '$lib'"
+				show_usage
+				exit 1
+				;;
+		esac
+	done
+
+	if [ "$SETUP_LOCAL_REPO" == "true" ] && [ "$NEEDS_LOCAL_REPO" == "false" ]; then
+		setup_local_repository
+		echo "Local Debian repository has been set up at $OUTPUT_DIR."
+	fi
+}
+
+# Print a summary of the build process
+function print_summary()
+{
+	echo "All selected libraries have been built successfully."
+	echo "Output packages are in $OUTPUT_DIR/"
+}
+
+#####################
+# Main Script Logic
+#####################
+
+# Parse command line arguments
+parse_arguments "$@"
+
+# Validate input arguments
+validate_arguments
+
+# Setup the build environment if flag is set
+if [ "$SETUP_ENV" == "true" ]; then
+	setup_build_environment
+else
+	echo "Skipping build environment setup (use -s or --setup to enable)"
+fi
+
+# Set up environment variables
+setup_environment
+
+echo "Using source path prefix: $SOURCE_PREFIX"
+
+# Clone repositories if flag is set
+if [ "$CLONE_REPOS" == "true" ]; then
+	clone_all_repos
+else
+	echo "Skipping repository cloning (use -c or --clone to enable)"
+fi
+
+# Build all libraries
+build_all_libraries
+
+# Print summary
+print_summary
diff --git a/scripts/packaging/build/dependencies/libbroadvoice/README.md b/scripts/packaging/build/dependencies/libbroadvoice/README.md
new file mode 100644
index 0000000000..97b4094e19
--- /dev/null
+++ b/scripts/packaging/build/dependencies/libbroadvoice/README.md
@@ -0,0 +1,117 @@
+# Building `libbroadvoice` Debian Package
+
+This guide explains how to build the `libbroadvoice` Debian package.
+
+## Prerequisites:
+- Git
+- Debian-based system (native or Docker)
+
+## Build Steps
+
+### Clone the repository:
+```bash
+git clone git@github.com:freeswitch/libbroadvoice.git
+```
+
+### (Optionally) Use Docker to build packages for Debian `Bookworm`:
+```bash
+docker run -it -v $(pwd):/usr/src/ debian:bookworm bash -c "cd /usr/src/ && bash"
+```
+
+### Set non-interactive frontend for APT:
+```bash
+export DEBIAN_FRONTEND=noninteractive
+```
+
+### Install required build tools:
+```bash
+apt-get update \
+&& apt-get -y upgrade \
+&& apt-get -y install \
+    build-essential \
+    cmake \
+    devscripts \
+    lsb-release \
+    docbook-xsl \
+    pkg-config
+```
+
+### Set build number (modify as needed):
+```bash
+export BUILD_NUMBER=42
+```
+> Note: The build number (42) used in this guide is arbitrary. You can modify it as needed for your build process.
+
+### Set Debian codename:
+```bash
+export CODENAME=$(lsb_release -sc)
+```
+
+### Configure git safety setting:
+```bash
+git config --global --add safe.directory '*'
+```
+
+### Navigate to the source directory:
+```bash
+cd libbroadvoice/
+```
+-- or --
+```bash
+cd /usr/src/libbroadvoice/
+```
+
+### Extract Debian package version:
+```bash
+export VERSION=$(dpkg-parsechangelog --show-field Version | cut -f1 -d'-')
+```
+
+### Extract git hash:
+```bash
+export GIT_SHA=$(git rev-parse --short HEAD)
+```
+
+### Install build dependencies:
+```bash
+apt-get update \
+&& mk-build-deps \
+    --install \
+    --remove debian/control \
+    --tool "apt-get -y --no-install-recommends" \
+&& apt-get -y -f install
+```
+
+### Update changelog:
+```bash
+dch \
+    --controlmaint \
+    --distribution "${CODENAME}" \
+    --force-bad-version \
+    --force-distribution \
+    --newversion "${VERSION}-${BUILD_NUMBER}-${GIT_SHA}~${CODENAME}" \
+    "Nightly build, ${GIT_SHA}"
+```
+
+### Build binary package:
+```bash
+debuild \
+    --no-tgz-check \
+    --build=binary \
+    --unsigned-source \
+    --unsigned-changes
+```
+
+### Move built packages to the output directory:
+```bash
+mkdir -p OUT \
+&& mv -v ../*.{deb,changes} OUT/.
+```
+-- or --
+```bash
+mkdir -p /usr/src/OUT \
+&& mv -v ../*.{deb,changes} /usr/src/OUT/.
+```
+
+## Output
+
+After a successful build, the Debian packages will be available in the `OUT` directory.
diff --git a/scripts/packaging/build/dependencies/libilbc/README.md b/scripts/packaging/build/dependencies/libilbc/README.md
new file mode 100644
index 0000000000..0b16638d5e
--- /dev/null
+++ b/scripts/packaging/build/dependencies/libilbc/README.md
@@ -0,0 +1,117 @@
+# Building `libilbc` Debian Package
+
+This guide explains how to build the `libilbc` Debian package.
+
+## Prerequisites:
+- Git
+- Debian-based system (native or Docker)
+
+## Build Steps
+
+### Clone the repository:
+```bash
+git clone git@github.com:freeswitch/libilbc.git
+```
+
+### (Optionally) Use Docker to build packages for Debian `Bookworm`:
+```bash
+docker run -it -v $(pwd):/usr/src/ debian:bookworm bash -c "cd /usr/src/ && bash"
+```
+
+### Set non-interactive frontend for APT:
+```bash
+export DEBIAN_FRONTEND=noninteractive
+```
+
+### Install required build tools:
+```bash
+apt-get update \
+&& apt-get -y upgrade \
+&& apt-get -y install \
+    build-essential \
+    cmake \
+    devscripts \
+    lsb-release \
+    docbook-xsl \
+    pkg-config
+```
+
+### Set build number (modify as needed):
+```bash
+export BUILD_NUMBER=42
+```
+> Note: The build number (42) used in this guide is arbitrary. You can modify it as needed for your build process.
+
+### Set Debian codename:
+```bash
+export CODENAME=$(lsb_release -sc)
+```
+
+### Configure git safety setting:
+```bash
+git config --global --add safe.directory '*'
+```
+
+### Navigate to the source directory:
+```bash
+cd libilbc/
+```
+-- or --
+```bash
+cd /usr/src/libilbc/
+```
+
+### Extract Debian package version:
+```bash
+export VERSION=$(dpkg-parsechangelog --show-field Version | cut -f1 -d'-')
+```
+
+### Extract git hash:
+```bash
+export GIT_SHA=$(git rev-parse --short HEAD)
+```
+
+### Install build dependencies:
+```bash
+apt-get update \
+&& mk-build-deps \
+    --install \
+    --remove debian/control \
+    --tool "apt-get -y --no-install-recommends" \
+&& apt-get -y -f install
+```
+
+### Update changelog:
+```bash
+dch \
+    --controlmaint \
+    --distribution "${CODENAME}" \
+    --force-bad-version \
+    --force-distribution \
+    --newversion "${VERSION}-${BUILD_NUMBER}-${GIT_SHA}~${CODENAME}" \
+    "Nightly build, ${GIT_SHA}"
+```
+
+### Build binary package:
+```bash
+debuild \
+    --no-tgz-check \
+    --build=binary \
+    --unsigned-source \
+    --unsigned-changes
+```
+
+### Move built packages to the output directory:
+```bash
+mkdir -p OUT \
+&& mv -v ../*.{deb,changes} OUT/.
+```
+-- or --
+```bash
+mkdir -p /usr/src/OUT \
+&& mv -v ../*.{deb,changes} /usr/src/OUT/.
+```
+
+## Output
+
+After a successful build, the Debian packages will be available in the `OUT` directory.
diff --git a/scripts/packaging/build/dependencies/libks/README.md b/scripts/packaging/build/dependencies/libks/README.md
new file mode 100644
index 0000000000..31521943b4
--- /dev/null
+++ b/scripts/packaging/build/dependencies/libks/README.md
@@ -0,0 +1,98 @@
+# Building `libks` Debian Package
+
+This guide explains how to build the `libks` Debian package.
+
+## Prerequisites:
+- Git
+- Debian-based system (native or Docker)
+
+## Build Steps
+
+### Clone the repository:
+```bash
+git clone git@github.com:signalwire/libks.git
+```
+
+### (Optionally) Use Docker to build packages for Debian `Bookworm`:
+```bash
+docker run -it -v $(pwd):/usr/src/ debian:bookworm bash -c "cd /usr/src/ && bash"
+```
+
+### Set non-interactive frontend for APT:
+```bash
+export DEBIAN_FRONTEND=noninteractive
+```
+
+### Install required build tools:
+```bash
+apt-get update \
+&& apt-get -y upgrade \
+&& apt-get -y install \
+    build-essential \
+    cmake \
+    devscripts \
+    lsb-release \
+    docbook-xsl \
+    pkg-config
+```
+
+### Set build number (modify as needed):
+```bash
+export BUILD_NUMBER=42
+```
+> Note: The build number (42) used in this guide is arbitrary. You can modify it as needed for your build process.
+
+### Set Debian codename:
+```bash
+export CODENAME=$(lsb_release -sc)
+```
+
+### Configure git safety setting:
+```bash
+git config --global --add safe.directory '*'
+```
+
+### Navigate to the source directory:
+```bash
+cd libks/
+```
+-- or --
+```bash
+cd /usr/src/libks/
+```
+
+### Extract git hash:
+```bash
+export GIT_SHA=$(git rev-parse --short HEAD)
+```
+
+### Install build dependencies:
+```bash
+apt-get update \
+&& apt-get -y install \
+    libssl-dev \
+    uuid-dev
+```
+
+### Build binary package:
+```bash
+PACKAGE_RELEASE="${BUILD_NUMBER}.${GIT_SHA}" cmake . \
+    -DCMAKE_BUILD_TYPE=Debug \
+    -DCMAKE_INSTALL_PREFIX="/usr" \
+&& make package
+```
+
+### Move built packages to the output directory:
+```bash
+mkdir -p OUT \
+&& mv -v *.deb OUT/.
+```
+-- or --
+```bash
+mkdir -p /usr/src/OUT \
+&& mv -v *.deb /usr/src/OUT/.
+```
+
+## Output
+
+After a successful build, the Debian packages will be available in the `OUT` directory.
diff --git a/scripts/packaging/build/dependencies/libsilk/README.md b/scripts/packaging/build/dependencies/libsilk/README.md
new file mode 100644
index 0000000000..f64075c057
--- /dev/null
+++ b/scripts/packaging/build/dependencies/libsilk/README.md
@@ -0,0 +1,117 @@
+# Building `libsilk` Debian Package
+
+This guide explains how to build the `libsilk` Debian package.
+
+## Prerequisites:
+- Git
+- Debian-based system (native or Docker)
+
+## Build Steps
+
+### Clone the repository:
+```bash
+git clone git@github.com:freeswitch/libsilk.git
+```
+
+### (Optionally) Use Docker to build packages for Debian `Bookworm`:
+```bash
+docker run -it -v $(pwd):/usr/src/ debian:bookworm bash -c "cd /usr/src/ && bash"
+```
+
+### Set non-interactive frontend for APT:
+```bash
+export DEBIAN_FRONTEND=noninteractive
+```
+
+### Install required build tools:
+```bash
+apt-get update \
+&& apt-get -y upgrade \
+&& apt-get -y install \
+    build-essential \
+    cmake \
+    devscripts \
+    lsb-release \
+    docbook-xsl \
+    pkg-config
+```
+
+### Set build number (modify as needed):
+```bash
+export BUILD_NUMBER=42
+```
+> Note: The build number (42) used in this guide is arbitrary. You can modify it as needed for your build process.
+
+### Set Debian codename:
+```bash
+export CODENAME=$(lsb_release -sc)
+```
+
+### Configure git safety setting:
+```bash
+git config --global --add safe.directory '*'
+```
+
+### Navigate to the source directory:
+```bash
+cd libsilk/
+```
+-- or --
+```bash
+cd /usr/src/libsilk/
+```
+
+### Extract Debian package version:
+```bash
+export VERSION=$(dpkg-parsechangelog --show-field Version | cut -f1 -d'-')
+```
+
+### Extract git hash:
+```bash
+export GIT_SHA=$(git rev-parse --short HEAD)
+```
+
+### Install build dependencies:
+```bash
+apt-get update \
+&& mk-build-deps \
+    --install \
+    --remove debian/control \
+    --tool "apt-get -y --no-install-recommends" \
+&& apt-get -y -f install
+```
+
+### Update changelog:
+```bash
+dch \
+    --controlmaint \
+    --distribution "${CODENAME}" \
+    --force-bad-version \
+    --force-distribution \
+    --newversion "${VERSION}-${BUILD_NUMBER}-${GIT_SHA}~${CODENAME}" \
+    "Nightly build, ${GIT_SHA}"
+```
+
+### Build binary package:
+```bash
+debuild \
+    --no-tgz-check \
+    --build=binary \
+    --unsigned-source \
+    --unsigned-changes
+```
+
+### Move built packages to the output directory:
+```bash
+mkdir -p OUT \
+&& mv -v ../*.{deb,changes} OUT/.
+```
+-- or --
+```bash
+mkdir -p /usr/src/OUT \
+&& mv -v ../*.{deb,changes} /usr/src/OUT/.
+```
+
+## Output
+
+After a successful build, the Debian packages will be available in the `OUT` directory.
diff --git a/scripts/packaging/build/dependencies/libv8/README.md b/scripts/packaging/build/dependencies/libv8/README.md
new file mode 100644
index 0000000000..252cfef741
--- /dev/null
+++ b/scripts/packaging/build/dependencies/libv8/README.md
@@ -0,0 +1,151 @@
+# Building `libv8` Debian Package
+
+This guide explains how to build the `libv8` Debian package.
+
+## Prerequisites:
+- Git
+- Debian-based system (native or Docker)
+- Only supported platform is AMD64
+
+## Build Steps
+
+### Clone the repository:
+```bash
+git clone git@github.com:freeswitch/libv8-packaging.git
+```
+
+### (Optionally) Use Docker to build packages for Debian `Bookworm`:
+```bash
+docker run -it -v $(pwd):/usr/src/ debian:bookworm bash -c "cd /usr/src/ && bash"
+```
+
+### Set non-interactive frontend for APT:
+```bash
+export DEBIAN_FRONTEND=noninteractive
+```
+
+### Install required build tools:
+```bash
+apt-get update \
+&& apt-get -y upgrade \
+&& apt-get -y install \
+    build-essential \
+    cmake \
+    devscripts \
+    lsb-release \
+    docbook-xsl \
+    pkg-config
+```
+
+### Set build number (modify as needed):
+```bash
+export BUILD_NUMBER=42
+```
+> Note: The build number (42) used in this guide is arbitrary. You can modify it as needed for your build process.
+
+### Set Debian codename:
+```bash
+export CODENAME=$(lsb_release -sc)
+```
+
+### Configure git safety setting:
+```bash
+git config --global --add safe.directory '*'
+```
+
+### Navigate to the source directory:
+```bash
+cd libv8-packaging/
+```
+-- or --
+```bash
+cd /usr/src/libv8-packaging/
+```
+
+### Install build dependencies:
+```bash
+apt-get update -y \
+&& apt-get install -y \
+    libbz2-dev \
+    libffi-dev \
+    libglib2.0-dev \
+    liblzma-dev \
+    libncurses5-dev \
+    libncursesw5-dev \
+    libreadline-dev \
+    libsqlite3-dev \
+    libssl-dev \
+    libtinfo5 \
+    llvm \
+    ninja-build \
+    tk-dev \
+    zlib1g-dev
+```
+
+### Configure build parameters:
+```bash
+export PYENV_VERSION_TAG=v2.4.0
+export PYTHON_VERSION=2.7.18
+export V8_GIT_VERSION=6.1.298
+export PYENV_ROOT="/opt/pyenv"
+export PATH="$PYENV_ROOT/shims:$PYENV_ROOT/bin:$BUILD_DIR/depot_tools:$PATH"
+export BUILD_DIR=$(realpath $(pwd))/BUILD
+```
+
+### Clone, build and configure `pyenv`:
+```bash
+git clone --branch $PYENV_VERSION_TAG https://github.com/pyenv/pyenv.git $PYENV_ROOT \
+    && sed -i 's|PATH="/|PATH="$PYENV_ROOT/bin/:/|g' /etc/profile \
+    && $PYENV_ROOT/bin/pyenv init - | tee -a /etc/profile \
+    && echo "export PATH=\"$BUILD_DIR/depot_tools:${PATH}\"" | tee -a /etc/profile
+```
+
+### Install `pyenv`:
+```bash
+pyenv install $PYTHON_VERSION \
+    && pyenv global $PYTHON_VERSION
+```
+
+### Configure build:
+```bash
+mkdir -p $BUILD_DIR \
+    && cp ./stub-gclient-spec $BUILD_DIR/.gclient \
+    && cp -av ./debian/ $BUILD_DIR/ \
+    && cd $BUILD_DIR
+```
+
+### Build binaries:
+```bash
+git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git \
+    && gclient sync --verbose -r $V8_GIT_VERSION \
+    && cd v8 \
+    && gn gen out.gn --args="is_debug=true symbol_level=2 blink_symbol_level=1 v8_symbol_level=1 v8_static_library=true is_component_build=false v8_enable_i18n_support=false v8_use_external_startup_data=false" \
+    && gn args out.gn --list | tee out.gn/gn_args.txt \
+    && ninja -v d8 -C out.gn \
+&& cd $BUILD_DIR
+```
+
+### Build Debian package:
+```bash
+sed -i -e "s/GIT_VERSION/$V8_GIT_VERSION/g" debian/v8-6.1_static.pc \
+    && sed -i -e "s/GIT_VERSION/$V8_GIT_VERSION/g" debian/changelog \
+    && sed -i -e "s/DATE/$(env LC_ALL=en_US.utf8 date '+%a, %d %b %Y %H:%M:%S %z')/g" debian/changelog \
+    && sed -i -e "s/DISTRO/$(lsb_release -sc | tr -d '\n')/g" debian/changelog \
+    && sed -i -e "s/BUILD_NUMBER/$BUILD_NUMBER/g" debian/changelog \
+&& debuild -b -us -uc
+```
+
+### Move built packages to the output directory:
+```bash
+mkdir -p OUT \
+&& mv -v ../*.{deb,changes} OUT/.
+```
+-- or --
+```bash
+mkdir -p /usr/src/OUT \
+&& mv -v ../*.{deb,changes} /usr/src/OUT/.
+```
+
+## Output
+
+After a successful build, the Debian packages will be available in the `OUT` directory.
diff --git a/scripts/packaging/build/dependencies/signalwire-c/README.md b/scripts/packaging/build/dependencies/signalwire-c/README.md
new file mode 100644
index 0000000000..621143854a
--- /dev/null
+++ b/scripts/packaging/build/dependencies/signalwire-c/README.md
@@ -0,0 +1,113 @@
+# Building `signalwire-c` Debian Package
+
+This guide explains how to build the `signalwire-c` Debian package.
+
+## Prerequisites:
+- Git
+- Debian-based system (native or Docker)
+- LibKS
+
+## Build Steps
+
+### Clone the repository:
+```bash
+git clone git@github.com:signalwire/signalwire-c.git
+```
+
+### (Optionally) Use Docker to build packages for Debian `Bookworm`:
+```bash
+docker run -it -v $(pwd):/usr/src/ debian:bookworm bash -c "cd /usr/src/ && bash"
+```
+
+### Set non-interactive frontend for APT:
+```bash
+export DEBIAN_FRONTEND=noninteractive
+```
+
+### Install required build tools:
+```bash
+apt-get update \
+&& apt-get -y upgrade \
+&& apt-get -y install \
+    build-essential \
+    cmake \
+    devscripts \
+    lsb-release \
+    docbook-xsl \
+    pkg-config
+```
+
+### Set build number (modify as needed):
+```bash
+export BUILD_NUMBER=42
+```
+> Note: The build number (42) used in this guide is arbitrary. You can modify it as needed for your build process.
+
+### Set Debian codename:
+```bash
+export CODENAME=$(lsb_release -sc)
+```
+
+### Configure git safety setting:
+```bash
+git config --global --add safe.directory '*'
+```
+
+### Navigate to the source directory:
+```bash
+cd signalwire-c/
+```
+-- or --
+```bash
+cd /usr/src/signalwire-c/
+```
+
+### Extract git hash:
+```bash
+export GIT_SHA=$(git rev-parse --short HEAD)
+```
+
+### (Optionally) Use local file-based Debian repository to install `libks` dependency:
+```bash
+cd OUT/ \
+&& dpkg-scanpackages . | tee OUT/Packages \
+&& gzip -f OUT/Packages \
+&& printf "deb [trusted=yes] file:$(realpath $(pwd)) ./\n" | tee /etc/apt/sources.list.d/local.list
+```
+-- or --
+```bash
+cd /usr/src/OUT/ \
+&& dpkg-scanpackages . | tee /usr/src/OUT/Packages \
+&& gzip -f /usr/src/OUT/Packages \
+&& printf "deb [trusted=yes] file:/usr/src/OUT ./\n" | tee /etc/apt/sources.list.d/local.list
+```
+
+### Install build dependencies:
+```bash
+apt-get update \
+&& apt-get -y install \
+    libks2
+```
+
+### Build binary package:
+```bash
+PACKAGE_RELEASE="${BUILD_NUMBER}.${GIT_SHA}" cmake . \
+    -DCMAKE_BUILD_TYPE=Debug \
+    -DCMAKE_INSTALL_PREFIX="/usr" \
+&& make package
+```
+
+### Move built packages to the output directory:
+```bash
+mkdir -p OUT \
+&& mv -v *.deb OUT/.
+```
+-- or --
+```bash
+mkdir -p /usr/src/OUT \
+&& mv -v *.deb /usr/src/OUT/.
+```
+
+## Output
+
+After a successful build, the Debian packages will be available in the `OUT` directory.
diff --git a/scripts/packaging/build/dependencies/sofia-sip/README.md b/scripts/packaging/build/dependencies/sofia-sip/README.md
new file mode 100644
index 0000000000..9c42f39fe8
--- /dev/null
+++ b/scripts/packaging/build/dependencies/sofia-sip/README.md
@@ -0,0 +1,117 @@
+# Building `sofia-sip` Debian Package
+
+This guide explains how to build the `sofia-sip` Debian package.
+
+## Prerequisites:
+- Git
+- Debian-based system (native or Docker)
+
+## Build Steps
+
+### Clone the repository:
+```bash
+git clone git@github.com:freeswitch/sofia-sip.git
+```
+
+### (Optionally) Use Docker to build packages for Debian `Bookworm`:
+```bash
+docker run -it -v $(pwd):/usr/src/ debian:bookworm bash -c "cd /usr/src/ && bash"
+```
+
+### Set non-interactive frontend for APT:
+```bash
+export DEBIAN_FRONTEND=noninteractive
+```
+
+### Install required build tools:
+```bash
+apt-get update \
+&& apt-get -y upgrade \
+&& apt-get -y install \
+    build-essential \
+    cmake \
+    devscripts \
+    lsb-release \
+    docbook-xsl \
+    pkg-config
+```
+
+### Set build number (modify as needed):
+```bash
+export BUILD_NUMBER=42
+```
+> Note: The build number (42) used in this guide is arbitrary. You can modify it as needed for your build process.
+
+### Set Debian codename:
+```bash
+export CODENAME=$(lsb_release -sc)
+```
+
+### Configure git safety setting:
+```bash
+git config --global --add safe.directory '*'
+```
+
+### Navigate to the source directory:
+```bash
+cd sofia-sip/
+```
+-- or --
+```bash
+cd /usr/src/sofia-sip/
+```
+
+### Extract Debian package version:
+```bash
+export VERSION=$(dpkg-parsechangelog --show-field Version | cut -f1 -d'-')
+```
+
+### Extract git hash:
+```bash
+export GIT_SHA=$(git rev-parse --short HEAD)
+```
+
+### Install build dependencies:
+```bash
+apt-get update \
+&& mk-build-deps \
+    --install \
+    --remove debian/control \
+    --tool "apt-get -y --no-install-recommends" \
+&& apt-get -y -f install
+```
+
+### Update changelog:
+```bash
+dch \
+    --controlmaint \
+    --distribution "${CODENAME}" \
+    --force-bad-version \
+    --force-distribution \
+    --newversion "${VERSION}-${BUILD_NUMBER}-${GIT_SHA}~${CODENAME}" \
+    "Nightly build, ${GIT_SHA}"
+```
+
+### Build binary package:
+```bash
+debuild \
+    --no-tgz-check \
+    --build=binary \
+    --unsigned-source \
+    --unsigned-changes
+```
+
+### Move built packages to the output directory:
+```bash
+mkdir -p OUT \
+&& mv -v ../*.{deb,changes} OUT/.
+```
+-- or --
+```bash
+mkdir -p /usr/src/OUT \
+&& mv -v ../*.{deb,changes} /usr/src/OUT/.
+```
+
+## Output
+
+After a successful build, the Debian packages will be available in the `OUT` directory.
diff --git a/scripts/packaging/build/dependencies/spandsp/README.md b/scripts/packaging/build/dependencies/spandsp/README.md
new file mode 100644
index 0000000000..ac21733140
--- /dev/null
+++ b/scripts/packaging/build/dependencies/spandsp/README.md
@@ -0,0 +1,117 @@
+# Building `spandsp` Debian Package
+
+This guide explains how to build the `spandsp` Debian package.
+
+## Prerequisites:
+- Git
+- Debian-based system (native or Docker)
+
+## Build Steps
+
+### Clone the repository:
+```bash
+git clone --branch packages git@github.com:freeswitch/spandsp.git
+```
+
+### (Optionally) Use Docker to build packages for Debian `Bookworm`:
+```bash
+docker run -it -v $(pwd):/usr/src/ debian:bookworm bash -c "cd /usr/src/ && bash"
+```
+
+### Set non-interactive frontend for APT:
+```bash
+export DEBIAN_FRONTEND=noninteractive
+```
+
+### Install required build tools:
+```bash
+apt-get update \
+&& apt-get -y upgrade \
+&& apt-get -y install \
+    build-essential \
+    cmake \
+    devscripts \
+    lsb-release \
+    docbook-xsl \
+    pkg-config
+```
+
+### Set build number (modify as needed):
+```bash
+export BUILD_NUMBER=42
+```
+> Note: The build number (42) used in this guide is arbitrary. You can modify it as needed for your build process.
+
+### Set Debian codename:
+```bash
+export CODENAME=$(lsb_release -sc)
+```
+
+### Configure git safety setting:
+```bash
+git config --global --add safe.directory '*'
+```
+
+### Navigate to the source directory:
+```bash
+cd spandsp/
+```
+-- or --
+```bash
+cd /usr/src/spandsp/
+```
+
+### Extract Debian package version:
+```bash
+export VERSION=$(dpkg-parsechangelog --show-field Version | cut -f1 -d'-')
+```
+
+### Extract git hash:
+```bash
+export GIT_SHA=$(git rev-parse --short HEAD)
+```
+
+### Install build dependencies:
+```bash
+apt-get update \
+&& mk-build-deps \
+    --install \
+    --remove debian/control \
+    --tool "apt-get -y --no-install-recommends" \
+&& apt-get -y -f install
+```
+
+### Update changelog:
+```bash
+dch \
+    --controlmaint \
+    --distribution "${CODENAME}" \
+    --force-bad-version \
+    --force-distribution \
+    --newversion "${VERSION}-${BUILD_NUMBER}-${GIT_SHA}~${CODENAME}" \
+    "Nightly build, ${GIT_SHA}"
+```
+
+### Build binary package:
+```bash
+debuild \
+    --no-tgz-check \
+    --build=binary \
+    --unsigned-source \
+    --unsigned-changes
+```
+
+### Move built packages to the output directory:
+```bash
+mkdir -p OUT \
+&& mv -v ../*.{deb,changes} OUT/.
+```
+-- or --
+```bash
+mkdir -p /usr/src/OUT \
+&& mv -v ../*.{deb,changes} /usr/src/OUT/.
+```
+
+## Output
+
+After a successful build, the Debian packages will be available in the `OUT` directory.