Untitled

Format: Shell
 ( View Raw)
Date: Fri, 09 Dec 2022 at 19:53:04

#!/bin/bash

pkg_dir="$(pwd)/debian-packages"
mtune="cortex-a76.cortex-a55"

set_flags() {
    export DEB_CFLAGS_APPEND="-mtune=$mtune"
    export DEB_CXXFLAGS_APPEND="-mtune=$mtune"
    export DEB_FCFLAGS_APPEND="-mtune=$mtune"
    export DEB_FFFLAGS_APPEND="-mtune=$mtune"
    export DEB_GCJFLAGS_APPEND="-mtune=$mtune"
    export DEB_OBJCFLAGS_APPEND="-mtune=$mtune"
    export DEB_OBJCXXFLAGS_APPEND="-mtune=$mtune"
}

build_package() {
    package=$1
    mkdir -p src/debian
    pushd src/debian/ || exit 1
        echo
        echo "Building Package: $package"
        echo "Installing Build Dependencies..."
        sudo apt build-dep -y "$pkg" > build.log 2>&1
        echo "Building From Source..."
        apt-get source --compile "$package" > build.log 2>&1
        rm -Rf "${package}-dbgsym*"
        mv ./*.deb "$pkg_dir"
        rm -Rf ./*
        echo "--------------------------------"
    popd || exit 1
}


pkg_file=$(pwd)/$1
sudo apt install -y build-essential fakeroot devscripts
mkdir -p "$pkg_dir"
pushd "$pkg_dir" || exit 1
set_flags
while read -r pkg; do
    build_package "$pkg" || exit 2
done < "$pkg_file"
popd