Project packaging
Introduction
The local builder allows projects to be packaged locally. Here is an example of a simple use of this tool in the case of project packaging.
After following the “getting started for a developer” chapter, you will have at least one project with one application. The application chosen for the example is helloworld-binding.
In case you did not follow those instructions, the only command you need, is to create a project and a helloworld-binding application. ONLY execute this command if you did not before
rp-cli projects add --name "my awesome project" --description "My first project in redpesk CI" --mandatory-distro redpesk-lts-batz-2.0-update --mandatory-arch x86_64 --optional-arch aarch64
Please be sure to have rp-cli installed, configured and connected to a local builder. Refer to local builder installation
$ rp-cli applications list
ID Name Slug Type Project
a3968638-58ae-41bd-9d9f-2e605fdceb87 Helloworld binding helloworld-binding standard my-awesome-project-1
This command shows your application Helloworld binding
in the project described before.
Steps to follow
Initialize the project
In this step, rp-cli retrieves the corresponding application in redpesk UI.
rp-cli local package init helloworld-binding --project my-awesome-project-1
Apply your modifications
- You can work on the spec file in your host here:
~/my_rp_builder_dir/gitpkgs/my-awesome-project-1/helloworld-binding/helloworld-binding.spec
. - You can modify the sources in the sources directory:
~/my_rp_builder_dir/gitsources/my-awesome-project-1/helloworld-binding/
.
Run to do the packaging
Once that you have done your modification, you can build the package locally. Just choose between native and cross packaging by selecting the architecture in the command line as below.
Cross packaging
# If the 'arch' flag is not present, the default target is aarch64
rp-cli local package build helloworld-binding --project my-awesome-project-1 --arch aarch64
Native packaging
rp-cli local package build helloworld-binding --project my-awesome-project-1 --arch x86_64
Upload the new specfile
If the package was correctly built in the previous step, it is possible to upload the spec file in the UI using the following command:
rp-cli local package commit helloworld-binding helloworld-binding.spec
Tips and tricks
If you want to make some changes locally in order to debug the packaging, you can do it like this:
rp-cli local package shell helloworld-binding --project my-awesome-project-1 --arch aarch64
When you are in the mock, you can see that all directories are empty the first time.
<mock-chroot> sh-5.1# ls -R
.:
build
./build:
BUILD BUILDROOT RPMS SOURCES SPECS SRPMS originals
./build/BUILD:
./build/BUILDROOT:
./build/RPMS:
./build/SOURCES:
./build/SPECS:
./build/SRPMS:
./build/originals:
If you’ve launched a build before launching the shell command, you can start building manually inside the mock.
cd build/BUILD/helloworld-binding-1.0.1/
mkdir build && cd build
cmake ..
If everything is correct, you will have something like:
<mock-chroot> sh-4.4# cmake ..
-- The C compiler identification is GNU 8.4.1
-- The CXX compiler identification is GNU 8.4.1
[...]
-- Generating done
-- Build files have been written to: /builddir/build/BUILD/helloworld-binding-1.0.1/build
This is useful when you made some changes locally that you want to test quickly:
<mock-chroot> sh-4.4# make -j
Scanning dependencies of target htdocs
Scanning dependencies of target helloworld-skeleton
Scanning dependencies of target helloworld-subscribe-event
Scanning dependencies of target helloworld-config
Scanning dependencies of target test-files
Scanning dependencies of target prepare_package
Scanning dependencies of target prepare_package_test
Scanning dependencies of target autobuild
Scanning dependencies of target fixture-files
[ 3%] Generating package
[ 7%] Generating htdocs
[...]
[100%] Built target helloworld-binding_build_done
The method above is using the --arch aarch64
option. This means that the package is built for an aarch64 architecture.
However the same process can be followed for an x86_64 target, the only thing to change is the value of the --arch
flag: --arch x86_64
.
It is also possible to install a specific package inside the mock from rp-cli
command line. Indeed, this is impossible from inside since the mock has no internet connection.
To do that, use the --install
flag like in the example below.
# Install jq package in the mock
rp-cli local package build helloworld-binding --project my-awesome-project-1 --target aarch64 --install jq