Skip to content

Rename CBL-Mariner to Azure Linux in documentation #68

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 31 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@

# Introduction
The [CBL-Mariner](https://github.com/microsoft/CBL-Mariner) repository provides detailed instructions for building CBL-Mariner from end-to-end. While it is possible to clone CBL-Mariner and build packages or images from that environment, for most users, it is _not the recommended approach_. Usually it is best to work in a smaller, problem focused environment where you can quickly build just what you need, and rely on the fact that the curated CBL-Mariner packages are already available in the cloud. In this way, you can customize an image with your preferred disk layout or adding supplemental packages that CBL-Mariner may not provide. If you are building a product based on CBL-Mariner, you may want your own repository with just the minimal set of packages for your business needs. This repo, the CBL-MarinerTutorials repo, provides a basic template for getting started. From here you can create a CBL-Mariner based product (aka a Derivative Image) or you may generate quick experimental or debug builds to try out new ideas.

When you build an ISO, VHD or VHDX image from this repository, the resulting image will contain additional content unavailable in the CBL-Mariner repo. The CBL-MarinerTutorials repository demonstrates how you can augment CBL-Mariner without forking the CBL-Mariner repository. This repository contains the SPEC file and source for building a simple "Hello World" application. This repository also includes a simple "os-subrelease" package that allows you to add identifying information about your derivative to an /etc/os-subrelease file.
Follow this decision tree to ensure you are using the correct repository for your use case:
```mermaid
---
title: Repo decision tree
---
flowchart TD
id1{{Do you want to experiment with Mariner or contribute to Mariner?}}
id2A[Do you want to build locally with Mariner?]
id2B[Do you want to add an unsupported package? \n either a package Mariner has never supported \nor an updated major/minor version of a package Mariner supports]
id2C[Do you want to use Mariner for your project? \n ex. bare metal, IoT, embedded devices, etc.]
id2D[Use the CBL-MarinerTutorials repo]
id1 -->|experiment| id2A
id2A -.-|or| id2B
id2B -.-|or| id2C
id2C -->|yes to any of the above| id2D
id3[Do you want to fix an issue in Mariner?]
id3B[Do you want to add a common package? \n either a package supported by another major distro \nor a package used widely across popular open-source projects]
id3C[Do you want to modify a supported Mariner package?]
id3D[Do you want to rebuild Mariner from end-to-end?]
id3E[Use the CBL-Mariner repo]
id1 --> |contribute|id3
# Introduction

The [Azure Linux](https://github.com/microsoft/azurelinux) repository provides detailed instructions for building Azure Linux from end-to-end. While it is possible to clone Azure Linux and build packages or images from that environment, for most users, it is _not the recommended approach_. Usually it is best to work in a smaller, problem focused environment where you can quickly build just what you need, and rely on the fact that the curated Azure Linux packages are already available in the cloud. In this way, you can customize an image with your preferred disk layout or adding supplemental packages that Azure Linux may not provide. If you are building a product based on Azure Linux, you may want your own repository with just the minimal set of packages for your business needs. This repo, the azurelinux-tutorials repo, provides a basic template for getting started. From here you can create an Azure Linux based product (aka a Derivative Image) or you may generate quick experimental or debug builds to try out new ideas.

When you build an ISO, VHD or VHDX image from this repository, the resulting image will contain additional content unavailable in the Azure Linux repo. The azurelinux-tutorials repository demonstrates how you can augment Azure Linux without forking the Azure Linux repository. This repository contains the SPEC file and source for building a simple "Hello World" application. This repository also includes a simple "os-subrelease" package that allows you to add identifying information about your derivative to an /etc/os-subrelease file.

Follow this decision tree to ensure you are using the correct repository for your use case:

```mermaid
---
title: Repo decision tree
---
flowchart TD
id1{{Do you want to experiment with Azure Linux or contribute to Azure Linux?}}

id2A[Do you want to build locally with Azure Linux?]
id2B[Do you want to add an unsupported package? \n either a package Azure Linux has never supported \nor an updated major/minor version of a package Azure Linux supports]
id2C[Do you want to use Azure Linux for your project? \n ex. bare metal, IoT, embedded devices, etc.]
id2D[Use the azurelinux-tutorials repo]
id1 -->|experiment| id2A
id2A -.-|or| id2B
id2B -.-|or| id2C
id2C -->|yes to any of the above| id2D


id3[Do you want to fix an issue in Azure Linux?]
id3B[Do you want to add a common package? \n either a package supported by another major distro \nor a package used widely across popular open-source projects]
id3C[Do you want to modify a supported Azure Linux package?]
id3D[Do you want to rebuild Azure Linux from end-to-end?]
id3E[Use the Azure Linux repo]
id1 --> |contribute|id3
id3 -.-|or| id3B
id3B -.-|or| id3C
id3C -.-|or| id3D
Expand Down
4 changes: 2 additions & 2 deletions SPECS/os-subrelease/os-subrelease.spec
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ License: Apache License
Group: System Environment/Base
URL: https://my-company-or-product-url
Vendor: My Company Name
Distribution: Mariner
Distribution: Azure Linux
BuildArch: noarch

%description
This package creates a sample os subrelease file: /etc/os-subrelease. Replace contents as needed for your CBL-Mariner based product information
This package creates a sample os subrelease file: /etc/os-subrelease. Replace contents as needed for your Azure Linux based product information

%install
rm -rf $RPM_BUILD_ROOT
Expand Down
46 changes: 23 additions & 23 deletions build-in-container/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build-in-container
The build-in-container tool provides a developer tool to quickly build Mariner packages. It is easy-to-use, and distribution and platform agnostic. It sets up a build environment in an expedient manner using a container.
The build-in-container tool provides a developer tool to quickly build Azure Linux packages. It is easy-to-use, and distribution and platform agnostic. It sets up a build environment in an expedient manner using a container.

Please install docker on your system before using the tool.

Expand All @@ -8,76 +8,76 @@ The mariner-docker-builder.sh script presents these options <br />
<pre>
-t creates container image <br />
-b creates container, builds specs under [mariner_dir]/SPECS/, & places output under [mariner_dir]/out/ <br />
-i creates an interactive Mariner build container <br />
-c cleans up Mariner workspace at [mariner_dir], container images and instances <br />
-i creates an interactive Azure Linux build container <br />
-c cleans up Azure Linux workspace at [mariner_dir], container images and instances <br />
--help shows help on usage <br />

Optional arguments <br />
--mariner_dir directory to use for Mariner artifacts (SPECS, toolkit, ..). Default is the current directory <br />
--mariner_dir directory to use for Azure Linux artifacts (SPECS, toolkit, ..). Default is the current directory <br />
--RPM_repo_file Path(s) to custom repo file(s) (must end in .repo). Please see [here](./README.md#sample-custom-repo) for sample custom repo file. Provide multiple files with space (" ") as delimiter. Please prefer RPM_repo_file over RPM_container_URL. <br />
--RPM_container_URL URL(s) of Azure blob storage container(s) to install RPMs from. Provide multiple URLs with space (" ") as delimiter <br />
--disable_mariner_repo disable default setting to use default Mariner package repos on packages.microsoft.com <br />
--disable_mariner_repo disable default setting to use default Azure Linux package repos on packages.microsoft.com <br />
</pre>

- 'tool_dir' refers to the directory of the build-in-container tool <br/>
- 'mariner_dir' refers to the directory with Mariner artifacts (SPECS, toolkit, etc.) <br/>
- If mariner_dir is provided, it will be used for all Mariner artifacts like toolkit, SPECS, build, out and logs. Else, current directory will be used. <br />
- 'mariner_dir' refers to the directory with Azure Linux artifacts (SPECS, toolkit, etc.) <br/>
- If mariner_dir is provided, it will be used for all Azure Linux artifacts like toolkit, SPECS, build, out and logs. Else, current directory will be used. <br />
- Place specs to build under $mariner_dir/SPECS/ <br />
- Please find SPEC sample [here](./../SPECS/hello_world_demo/) <br />
- The output from the build will be available under $mariner_dir/out/ (RPMS and SRPMS) <br />
- Logs are published under $mariner_dir/logs/ <br />

``` bash
# Setup the container for 1st use
./CBL-MarinerTutorials/build-in-container/mariner-docker-builder.sh -t
./azurelinux-tutorials/build-in-container/mariner-docker-builder.sh -t
# Build `SPECS/**/*.spec` automatically
./CBL-MarinerTutorials/build-in-container/mariner-docker-builder.sh -b
ls CBL-MarinerTutorials/build-in-container/out/RPMS/x86_64/
./azurelinux-tutorials/build-in-container/mariner-docker-builder.sh -b
ls azurelinux-tutorials/build-in-container/out/RPMS/x86_64/
# hello_world_demo-1.0.0-2.cm2.x86_64.rpm hello_world_demo-debuginfo-1.0.0-2.cm2.x86_64.rpm

# Invoke the toolkit directly
./CBL-MarinerTutorials/build-in-container/mariner-docker-builder.sh -i
./azurelinux-tutorials/build-in-container/mariner-docker-builder.sh -i
# Run the tools manually
make build-packages SRPM_PACK_LIST="hello_world_demo" -j$(nproc)

# Use optional arguments
## Provide path to Mariner directory. If this option is not used, the current directory is treated as Mariner directory
./CBL-MarinerTutorials/build-in-container/mariner-docker-builder.sh -i --mariner_dir /path/to/CBL-Mariner/
## Provide path to Azure Linux directory. If this option is not used, the current directory is treated as Azure Linux directory
./azurelinux-tutorials/build-in-container/mariner-docker-builder.sh -i --mariner_dir /path/to/azurelinux/

## Install RPMs from a custom repo, by providing path to .repo file
## Please ensure that custom repo file ends in '.repo' as per requirements of rpm/yum/tdnf/dnf
## Provide multiple paths with space (" ") as delimiter
./CBL-MarinerTutorials/build-in-container/mariner-docker-builder.sh -i --RPM_repo_file "path/to/custom-repo-file.repo[ path/to/another-custom-repo-file.repo]"
./azurelinux-tutorials/build-in-container/mariner-docker-builder.sh -i --RPM_repo_file "path/to/custom-repo-file.repo[ path/to/another-custom-repo-file.repo]"

## Install RPMs from an Azure blob-storage container storing custom RPMs, by providing URL of the container
## Provide multiple URLs with space (" ") as delimiter
./CBL-MarinerTutorials/build-in-container/mariner-docker-builder.sh -i --RPM_container_URL "https://az-storage-account.blob.core.windows.net/az-container/[ https://az-storage-account.blob.core.windows.net/another-az-container/]"
./azurelinux-tutorials/build-in-container/mariner-docker-builder.sh -i --RPM_container_URL "https://az-storage-account.blob.core.windows.net/az-container/[ https://az-storage-account.blob.core.windows.net/another-az-container/]"

## Disable default setting to use default Mariner package repos on packages.microsoft.com
./CBL-MarinerTutorials/build-in-container/mariner-docker-builder.sh -i --disable_mariner_repo
## Disable default setting to use default Azure Linux package repos on packages.microsoft.com
./azurelinux-tutorials/build-in-container/mariner-docker-builder.sh -i --disable_mariner_repo

```

## Details on what goes on inside the container:
### Creating container image
'create-container.sh' creates an image that the docker can use to launch the Mariner build container. It downloads a Mariner2.0 container image, and makes suitable modifications to it. The output image is tagged as 'mcr.microsoft.com/mariner-container-build:2.0'
'create-container.sh' creates an image that the docker can use to launch the Azure Linux build container. It downloads an Azure Linux container image, and makes suitable modifications to it. The output image is tagged as 'mcr.microsoft.com/mariner-container-build:2.0'

### Running container in the specified mode
'run-container.sh' starts a docker container using the image produced in Step(1).

In the _build_ mode, it sets up the Mariner build system inside the container, builds all the specs under $mariner_dir/SPECS/ and outputs to $mariner_dir/out/.
In the _build_ mode, it sets up the Azure Linux build system inside the container, builds all the specs under $mariner_dir/SPECS/ and outputs to $mariner_dir/out/.

In the _interactive_ mode, it sets up the Mariner build system inside the container, and starts the container at /mariner/toolkit/. The user can invoke Mariner `make` commands to build packages, images and more. Please see the [section](README.md#sample-make-commands) for sample `make` commands, and visit [Mariner Docs](https://github.com/microsoft/CBL-Mariner/blob/2.0/toolkit/docs/building/building.md) for the complete set of commands.
In the _interactive_ mode, it sets up the Azure Linux build system inside the container, and starts the container at /mariner/toolkit/. The user can invoke Azure Linux `make` commands to build packages, images and more. Please see the [section](README.md#sample-make-commands) for sample `make` commands, and visit [Azure Linux Docs](https://github.com/microsoft/azurelinux/blob/2.0/toolkit/docs/building/building.md) for the complete set of commands.

### Helper scripts

- 'scripts/setup.sh' installs the required pacakges, downloads the Mariner toolkit from GitHub (if missing), downloads Mariner2.0 toolchain RPMs, and sets up the environment variables required for Mariner builds.
- 'scripts/setup.sh' installs the required pacakges, downloads the Azure Linux toolkit from GitHub (if missing), downloads Azure Linux toolchain RPMs, and sets up the environment variables required for Azure Linux builds.

- 'scripts/build.sh' The build starts with cloning the Mariner GitHub repository, and downloading the toolchain. Using the tools from Mariner toolkit, it reads the spec files under SPECS/, installs the build dependepdencies, builds the specs and packages them into an RPM. Each pacakge is built inside a chroot environment.
- 'scripts/build.sh' The build starts with cloning the Azure Linux GitHub repository, and downloading the toolchain. Using the tools from Azure Linux toolkit, it reads the spec files under SPECS/, installs the build dependepdencies, builds the specs and packages them into an RPM. Each pacakge is built inside a chroot environment.

## Advantages:
- It is convenient and fast for developement environment
- It gives the user an option to build Mariner without having to go into the details of the build system
- It gives the user an option to build Azure Linux without having to go into the details of the build system

## Disadvantages:
- The number of chroots is limited to 12
Expand Down
14 changes: 7 additions & 7 deletions build-in-container/scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,23 @@ SOURCE_URL="https://cblmarinerstorage.blob.core.windows.net/sources/core"
SPECS_DIR="$MARINER_BASE_DIR/SPECS"
USE_CCACHE="y"

# Build Mariner toolkit if not present, by cloning Mariner GitHub repo
# Build Azure Linux toolkit if not present, by cloning Azure Linux GitHub repo
#
# No arguments
# Global variables expected to be defined: BUILD_DIR, CHROOT_DIR, CHROOT_NB, OUT_DIR
download_mariner_toolkit() {
if [ ! "$(ls -A toolkit)" ]; then
echo "------------ Preparing Mariner toolkit ------------"
if [ ! -d CBL-Mariner ]; then
echo "------------ Cloning Mariner toolkit from github ------------"
echo "------------ Preparing Azure Linux toolkit ------------"
if [ ! -d azurelinux ]; then
echo "------------ Cloning Azure Linux toolkit from github ------------"
git clone \
--branch ${MARINER_RELEASE_TAG} \
--depth 1 \
${CBL_MARINER_GIT_URL}
fi
echo "------------ Building Mariner toolkit ------------"
echo "------------ Building Azure Linux toolkit ------------"
make -j$(nproc) \
-C CBL-Mariner/toolkit \
-C azurelinux/toolkit \
package-toolkit \
BUILD_DIR="$BUILD_DIR" \
CHROOT_DIR="$CHROOT_DIR" \
Expand All @@ -54,7 +54,7 @@ download_mariner_toolkit() {
LOG_LEVEL=info \
OUT_DIR="$OUT_DIR" \
REBUILD_TOOLS=y && \
rm -rf CBL-Mariner && \
rm -rf azurelinux && \
tar -xzvf ${OUT_DIR}/toolkit-*.tar.gz
fi
}
Expand Down
Loading