Skip to content

Commit

Permalink
fixes issues with all plans till core/hab-studio
Browse files Browse the repository at this point in the history
Signed-off-by: Johny Jose <[email protected]>
  • Loading branch information
atrniv committed May 24, 2023
1 parent 4ef7dac commit 0bb86b1
Show file tree
Hide file tree
Showing 78 changed files with 307 additions and 210 deletions.
60 changes: 60 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
HAB_BOOTSTRAP_IMAGE_VERSION = "20230523"
HAB_AUTO_BUILD_GIT_REPO = "https://github.com/habitat-sh/hab-auto-build.git"
HAB_AUTO_BUILD_BRANCH = "v2"
PACKAGE = "*/*"

check-docker:
@if ! command -v docker &> /dev/null; then \
echo "Docker is not installed. Please install Docker: https://docs.docker.com/get-docker/"; \
exit 1; \
fi

check-rust:
@if ! command -v cargo &> /dev/null; then \
echo "Cargo is not installed. Please install Rust: https://www.rust-lang.org/tools/install"; \
exit 1; \
fi

check-hab-auto-build:
@if ! command -v hab-auto-build &> /dev/null; then \
echo "hab-auto-build is not found. Please install it by running 'make setup'"; \
exit 1; \
fi

build-hab-bootstrap-image: check-docker
@echo "Building Docker Image for build tools: hab-bootstrap:$(HAB_BOOTSTRAP_IMAGE_VERSION)"
@docker build -q -t hab-bootstrap:$(HAB_BOOTSTRAP_IMAGE_VERSION) docker/hab-bootstrap &> /dev/null
@echo "Docker Image built hab-bootstrap:$(HAB_BOOTSTRAP_IMAGE_VERSION)"

install-hab-auto-build: check-rust
@if ! command -v hab-auto-build &> /dev/null; then \
echo "Installing hab-auto-build"; \
cargo install --git $(HAB_AUTO_BUILD_GIT_REPO) --branch $(HAB_AUTO_BUILD_BRANCH); \
echo "Installed hab-auto-build"; \
else \
echo "Found hab-auto-build already installed at $$(which hab-auto-build)"; \
fi

update-hab-auto-build: check-rust
@echo "Updating hab-auto-build"
@cargo install --git $(HAB_AUTO_BUILD_GIT_REPO) --branch $(HAB_AUTO_BUILD_BRANCH) --quiet;
@echo "Updated hab-auto-build"

setup: build-hab-bootstrap-image install-hab-auto-build
@echo "Installed all tools for building packages"

update: build-hab-bootstrap-image update-hab-auto-build
@echo "Updated all tools for building packages"

build-dry-run: check-hab-auto-build
hab-auto-build build -d $(PACKAGE)

build: check-hab-auto-build setup
@echo "Building all packages matching $(PACKAGE)"
hab-auto-build build $(PACKAGE)
@echo "Built all packages matching $(PACKAGE)"

check: check-hab-auto-build
@echo "Checking all packages matching $(PACKAGE)"
hab-auto-build check $(PACKAGE)
@echo "Checked all packages matching $(PACKAGE)"
166 changes: 8 additions & 158 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,167 +1,17 @@
# Habitat Packages Bootstrap
# Habitat Core Packages

This repo contains plan files that can be used to bootstrap a set of self contained GNU build tools
that are completely isolated from the host system environment. These build tools can then be used to
bootstrap a set of standard habitat packages for new platforms.
This repository houses plan files designed to bootstrap a comprehensive suite of self-sufficient GNU build tools. These tools are designed to operate independently from the host system environment, providing a foundation to bootstrap a complete set of standard habitat packages for both new and existing platforms.

This repo builds on knowledge available from the Linux From Scratch project (LFS) and adapts it for
Habitat's packaging system. There are many variants of the LFS project for different platforms and versions.
This repo largely follows the instructions [mentioned here](https://clfs.org/~kb0iic/lfs-systemd/index.html).
The repository leverages knowledge from various sources, including the Linux From Scratch (LFS) project and Nix, and tailors it to suit Habitat's packaging system.

## Building
There exist numerous LFS project variants tailored for different platforms and versions. This repository primarily adheres to the instructions [found here](https://clfs.org/~kb0iic/lfs-systemd/index.html).

### Checking the Host System tools
## Compilation Process

Before you start building, you can run the `version-check.sh` script to check the versions of the various required tools on your system.
Be sure to cross check the version meets the minimum specified version mentioned [here](https://clfs.org/~kb0iic/lfs-systemd/chapter02/hostreqs.html).
To compile all the packages contained within this repository, clone the repository and execute the following command:

```bash
bash version-check.sh
make build
```

### Building with hab-auto-build

The packages in this repo can be built using [hab-auto-build](https://github.com/habitat-sh/hab-auto-build).

To build all the packages you can use the following command:

```bash
hab-auto-build build
```

**IMPORTANT** If you make any changes to any plans in any of the folders, the hab-auto-build
tool will consider the package as updated and rebuild that package and all it's
dependants.

You can also build a specific package and all packages that depend on it with
the following command:

```bash
hab-auto-build build -i dev <package-name>
#Eg: hab-auto-build build -i dev core/build-tools-glibc
```

### Building Manually

The packages involved in the bootstrapping process are almost always native packages.
To build them you must make sure you have enabled native package support for Habitat.

As of this writing, you need a habitat build of the latest commit on [jj/aarch64-linux-bootstrap branch](https://github.com/habitat-sh/habitat/tree/jj/aarch64-linux-bootstrap) to build these plans.

```bash
export HAB_FEAT_NATIVE_PACKAGE_SUPPORT=1
```

To build a package you can use the following command

```bash
# In the root folder of this repo
hab pkg build -N <package-folder>
# Eg: hab pkg build -N bootstrap/cross-tools/build-tools-glibc
```
### Cross Building

You should theoretically be able to follow the same build process to cross build the arm packages on
`x86_64` linux platforms as well. To do so you need to set an additional environment variable before
running a build.

```bash
# On an x86_64 machine
export TARGET_ARCH="aarch64-linux"
```

### Running Tests

Most of the packages have tests defined. You can run it by setting the `DO_CHECK` environment variable.

```bash
DO_CHECK=1 hab pkg build -N <package-folder>
# Eg: DO_CHECK=1 hab pkg build -N bootstrap/cross-tools/build-tools-file
```

## Manual Build Order

This is a build order for the initial set of build tools packages that can be followed if you
are building each plan manually.

### Temporary Cross Compilation Toolchain

These are a minimal set of packages that can be used to build an isolated set of build tools.
At this stage the build process completely depends on tools available on the host system.

- native-libgmp
- native-libmpfr
- native-libmpc
- native-libisl
- native-cross-binutils
- native-cross-gcc-real
- build-tools-linux-headers
- build-tools-glibc
- build-tools-libstdcpp
- native-cross-gcc

### Build Tools

These are the set of packages that compromise the isolated build tools. They still depend on tools
available on the host for their build process, however they have no runtime dependencies on the host system.

- build-tools-binutils
- build-tools-libgmp
- build-tools-libmpfr
- build-tools-libmpc
- build-tools-libisl
- build-tools-gcc
- build-tools-gcc-libs
- build-tools-patchelf
- build-tools-m4
- build-tools-ncurses
- build-tools-bash
- build-tools-coreutils
- build-tools-diffutils
- native-file
- build-tools-file
- build-tools-findutils
- build-tools-gawk
- build-tools-grep
- build-tools-gzip
- build-tools-make
- build-tools-patch
- build-tools-sed
- build-tools-tar
- build-tools-xz
- build-tools-cacerts
- build-tools-openssl
- build-tools-wget
- native-busybox-static

### Hab Bootstrap Studio Toolchain

These next set of packages are the minimum set of native packages required to get a functional
habitat bootstrap studio running to start building standard packages in a clean room environment.

Since these components already have existing standard plans, we have an alternative set of native
bootstrapping plans in this repo which we use to build a minimal hab chroot studio with support for
the `bootstrap` studio type.

- build-tools-hab
- build-tools-hab-plan-build
- build-tools-hab-backline
- build-tools-studio

On you have built a bootstrap studio you can use it for isolated package builds using the following
commands.

```bash
# Entering a studio
sudo HAB_LICENSE=accept-no-persist HAB_ORIGIN=core hab pkg exec core/build-tools-hab-studio hab-studio -- -t bootstrap enter
```

**IMPORTANT**: If you have not yet been able to push your packages to the builder you will need to ensure
that the correct version of each build dependency is installed inside the bootstrap studio before doing a build.

You can do this using the following command inside the studio:

```bash
hab pkg install /hab/cache/artifacts/<dependency-hart-file>
# Eg: hab pkg install /hab/cache/artifacts/core-build-tools-util-linux-2.38.1-20221018054208-aarch64-linux.hart
```
The Habitat Auto Build tool is utilized internally to build the packages. For more complex tasks, please refer to the Habitat Auto Build tool's [readme](https://github.com/habitat-sh/hab-auto-build/tree/v2).
5 changes: 5 additions & 0 deletions docker/hab-bootstrap/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM ubuntu:20.04
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y wget curl sudo tar xz-utils gawk bison python3 make m4 patch gcc g++ texinfo bash autoconf protobuf-compiler pkg-config
RUN ln -sfv bash /bin/sh
COPY build.sh /bin/build
RUN chmod +x /bin/build
13 changes: 13 additions & 0 deletions docker/hab-bootstrap/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
# This installs any additional packages before starting the studio.
# It is useful in scenarios where you have a newer version of a package
# and want habitat to pick the newer locally installed version during
# a studio build. We do exactly this during the package refresh process.
if [ -n "${HAB_STUDIO_INSTALL_PKGS-}" ]; then
echo "Installing additional packages in image"
deps=$(echo "$HAB_STUDIO_INSTALL_PKGS" | tr ":" "\n")
for dep in $deps; do
hab pkg install "$dep"
done
fi
hab pkg build -N "$1"
4 changes: 2 additions & 2 deletions hab-auto-build.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"repos": [
{
"id": "core",
"source": "../core-packages",
"source": ".",
"native_packages": [
"packages/bootstrap/build-support/**",
"packages/bootstrap/build-tools/cross-compiler/**",
Expand All @@ -14,4 +14,4 @@
]
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pkg_deps=(
core/geos
core/glibc
core/json-c
core/libpcre2
core/pcre
core/libxml2
core/icu
core/perl
Expand Down
2 changes: 1 addition & 1 deletion packages/applications/editors/vim/.hab-plan-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
missing-license = { level = "off", source-shasum = "c75acdac8b80e664666663d3429efe1eb25be7f13db0bd3697a2d2a78dd1bb66" }
license-not-found = { level = "off", source-shasum = "c75acdac8b80e664666663d3429efe1eb25be7f13db0bd3697a2d2a78dd1bb66" }
# Script for a use with UNIX that we don't care about
host-script-interpreter = { ignored_files = ["share/vim/vim90/tools/vim132"] }
host-script-interpreter = { ignored_files = ["share/vim/vim*/tools/vim132"] }
4 changes: 2 additions & 2 deletions packages/applications/editors/vim/plan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ do_install() {

# Install license file
install -Dm644 runtime/doc/uganda.txt "${pkg_prefix}/share/licenses/license.txt"
# fix_interpreter "$pkg_prefix/share/vim/vim90/**/*" core/coreutils bin/env
# sed -e "s,/usr/bin/python,$(pkg_path_for core/coreutils)/bin/env python3,g" -i "$pkg_prefix/share/vim/vim90/tools/demoserver.py"
fix_interpreter "$pkg_prefix/share/vim/vim*/**/*" core/coreutils bin/env
sed -e "s,/usr/bin/python,$(pkg_path_for core/coreutils)/bin/env python3,g" -i "$pkg_prefix/share/vim/vim82/tools/demoserver.py"
}
2 changes: 1 addition & 1 deletion packages/applications/servers/nginx/plan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pkg_deps=(
core/zlib
core/bzip2
core/openssl
core/pcre2
core/pcre
)
pkg_build_deps=(
core/gcc
Expand Down
4 changes: 2 additions & 2 deletions packages/applications/version-management/git/plan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pkg_deps=(
core/expat
core/gettext
core/glibc
core/libpcre2
core/pcre
core/openssh
core/openssl
core/perl
Expand Down Expand Up @@ -47,7 +47,7 @@ do_build() {
--with-shell="$(pkg_path_for bash)/bin/sh" \
--with-zlib="$(pkg_path_for zlib)" \
--with-openssl \
--with-libpcre2
--with-libpcre

make -j"$(nproc)"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
docker-image = "hab-bootstrap:20230523"

[rules]
missing-license = { level = "off", source-shasum = "c62127bdd4e60916c5556b8be2ee0f10a54450ebda6cd30e71a1add59b78a59b" }
license-not-found = { level = "off", source-shasum = "c62127bdd4e60916c5556b8be2ee0f10a54450ebda6cd30e71a1add59b78a59b" }
license-not-found = { level = "off", source-shasum = "c62127bdd4e60916c5556b8be2ee0f10a54450ebda6cd30e71a1add59b78a59b" }
4 changes: 3 additions & 1 deletion packages/bootstrap/build-support/hab-cc-wrapper/plan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ pkg_license=('Apache-2.0')
pkg_source="https://github.com/habitat-sh/hab-pkg-wrappers/archive/${commit_hash}.tar.gz"
pkg_shasum="c62127bdd4e60916c5556b8be2ee0f10a54450ebda6cd30e71a1add59b78a59b"
pkg_dirname="hab-pkg-wrappers-${commit_hash}"
pkg_build_deps=(
core/native-rust
)

# We don't specify 'pkg_bin_dirs' as we always use the wrapper via it's full path

bin="hab-cc-wrapper"

do_prepare() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
docker-image = "hab-bootstrap:20230523"

[rules]
missing-license = { level = "off", source-shasum = "c62127bdd4e60916c5556b8be2ee0f10a54450ebda6cd30e71a1add59b78a59b" }
license-not-found = { level = "off", source-shasum = "c62127bdd4e60916c5556b8be2ee0f10a54450ebda6cd30e71a1add59b78a59b" }
4 changes: 3 additions & 1 deletion packages/bootstrap/build-support/hab-ld-wrapper/plan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ pkg_license=('Apache-2.0')
pkg_source="https://github.com/habitat-sh/hab-pkg-wrappers/archive/${commit_hash}.tar.gz"
pkg_shasum="c62127bdd4e60916c5556b8be2ee0f10a54450ebda6cd30e71a1add59b78a59b"
pkg_dirname="hab-pkg-wrappers-${commit_hash}"
pkg_build_deps=(
core/native-rust
)

# We don't specify 'pkg_bin_dirs' as we always use the wrapper via it's full path

bin="hab-ld-wrapper"

do_prepare() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
docker-image = "hab-bootstrap:20230523"

[rules]
missing-license = { level = "off", source-shasum = "67fc1a4030d08ee877a4867d3dcab35828148f87e1fd05da6db585ed5a166bd4" }
license-not-found = { level = "off", source-shasum = "67fc1a4030d08ee877a4867d3dcab35828148f87e1fd05da6db585ed5a166bd4" }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
docker-image = "hab-bootstrap:20230523"

[rules]
missing-license = { level = "off", source-shasum="c95da32f440378d7751dd95533186f7fc05ceb4fb65eb5b85234e6299eb9838e" }
license-not-found = { level = "off", source-shasum="c95da32f440378d7751dd95533186f7fc05ceb4fb65eb5b85234e6299eb9838e" }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
docker-image = "hab-bootstrap:20230523"

[rules]
host-script-interpreter = "off"
# This package combines multiple packages into a single package
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
docker-image = "hab-bootstrap:20230523"

[rules]
missing-license = { level = "off", source-shasum = "5bac17218d3911834520dad13cd1f85ab944e1c09ae1aba55906be1f8192f558" }
license-not-found = { level = "off", source-shasum = "5bac17218d3911834520dad13cd1f85ab944e1c09ae1aba55906be1f8192f558" }
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
docker-image = "hab-bootstrap:20230523"

[rules]
missing-license = { level = "off", source-shasum = "67fc1a4030d08ee877a4867d3dcab35828148f87e1fd05da6db585ed5a166bd4" }
license-not-found = { level = "off", source-shasum = "67fc1a4030d08ee877a4867d3dcab35828148f87e1fd05da6db585ed5a166bd4" }
Expand Down
Loading

0 comments on commit 0bb86b1

Please sign in to comment.