Skip to content
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
| [webinstall.dev](https://github.com/devcontainer-community/devcontainer-features/tree/main/src/webinstall.dev) | `webi` — install packages without sudo | curl | 1.0.1 |
| [yakitrak/notesmd-cli](https://github.com/devcontainer-community/devcontainer-features/tree/main/src/yakitrak-notesmd-cli) | `notesmd-cli` — manage Obsidian vaults from the terminal | gh release | 1.0.0 |
| [yoctoproject.org](https://github.com/devcontainer-community/devcontainer-features/tree/main/src/yoctoproject.org) | `bitbake` — build tool for the Yocto Project and OpenEmbedded | curl | 1.0.0 |
| [yoctoproject.org/bitbake](https://github.com/devcontainer-community/devcontainer-features/tree/main/src/yoctoproject.org-bitbake) | `bitbake` — build tool for the Yocto Project | curl | 1.0.0 |
| [yq](https://github.com/devcontainer-community/devcontainer-features/tree/main/src/yq) | `yq` — command-line YAML/JSON/XML processor | gh release | 1.0.1 |
| [zellij.dev](https://github.com/devcontainer-community/devcontainer-features/tree/main/src/zellij.dev) | `zellij` — terminal workspace with multiplexer and layouts | gh release | 1.0.2 |
| [zyedidia/eget](https://github.com/devcontainer-community/devcontainer-features/tree/main/src/zyedidia-eget) | `eget` — easily install prebuilt binaries from GitHub releases | gh release | 1.0.2 |
17 changes: 17 additions & 0 deletions src/yoctoproject.org-bitbake/NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# yoctoproject.org/bitbake

## Project

- [BitBake](https://github.com/openembedded/bitbake)

## Description

BitBake is a generic task execution engine for the Yocto Project and OpenEmbedded that allows shell and Python tasks to be run efficiently and in parallel while working within complex inter-task dependency constraints. It is the build tool at the core of the Yocto Project's embedded Linux build system.

## Installation Method

Downloaded as a source tarball from [github.com/openembedded/bitbake](https://github.com/openembedded/bitbake) (tags in the form `yocto-X.Y.Z`) and extracted to `/opt/bitbake`, with wrapper scripts placed in `/usr/local/bin`.

## Other Notes

_No additional notes._
17 changes: 17 additions & 0 deletions src/yoctoproject.org-bitbake/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "yoctoproject.org/bitbake",
"id": "yoctoproject.org-bitbake",
"version": "1.0.0",
"description": "Install \"bitbake\" build tool for the Yocto Project",
"documentationURL": "https://github.com/devcontainer-community/devcontainer-features/tree/main/src/yoctoproject.org-bitbake",
"options": {
"version": {
"type": "string",
"default": "latest",
"proposals": [
"latest"
],
"description": "Version of \"bitbake\" to install."
}
}
}
113 changes: 113 additions & 0 deletions src/yoctoproject.org-bitbake/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#!/bin/bash
set -o errexit
set -o pipefail
set -o noclobber
set -o nounset
set -o allexport
readonly name="bitbake"
readonly githubRepository='openembedded/bitbake'
readonly installDir='/opt/bitbake'
readonly binaryTargetFolder='/usr/local/bin'
apt_get_update() {
if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then
echo "Running apt-get update..."
apt-get update -y
fi
}
apt_get_checkinstall() {
if ! dpkg -s "$@" >/dev/null 2>&1; then
apt_get_update
DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends --no-install-suggests --option 'Debug::pkgProblemResolver=true' --option 'Debug::pkgAcquire::Worker=1' "$@"
fi
}
apt_get_cleanup() {
apt-get clean
rm -rf /var/lib/apt/lists/*
}
check_curl_tar_installed() {
declare -a requiredAptPackagesMissing=()
if ! [ -r '/etc/ssl/certs/ca-certificates.crt' ]; then
requiredAptPackagesMissing+=('ca-certificates')
fi
if ! command -v curl >/dev/null 2>&1; then
requiredAptPackagesMissing+=('curl')
fi
if ! command -v tar >/dev/null 2>&1; then
requiredAptPackagesMissing+=('tar')
fi
declare -i requiredAptPackagesMissingCount=${#requiredAptPackagesMissing[@]}
if [ $requiredAptPackagesMissingCount -gt 0 ]; then
apt_get_update
apt_get_checkinstall "${requiredAptPackagesMissing[@]}"
apt_get_cleanup
fi
}
curl_check_url() {
local url=$1
local status_code
status_code=$(curl -s -o /dev/null -w '%{http_code}' "$url")
if [ "$status_code" -ne 200 ] && [ "$status_code" -ne 302 ]; then
echo "Failed to download '$url'. Status code: $status_code."
return 1
fi
}
curl_download_stdout() {
local url=$1
curl \
--silent \
--location \
--output '-' \
--connect-timeout 5 \
"$url"
}
echo_banner() {
local text="$1"
echo -e "\e[1m\e[97m\e[41m$text\e[0m"
}
utils_check_version() {
local version=$1
if ! [[ "${version:-}" =~ ^(latest|[0-9]+\.[0-9]+(\.[0-9]+)?)$ ]]; then
printf >&2 '=== [ERROR] Option "version" (value: "%s") is not "latest" or valid version format "X.Y" or "X.Y.Z" !\n' \
"$version"
exit 1
fi
}
github_get_latest_bitbake_version() {
curl -s "https://api.github.com/repos/${githubRepository}/tags?per_page=100" \
| grep -oP '"name":\s*"yocto-\K[0-9]+\.[0-9]+\.[0-9]+(?=")' \
| sort -V \
| tail -1
}
install() {
utils_check_version "$VERSION"
check_curl_tar_installed
apt_get_checkinstall python3 locales
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
locale-gen
if [ "$VERSION" == 'latest' ] || [ -z "$VERSION" ]; then
VERSION="$(github_get_latest_bitbake_version)"
fi
readonly version="${VERSION:?}"
readonly downloadUrl="https://github.com/${githubRepository}/archive/refs/tags/yocto-${version}.tar.gz"
curl_check_url "$downloadUrl"
mkdir -p "$installDir"
curl_download_stdout "$downloadUrl" | tar \
-xz \
-f '-' \
--strip-components=1 \
-C "$installDir"
local bin_name
for bin_file in "${installDir}/bin"/*; do
bin_name="$(basename "$bin_file")"
printf '#!/bin/sh\nexec "%s" "$@"\n' "$bin_file" > "${binaryTargetFolder}/${bin_name}"
chmod 755 "${binaryTargetFolder}/${bin_name}"
done
if ! command -v python >/dev/null 2>&1; then
ln -sf "$(command -v python3)" /usr/local/bin/python
fi
apt_get_cleanup
}
echo_banner "devcontainer.community"
echo "Installing $name..."
install "$@"
echo "(*) Done!"
14 changes: 14 additions & 0 deletions test/yoctoproject.org-bitbake/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

set -e

# Optional: Import test library bundled with the devcontainer CLI
# See https://github.com/devcontainers/cli/blob/HEAD/docs/features/test.md#dev-container-features-test-lib
# Provides the 'check' and 'reportResults' commands.
source dev-container-features-test-lib

# Feature-specific tests
check "execute command" bash -c "bitbake --version | grep 'BitBake'"

# Report results
reportResults
Loading