StarlingX build tools
Go to file
Scott Little ae68691bf0 Enable starlingx mirror
StarlingX needs to download a variety of rpms and tarballs
from various upstream sources.  Unfortunately the upstream sources
are not always dependable. Either servers go down, are unreachable,
or drop older content that we still depend on.

Our proposed solution is to run our own mirror to capture an
independent copy of the content needed by StarlingX.
For this purpose, a server has been set up at
http://mirror.starlingx.cengn.ca/mirror/centos

The mirror will use deterministic paths derived from the upstream
urls.  Scripts will be used to convert an upstream url to
the mirror's equivalent url (see function url_to_stx_mirror_url in
url_utils.sh)

The mirror will be refreshed daily.  New .lst entries will be
processed at that time.  Processing of changes under yum.repos.d
is not automated by this update.  Expect a follow-up update to
address this issue soon.  These scripts are found under the
'stx_mirror_scripts' subdirectory.

Changes are made to the download_mirror.sh script, and it's
supporting scripts.  New arguments have been added to each
script to select the download source.
   -s  StarlingX mirror only
   -S  StarlingX mirror, with upstream source as backup
   -u  Upstream source only
   -U  Upstream source, with StarlingX mirror as backup

You do not need to provide any of these flags.  Continue to
us download_mirror.sh as you always have.  The default
behavior is currently set to '-S', i.e. first try the
StarlingX mirror, with upstream source as backup.
If this proves to place to heavy a load on the existing
server, we might switch the default to '-U', i.e. first
try the upstream source, with StarlingX mirror as backup.
If poor download performance is seen, you might want to try
explicitly adding -U as an argument.

The remaining two options are not recommended for regular use.
Upstream only, i.e. '-u', restores original behaviour, but
you may once again encounter rpms that have aged out, and
been removed from their original repos.  StarlingX only,
i.e. '-s', is vulnerable if a .lst file has been updated,
but the mirror has not yet processed it.

Change-Id: I7e0f3d9fb99253662f9f4bf12457d39250408c0b
Story: 2003906
Task: 26785
Signed-off-by: Scott Little <scott.little@windriver.com>
2018-11-02 13:33:00 -04:00
centos-mirror-tools Enable starlingx mirror 2018-11-02 13:33:00 -04:00
deployment Remove working dir issues from deploy scripts 2018-10-09 19:31:21 -05:00
doc [Doc] openstackdocstheme starlingxdocs theme 2018-10-22 14:38:13 +00:00
release Support feature branches in branch-stx.sh 2018-09-04 09:06:18 -05:00
releasenotes [Doc] openstackdocstheme starlingxdocs theme 2018-10-22 14:38:13 +00:00
toCOPY Update populate_downloads to use latest libibverbs 2018-08-21 09:14:00 -04:00
.gitignore Add docs, releasenotes jobs 2018-09-05 19:08:28 -05:00
.gitreview correct gitreview setting for master 2018-09-20 23:26:17 +08:00
.zuul.yaml Add relnotes publish job 2018-10-12 15:13:18 -05:00
DependenciesReviewer.py Add script to verify that repo's SRPMs matches with mirror's SRPMs 2018-07-18 14:23:08 -05:00
Dockerfile Add unified dockerfile 2018-09-13 10:56:11 -05:00
Dockerfile.centos73 hostdata-collectors: Engineering Tools Pip Dependency 2018-09-07 10:39:05 -05:00
Dockerfile.centos73.TC-builder fixing namefile running make build 2018-07-05 11:46:17 -05:00
Makefile Enable multiple docker images per user. 2018-10-05 11:18:11 -05:00
README.rst Port documentation from markdown into rst 2018-07-10 08:36:05 -05:00
buildrc Add build tools 2018-06-08 17:01:43 -05:00
tb.sh Enable multiple docker images per user. 2018-10-05 11:18:11 -05:00
test-requirements.txt Add bashate job nonvotingwq 2018-06-08 17:19:00 -05:00
tox.ini fix tox python3 overrides 2018-10-05 11:01:23 +00:00

README.rst

stx-tools

StarlingX Build Tools

The StarlingX build process is tightly tied to CentOS in a number of ways, doing the build inside a Docker container makes this much easier on other flavors of Linux.

Container Build Preparation

We will use a copy of your existing .gitconfig in the container to pick up existing configuration. The StarlingX build system also has some specific requirements that do not need to be in your personal .gitconfig. Copy it into toCOPY to be picked up in the container build.

cp ~/.gitconfig toCOPY

Configuration

tbuilder uses a two-step configuration process that provides access to certain configuration values both inside and outside the container. This is extremely useful for path variables such as MY_REPO with have different values inside and outside but can be set to point to the same place.

The buildrc file is a shell script that is used to set the default configuration values. It is contained in the tbuilder repo and should not need to be modified by users as it reads a localrc file that will not be overwritten by tbuilder updates. This is where users should alter the default settings.

Sample localrc

# tbuilder localrc

MYUNAME=stx-builder
PROJECT=stx-work
HOST_PREFIX=$HOME/work

Makefile

tbuilder contains a Makefile that can be used to automate the build lifecycle of a container. The commands below are handled by the Makefile and will read the contents of the buildrc file.

The targets commonly used are: * build - build the Docker images as required (This includes dev-centos, to build just the base dev image use target base-build.) * clean - remove the stx-builder image (The dev-centos image is not removed, use base-clean to do that)

Base Container Build

The container build has been split into two parts to simplify iterating on build development. The basic CentOS image and the nearly 500 required development packages are pre-installed into a base image (local/dev-centos:7.3) that is then used for the StarlingX builder-specific bits.

make base-build

will run essentially the following manual build command:

docker build \
    --ulimit core=0 \
    -t local/dev-centos:7.3 \
    -f Dockerfile.centos73 \
    .

STX Builder Container Build

StarlingX Builder container images are tied to your UID so image names should include your username.

make build

NOTE:

  • Do NOT change the UID to be different from the one you have on your host or things will go poorly. i.e. do not change --build-arg MYUID=$(id -u)
  • The Dockerfile needs MYUID and MYUNAME defined, the rest of the configuration is copied in via buildrc/localrc.

Use the Builder Container

The tb.sh script is used to manage the run/stop lifecycle of working containers. Copy it to somewhere on your PATH, say $HOME/bin if you have one, or maybe /usr/local/bin.

The basic workflow is to create a working directory for a particular build, say a specific branch or whatever. Copy the buildrc file from the tbuilder repo to your work directory and create a localrc if you need one. The current working directory is assumed to be this work directory for all tb.sh commands. You switch projects by switching directories.

By default LOCALDISK will be placed under the directory pointed to by HOST_PREFIX, which defaults to $HOME/starlingx.

The tb.sh script uses sub-commands to select the operation: * run - Runs the container in a shell. It will also create LOCALDISK if it does not exist. * stop - Kills the running shell. * exec - Starts a shell inside the container.

You should name your running container with your username. tbuilder does this automatically using the USER environment variable.

tb.sh run will create LOCALDISK if it does not already exist before starting the container.

Set the mirror directory to the shared mirror pointed to by HOST_MIRROR_DIR. The mirror is LARGE, if you are on a shared machine use the shared mirror. For example you could set the default value for HOST_MIRROR_DIR to /home/starlingx/mirror and share it.

Running the Container

Start the builder container:

tb.sh run

or by hand:

docker run -it --rm \
    --name ${TC_CONTAINER_NAME} \
    --detach \
    -v ${LOCALDISK}:${GUEST_LOCALDISK} \
    -v ${HOST_MIRROR_DIR}:/import/mirrors:ro \
    -v /sys/fs/cgroup:/sys/fs/cgroup:ro \
    -v ~/.ssh:/mySSH:ro \
    -e "container=docker" \
    --security-opt seccomp=unconfined \
    ${TC_CONTAINER_TAG}

Running a Shell Inside the Container

Since running the container does not return to a shell prompt the exec into the container must be done from a different shell:

tb.sh exec

or by hand:

docker exec -it --user=${MYUNAME} ${USER}-centos-builder bash

Notes:

  • The above will reusult in a running container in systemd mode. It will have NO login.
  • I tend to use tmux to keep a group of shells related to the build container
  • --user=${USER} is the default username, set MYUNAME in buildrc to change it.

Stop the Container

tb.sh stop

or by hand:

docker kill ${USER}-centos-builder

What to do to build from WITHIN the container

To make git cloning less painful

$ eval $(ssh-agent)
$ ssh-add

To start a fresh source tree

Instructions

Initialize the source tree.

cd $MY_REPO_ROOT_DIR
repo init -u git://git.openstack.org/openstack/stx-manifest.git -m default.xml
repo sync

To generate cgcs-centos-repo

The cgcs-centos-repo is a set of symbolic links to the packages in the mirror and the mock configuration file. It is needed to create these links if this is the first build or the mirror has been updated.

generate-cgcs-centos-repo.sh /import/mirror/CentOS/pike

Where the argument to the script is the path of the mirror.

To build all packages:

$ cd $MY_REPO
$ build-pkgs or build-pkgs --clean <pkglist>; build-pkgs <pkglist>

To generate cgcs-tis-repo:

The cgcs-tis-repo has the dependency information that sequences the build order; To generate or update the information the following command needs to be executed after building modified or new packages.

$ generate-cgcs-tis-repo

To make an iso:

$ build-iso

First time build

The entire project builds as a bootable image which means that the resulting ISO needs the boot files (initrd, vmlinuz, etc) that are also built by this build system. The symptom of this issue is that even if the build is successful, the ISO will be unable to boot.

For more specific instructions on how to solve this issue, please the README on installer folder in stx-beas repository.

WARNING HACK WARNING

  • Due to a lack of full udev support in the current build container, you need to do the following:

    $ cd $MY_REPO
    $ rm build-tools/update-efiboot-image
    $ ln -s /usr/local/bin/update-efiboot-image $MY_REPO/build-tools/update-efiboot-image
  • if you see complaints about udisksctl not being able to setup the loop device or not being able to mount it, you need to make sure the build-tools/update-efiboot-image is linked to the one in /usr/local/bin

Troubleshooting

  • if you see:

    Unit tmp.mount is bound to inactive unit dev-sdi2.device. Stopping, too.
  • it's a docker bug. just kill the container and restart the it using a different name.

    • I usually switch between -centos-builder and -centos-builder2. It's some kind of timeout (bind?) issue.