From 130d7fb70f4a10755731e898e87610547fe44692 Mon Sep 17 00:00:00 2001 From: Kyle Harding Date: Fri, 2 Feb 2024 09:46:06 -0500 Subject: [PATCH] Remove unused block-build functions Change-type: minor Signed-off-by: Kyle Harding --- README.md | 1 - automation/Dockerfile_yocto-block-build-env | 20 --- .../entry_scripts/balena-build-block.sh | 103 ------------- automation/include/balena-deploy.inc | 41 ----- automation/jenkins_build-blocks.sh | 144 ------------------ 5 files changed, 309 deletions(-) delete mode 100644 automation/Dockerfile_yocto-block-build-env delete mode 100755 automation/entry_scripts/balena-build-block.sh delete mode 100755 automation/jenkins_build-blocks.sh diff --git a/README.md b/README.md index da7fc79f6..228d0a796 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,6 @@ This repository provides helper scripts and tools for building Balena OS. * __build/barys__: Used for native builds, barys is a wrapper script over bitbake that builds BalenaOS. Used to initialize a build directory and create device type json files out of the coffeescript files, and then run the default build. Use `-n` to just setup the build directory. * __build/balena-build.sh__: Used to build in a container, this script downloads a container builder image and calls barys. * __automation/jenkins_build.sh__: Used in jenkins automation to build the OS, requires a jenkins environment to work. -* __automation/jenkins_build-blocks.sh__: Used in jenkins automation to build OS blocks defined in a hostOS contract, requires a jenkins environment to work. ## Contributing diff --git a/automation/Dockerfile_yocto-block-build-env b/automation/Dockerfile_yocto-block-build-env deleted file mode 100644 index 2aaa95d71..000000000 --- a/automation/Dockerfile_yocto-block-build-env +++ /dev/null @@ -1,20 +0,0 @@ -ARG NAMESPACE="balena" -ARG TAG="latest" -FROM ${NAMESPACE}/balena-push-env:${TAG} - -RUN apt-get update && apt-get install -y git make automake gcc libtool libtool-bin pkg-config libarchive-dev libcurl4-openssl-dev libssl-dev libgpgme11-dev && rm -rf /var/lib/apt/lists/* - -RUN git clone git://git.yoctoproject.org/opkg opkg -RUN cd ./opkg && ./autogen.sh && ./configure --enable-libsolv && make && make install - -RUN LD_LIBRARY_PATH=/usr/local/lib && ldconfig - -RUN mkdir -p /var/lib/opkg /etc/opkg/ -RUN echo 'dest hostapp /hostapp\n\ -option info_dir /var/lib/opkg/info\n\ -option lists_dir /var/lib/opkg/lists\n\ -option status_file /var/lib/opkg/status'\ -> /etc/opkg/opkg.conf - -COPY include/balena-api.inc include/balena-lib.inc entry_scripts/balena-build-block.sh / -WORKDIR / diff --git a/automation/entry_scripts/balena-build-block.sh b/automation/entry_scripts/balena-build-block.sh deleted file mode 100755 index d1020f294..000000000 --- a/automation/entry_scripts/balena-build-block.sh +++ /dev/null @@ -1,103 +0,0 @@ -#!/bin/bash - -set -e - -script_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) -source "${script_dir}/balena-api.inc" -source "${script_dir}/balena-lib.inc" - -# Input checks -[ -z "${APPNAME}" ] && echo "The block's app name needs to be defined" && exit 1 -[ -z "${MACHINE}" ] && echo "Machine needs to be defined" && exit 1 -[ -z "${PACKAGES}" ] && echo "list of packages to install without dependencies" && exit 1 -[ -z "${RELEASE_VERSION}" ] && echo "A release version needs to be defined" && exit 1 -[ -z "${WORKSPACE}" ] && echo "Workspace needs to be defined" && exit 1 - -[ -z "${PACKAGE_TYPE}" ] && PACKAGE_TYPE="ipk" - -DEVICE_TYPE_JSON="$WORKSPACE/$MACHINE.json" -if [ -e "${DEVICE_TYPE_JSON}" ]; then - ARCH=$(jq --raw-output '.arch' "$DEVICE_TYPE_JSON") -fi -[ -z "${ARCH}" ] && echo "Device architecture is required" && exit 1 - -source /balena-docker.inc - -finish() { - balena_docker_stop - # Dockerd leaves a mount here - if ! umount "${DOCKER_ROOT}"; then - umount -l "${DOCKER_ROOT}" || true - fi - rm -rf "${TMPDIR}" -} -trap finish EXIT ERR - -# Start docker -# Data root needs to be on a non-aufs directory to use balena build -TMPDIR=$(mktemp -d --tmpdir="${WORKSPACE:?}") -DOCKER_ROOT="${TMPDIR}/docker" -balena_docker_start "${DOCKER_ROOT}" "/var/run" "/var/log/docker.log" -balena_docker_wait - -# Only support overlay images for the time being. Labels to be parametrized from contract in future. -cat << 'EOF' > ${TMPDIR}/Dockerfile -ARG NAMESPACE=balena -ARG TAG=latest -FROM ${NAMESPACE}/yocto-block-build-env:${TAG} AS builder -ARG PACKAGES -ARG ARCH_LIST -ARG FEED_URL="file:/ipk" -COPY feed / -RUN priority=1; for arch in $ARCH_LIST; do echo "arch $arch $priority" >> /etc/opkg/opkg.conf; priority=$(expr $priority + 5); echo "src/gz balena-$arch $FEED_URL/$arch" >> /etc/opkg/opkg.conf; done -RUN mkdir /hostapp -RUN opkg -f /etc/opkg/opkg.conf update && opkg -f /etc/opkg/opkg.conf --nodeps --dest=hostapp install ${PACKAGES} || true -RUN rm -rf /hostapp/var/lib/opkg -FROM scratch -COPY --from=builder /hostapp / -EOF - -# Add image labels -echo "LABEL ${BALENA_HOSTOS_BLOCK_CLASS}=overlay" >> "${TMPDIR}/Dockerfile" -echo "LABEL ${BALENA_HOSTOS_BLOCK_REQUIRES_REBOOT}=1" >> "${TMPDIR}/Dockerfile" -echo "LABEL ${BALENA_HOSTOS_BLOCK_STORE}=data" >> "${TMPDIR}/Dockerfile" - -# Copy local package feed to context if available from previous build step -if [ -d "${WORKSPACE}/deploy-jenkins/${PACKAGE_TYPE}" ]; then - ARCH_LIST="" - mkdir -p "${TMPDIR}/feed" - cp -r "${WORKSPACE}/deploy-jenkins/${PACKAGE_TYPE}" "${TMPDIR}/feed/" - # Extract package architecture list from feed - # Each architecture is one directory - while IFS=$'\n' read -r dir; do - if [ -z "${ARCH_LIST}" ]; then - ARCH_LIST="${dir}" - else - ARCH_LIST="${ARCH_LIST} ${dir}" - fi - done< <(find "${WORKSPACE}/deploy-jenkins/${PACKAGE_TYPE}" -mindepth 1 -maxdepth 1 -type d | xargs -I{} basename {}) -else - proto=${FEED_URL%:*} - if [ -z "${FEED_URL}" ] || [ "${proto}" = "file" ]; then - echo "[ERROR] Local package feed not available" - exit 1 - fi -fi - -pushd "${TMPDIR}" - -# Clean local docker of labelled hostos images -docker rmi -f $(docker images --filter "label=${BALENA_HOSTOS_BLOCK_CLASS}" --format "{{.ID}}" | tr '\n' ' ') 2> /dev/null || true - -if balena build --logs --nocache --deviceType "${MACHINE}" --arch "${ARCH}" --buildArg PACKAGES="${PACKAGES}" --buildArg ARCH_LIST="${ARCH_LIST}" --buildArg NAMESPACE="${NAMESPACE:-balena}"; then - image_id=$(docker images --filter "label=${BALENA_HOSTOS_BLOCK_CLASS}" --format "{{.ID}}") - mkdir -p "${WORKSPACE}/deploy-jenkins" - docker save "${image_id}" > "${WORKSPACE}/deploy-jenkins/${APPNAME}-${RELEASE_VERSION}.docker" -else - echo "[ERROR] Fail to build" - exit 1 -fi - -popd - -exit 0 diff --git a/automation/include/balena-deploy.inc b/automation/include/balena-deploy.inc index 25c60f009..850205b55 100644 --- a/automation/include/balena-deploy.inc +++ b/automation/include/balena-deploy.inc @@ -330,47 +330,6 @@ balena_deploy_block() { balena_lib_docker_remove_helper_images "balena-push-env" } -# Builds and deploys the specified block to BalenaCloud -# Input arguments; -# $1: App name to deploy into -# $2: Device type for the app -# $3: Package list to build the block with -# $4: Balena cloud account (defaults to balena_os) -# $5: Balena API environment -# -balena_build_block() { - local _appName="$1" - local _device_type="${2:-${MACHINE}}" - local _packages="${3:-${PACKAGES}}" - local _balenaos_account="${4:-balena_os}" - local _api_env="${5:-$(balena_lib_environment)}" - - [ -z "${_appName}" ] && echo "App name is required" && return - [ -z "${_device_type}" ] && echo "Device type is required" && return - [ -z "${_packages}" ] && echo "Package list is required" && return - - if ! balena_lib_docker_pull_helper_image "Dockerfile_yocto-block-build-env" balena_yocto_scripts_revision; then - return 1 - fi - docker run --rm -t \ - -e APPNAME="${_appName}" \ - -e NAMESPACE="${NAMESPACE:-balena}" \ - -e RELEASE_VERSION="$(balena_lib_get_os_version)" \ - -e PACKAGES="${_packages}" \ - -e VERBOSE="${VERBOSE}" \ - -e MACHINE="${_device_type}" \ - -e TAG="${balena_yocto_scripts_revision}" \ - -e WORKSPACE=/work \ - -e balenaCloudEmail="${balenaCloudEmail}" \ - -e balenaCloudPassword="${balenaCloudPassword}" \ - -e ESR="${ESR}" \ - -v "${WORKSPACE:-"${PWD}"}":/work \ - --privileged \ - "${NAMESPACE}"/yocto-block-build-env:"${balena_yocto_scripts_revision}" /balena-build-block.sh - - balena_lib_docker_remove_helper_images "yocto-block-build-env" -} - # Initialize a compose file in the specified path # # Input: diff --git a/automation/jenkins_build-blocks.sh b/automation/jenkins_build-blocks.sh deleted file mode 100755 index 614e20318..000000000 --- a/automation/jenkins_build-blocks.sh +++ /dev/null @@ -1,144 +0,0 @@ -#!/bin/bash - -set -e -[ "${VERBOSE}" = "verbose" ] && set -x - -script_name=$(basename "${0}") -automation_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) -include_dir="${automation_dir}/include" -build_dir="${automation_dir}/../build" -work_dir=$( cd "${automation_dir}/../../" && pwd ) - -usage() { - cat <