Skip to content

Commit

Permalink
Support Ubuntu 22.04 arm64 amd64 (#490)
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyi-peng committed Jul 10, 2023
1 parent df81fb7 commit 09fcc4a
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 18 deletions.
19 changes: 15 additions & 4 deletions azurepipelines/build/native/adu-ubuntu-amd64-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,21 @@ pr:
- licenses/*

jobs:
- job: BuildAduAgent_ubuntu2204
displayName: "Build ADU Agent - Ubuntu 22.04 (amd64)"
timeoutInMinutes: 120
cancelTimeoutInMinutes: 120
pool: aduc_1es_client_pool
steps:
- template: ../templates/adu-docker-build-steps.yml
parameters:
targetOs: "ubuntu2204"
targetArch: "amd64"

- job: BuildAduAgent_ubuntu1804
displayName: "Build ADU Agent - Ubuntu 18.04 (amd64)"
timeoutInMinutes: 60
cancelTimeoutInMinutes: 60
timeoutInMinutes: 120
cancelTimeoutInMinutes: 120
pool: aduc_1es_client_pool
steps:
- template: ../templates/adu-docker-build-steps.yml
Expand All @@ -73,8 +84,8 @@ jobs:

- job: BuildAduAgent_ubuntu2004
displayName: "Build ADU Agent - Ubuntu 20.04 (amd64)"
timeoutInMinutes: 60
cancelTimeoutInMinutes: 60
timeoutInMinutes: 120
cancelTimeoutInMinutes: 120
pool: 1es_hosted_pool_ubuntu2004
steps:
- template: ../templates/adu-docker-build-steps.yml
Expand Down
27 changes: 19 additions & 8 deletions azurepipelines/build/native/adu-ubuntu-arm64-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,35 @@ pr:
- licenses/*

jobs:
- job: BuildAduAgent_ubuntu2204
displayName: "Build ADU Agent - Ubuntu 22.04 (arm64)"
timeoutInMinutes: 120
cancelTimeoutInMinutes: 120
pool: aduc_1es_client_pool
steps:
- template: ../templates/adu-docker-build-steps.yml
parameters:
targetOs: "ubuntu2204"
targetArch: "arm64"

- job: BuildAduAgent_ubuntu2004
displayName: "Build ADU Agent - Ubuntu 20.04 (arm64)"
timeoutInMinutes: 60
cancelTimeoutInMinutes: 60
pool: ubuntu2004_arm_pool
timeoutInMinutes: 120
cancelTimeoutInMinutes: 120
pool: aduc_1es_client_pool
steps:
- template: ../templates/adu-native-build-steps.yml
- template: ../templates/adu-docker-build-steps.yml
parameters:
targetOs: "ubuntu2004"
targetArch: "arm64"

- job: BuildAduAgent_ubuntu1804
displayName: "Build ADU Agent - Ubuntu 18.04 (arm64)"
timeoutInMinutes: 60
cancelTimeoutInMinutes: 60
pool: ubuntu1804_arm_pool
timeoutInMinutes: 120
cancelTimeoutInMinutes: 120
pool: aduc_1es_client_pool
steps:
- template: ../templates/adu-native-build-steps.yml
- template: ../templates/adu-docker-build-steps.yml
parameters:
targetOs: "ubuntu1804"
targetArch: "arm64"
34 changes: 33 additions & 1 deletion scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ install_prefix=/usr/local
install_adu=false
work_folder=/tmp
cmake_dir_path="${work_folder}/deviceupdate-cmake"
openssl_dir_path="/usr/local/lib/deviceupdate-openssl"

print_help() {
echo "Usage: build.sh [options...]"
Expand Down Expand Up @@ -79,6 +80,8 @@ print_help() {
echo ""
echo "--cmake-path Override the cmake path such that CMake binary is at <cmake-path>/bin/cmake"
echo ""
echo "--openssl-path Override the openssl path"
echo ""
echo "--major-version Major version of ADU"
echo ""
echo "--minor-version Minor version of ADU"
Expand Down Expand Up @@ -295,6 +298,10 @@ while [[ $1 != "" ]]; do
shift
cmake_dir_path=$1
;;
--openssl-path)
shift
openssl_dir_path=$1
;;
--major-version)
shift
major_version=$1
Expand Down Expand Up @@ -366,7 +373,31 @@ else
fi
echo ''

# Store options for CMAKE in an array
do_install_openssl() {
local openssl_dir=$work_folder/openssl-1.1.1u
echo "Installing OpenSSL ..."

$SUDO apt-get install -y build-essential checkinstall zlib1g-dev -y || return
wget https://www.openssl.org/source/openssl-1.1.1u.tar.gz || return
mkdir -p $openssl_dir || return
tar -xf openssl-1.1.1u.tar.gz -C $openssl_dir --strip-components=1 || return
pushd $openssl_dir > /dev/null || return
./config --prefix="$openssl_dir_path" --openssldir="$openssl_dir_path" shared zlib || return
make || return

$SUDO make install || return
export LD_LIBRARY_PATH="$openssl_dir_path/lib:$LD_LIBRARY_PATH" || return
echo "OpenSSL has been installed in $openssl_dir_path"

popd > /dev/null || return
}

# Check if the directory exists
if [ ! -d "$openssl_dir_path" ]; then
echo "OpenSSL directory not found. Invoking installation..."
do_install_openssl || return
fi

CMAKE_OPTIONS=(
"-DADUC_BUILD_DOCUMENTATION:BOOL=$build_documentation"
"-DADUC_BUILD_UNIT_TESTS:BOOL=$build_unittests"
Expand All @@ -381,6 +412,7 @@ CMAKE_OPTIONS=(
"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY:STRING=$library_dir"
"-DCMAKE_RUNTIME_OUTPUT_DIRECTORY:STRING=$runtime_dir"
"-DCMAKE_INSTALL_PREFIX=$install_prefix"
"-DOPENSSL_ROOT_DIR=$openssl_dir_path"
)

if [[ $major_version != "" ]]; then
Expand Down
50 changes: 45 additions & 5 deletions scripts/install-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ azure_sdk_ref=LTS_07_2021_Ref01
# ADUC Test Deps

install_catch2=false
default_catch2_ref=v2.11.0
default_catch2_ref=v2.13.9
catch2_ref=$default_catch2_ref
install_swupdate=false
default_swupdate_ref=2021.11
Expand All @@ -65,6 +65,8 @@ cmake_prefix="$work_folder"
cmake_installer_dir=""
cmake_dir_symlink="/tmp/deviceupdate-cmake"

openssl_dir_path="/usr/local/lib/deviceupdate-openssl"

install_shellcheck=false
supported_shellcheck_version='0.8.0'

Expand All @@ -79,7 +81,7 @@ do_ref=$default_do_ref
# Dependencies packages
aduc_packages=('git' 'make' 'build-essential' 'cmake' 'ninja-build' 'libcurl4-openssl-dev' 'libssl-dev' 'uuid-dev' 'python2.7' 'lsb-release' 'curl' 'wget' 'pkg-config')
static_analysis_packages=('clang' 'clang-tidy' 'cppcheck')
compiler_packages=("gcc-[68]")
compiler_packages=('gcc' 'g++')

# Distro and arch info
OS=""
Expand Down Expand Up @@ -134,6 +136,9 @@ print_help() {
echo "-k, --keep-source-code Indicates that source code should not be deleted after install from work_folder."
echo ""
echo "--use-ssh Use ssh URLs to clone instead of https URLs."
echo ""
echo "--openssl-dir-path Specific path to install OpenSSL 1.1"
echo ""
echo "--list-deps List the states of the dependencies."
echo "-h, --help Show this help message."
echo ""
Expand All @@ -156,6 +161,25 @@ do_install_githooks() {
fi
}

do_install_openssl() {
local openssl_dir=$work_folder/openssl-1.1.1u
echo "Installing OpenSSL ..."

$SUDO apt-get install -y build-essential checkinstall zlib1g-dev -y || return
wget https://www.openssl.org/source/openssl-1.1.1u.tar.gz || return
mkdir -p $openssl_dir || return
tar -xf openssl-1.1.1u.tar.gz -C $openssl_dir --strip-components=1 || return
pushd $openssl_dir > /dev/null || return
./config --prefix="$openssl_dir_path" --openssldir="$openssl_dir_path" shared zlib || return
make || return

$SUDO make install || return
export LD_LIBRARY_PATH="$openssl_dir_path/lib:$LD_LIBRARY_PATH" || return
echo "OpenSSL has been installed in $openssl_dir_path"

popd > /dev/null || return
}

do_install_aduc_packages() {
echo "Installing dependency packages for ADU Agent..."

Expand All @@ -164,10 +188,12 @@ do_install_aduc_packages() {
# The latest version of gcc available on Debian is gcc-6. We install that version if we are
# building for Debian, otherwise we install gcc-8 for Ubuntu.
OS=$(lsb_release --short --id)
if [[ $OS == "debian" && $VER == "9" ]]; then
if [[ $OS == "Debian" && $VER == "9" ]]; then
$SUDO apt-get install --yes gcc-6 g++-6 || return
elif [[ $OS == "Debian" && $VER == "11" ]]; then
$SUDO apt-get install --yes gcc-10 g++-10 || return
elif [[ $OS == "Ubuntu" && $VER == "22.04" ]]; then
$SUDO apt-get install --yes gcc-10 g++-10 || return
else
$SUDO apt-get install --yes gcc-8 g++-8 || return
fi
Expand All @@ -182,6 +208,12 @@ do_install_aduc_packages() {

# Note that clang-tidy requires clang to be installed so that it can find clang headers.
$SUDO apt-get install --yes "${static_analysis_packages[@]}" || return

# Check if the directory exists
if [ ! -d "$openssl_dir_path" ]; then
echo "OpenSSL directory not found. Invoking installation..."
do_install_openssl || $ret
fi
}

do_install_azure_iot_sdk() {
Expand Down Expand Up @@ -216,6 +248,7 @@ do_install_azure_iot_sdk() {
"-Dskip_samples:BOOL=ON"
"-Dbuild_service_client:BOOL=OFF"
"-Dbuild_provisioning_service_client:BOOL=OFF"
"-DOPENSSL_ROOT_DIR=$openssl_dir_path"
)

if [[ $keep_source_code == "true" ]]; then
Expand Down Expand Up @@ -259,7 +292,9 @@ do_install_catch2() {

mkdir cmake || return
pushd cmake > /dev/null || return

cmake .. || return

cmake --build . || return
$SUDO cmake --build . --target install || return
popd > /dev/null || return
Expand Down Expand Up @@ -444,8 +479,6 @@ do_install_do() {

git clone --recursive --single-branch --branch $do_ref --depth 1 $do_url . || return

#TODO: Remove the sepecif commit once DO publishs a new tag
git checkout 02c9ae2c7484182903c66ad986a834762fc569e6
bootstrap_file=$do_dir/build/scripts/bootstrap.sh
chmod +x $bootstrap_file || return
$SUDO $bootstrap_file --install build || return
Expand All @@ -456,6 +489,7 @@ do_install_do() {
local do_cmake_options=(
"-DDO_BUILD_TESTS:BOOL=OFF"
"-DDO_INCLUDE_SDK=ON"
"-DOPENSSL_ROOT_DIR=$openssl_dir_path"
)

if [[ $keep_source_code == "true" ]]; then
Expand Down Expand Up @@ -514,6 +548,8 @@ do_install_azure_blob_storage_file_upload_utility() {
azure_blob_storage_file_upload_utility_cmake_options+=("-DCMAKE_BUILD_TYPE:STRING=Release")
fi

azure_blob_storage_file_upload_utility_cmake_options+=("-DOPENSSL_ROOT_DIR=$openssl_dir_path")

echo -e "Building Azure Blob Storage File Upload Uility ...\n\tBranch: $azure_blob_storage_file_upload_utility_ref\n\t"
cmake "${azure_blob_storage_file_upload_utility_cmake_options[@]}" .. || return

Expand Down Expand Up @@ -848,6 +884,10 @@ while [[ $1 != "" ]]; do
--use-ssh)
use_ssh=true
;;
--openssl-dir-path)
shift
openssl_dir_path=$1
;;
--list-deps)
do_list_all_deps
$ret $?
Expand Down

0 comments on commit 09fcc4a

Please sign in to comment.