-
Notifications
You must be signed in to change notification settings - Fork 85
Autobuild3
Autobuild is a distribution packaging toolkit meant to carry out the following functions:
- Definition, therefore identification of source code
- Preparing and patching of source code
- Building of source code
- Quality control of built binaries
- Packaging of built binaries
Autobuild3 is essentially a set of scripts (autobuild
is the only command script useful for invoking a build process) that works to automatically carry out the function listed above, and to simplify build configuration (build scripts in another word) using various pre-designed build routines, named ABTYPE
or Autobuild Build Types. More will be discussed below (extensively).
Autobuild3 is a successor to the original Autobuild used back in 2013 when AOSC OS was initially rebooted as a independent Linux distribution. Unlike Autobuild being a distribution specific and single backend toolkit, Autobuild3 is distribution neutral and supports various backends:
- DPKG, the most "native" backend of all, using
dpkg-deb
and Autobuild variables to control the generation of DPKG control files, and henceforth building the packages. - RPM, using Autobuild variables to generate .spec files, and invoking
rpmbuild
to build RPM packages. - PKGBUILD (coming soon), using Autobuild variables to generate
PKGBUILD
files, using a temporary install root, to providemakepkg
with a fake binary packaging process.
Autobuild3 is provided in the autobuild3
package (AOSC OS), and is provided with BuildKit. However it can be obtained as a Git checkout/snapshot or as a release at the GitHub repository.
As a Git checkout or downloaded source, Autobuild3 can be deployed with executing the following command at the source root, as superuser or root.
./ab3.sh
Autobuild3 is installed at /usr/lib/autobuild3
, and this directory is known to Autobuild3 (and possibly to you) as "$AB"
.
Autobuild3 needs a autobuild/
directory placed in the source root, which in most cases, is its working directory. For example, when building wget-1.17, one will unpack its source code, get into the wget-1.17/
directory, and autobuild/
should be put in the source root.
autobuild/defines
is the core configurations file used by Autobuild3 to read building definitions (obviously) such as package name, version, category/section, dependencies, descriptions, etc. defines
is meant to be a powerful configuration file, and hence supports an extensive amount of control variables. And they will be described below (essential variables are marked with an asterisk, "*" at the end of their descriptions).
Here lists the variables that describes general information of the package.
PKGNAME= expects a string value that defines the name of the package to be built (an underscore must not be used as part of the name string). *
PKGVER= expects a string value that defines the version of the package to be built (an underscore must not be used as part of the version string). *
PKGSEC= expects a string value that defines the category/section that the package belongs in, all canonical section names are defined in "$AB"/sets/section
. A QA (quality assurance) warning will be emitted by Autobuild3 when a non-canonical section is used as the value provided here. *
PKGDES= expects a string value containing the description of the package, basic writing convention is advised (capitalize the first letter, for example). *
Here lists the variables that defines several different dependency relationships that will be carried out by the package. It is recommended that you have a good read of the Debian Policy Manual before you start.
PKGDEP= expects a string value that defines a list of dependencies of the package, separated with spaces.
PKGRECOM= expects a string value that defines a list of recommended (soft dependencies) packages that enhances the functionality of the package, separated with spaces, just like PKGDEP
.
PKGBREAK= expects a string value that defines a list of packages that will be broken (ABI breakage, dependency breakage) by the package or one of its updates, separated with spaces.
PKGCONFL= expects a string value that defines a list of packages that conflicts with the package (file conflict is the main usage of this variable), separated with spaces.
PKGREP= expects a string value that defines a list of packages that are replaced/obsoleted by the package, separated with spaces.
Here lists variables that serves as options during build-time that may alter build results. Some times they are used to workaround FTBFS (fail to build from source, essential vocabulary, Cadet) situations. Workaround-oriented usage of some of the variables listed below will the discussed in the Tips and Tricks section.
AB_FLAGS_PIE= expects a binary value (0/1) that switches compiler and linker flags needed to build PIE (Position Independent Executables), contributing to a hardened binary build (Defaults to 1 or "on").
AB_FLAGS_PIC= expects a binary value (0/1) that switches compiler and linker flags needed to build PIC (Position Independent Code) for both executables and shared objects, contributing to a hardened binary build (Defaults to 1 or "on").
AB_FLAGS_SSP= expects a binary value (0/1) that switches compiler flags needed to enable/disable stack smash protection for shared objects and executables, contributing to a hardened binary build (Defaults to 1 or "on").
AB_FLAGS_FTF= expects a binary value (0/1) that switches code preprocessor (cpp) to fortify source code before compilation, contributing to a hardened binary build (Defaults to 1 or "on").
AB_FLAGS_RRO= expects a binary value (0/1) that switches linker flags needed to link executables and shared objects with read-only relocations, contributing to a hardened binary build (Defaults to 1 or "on").
AB_FLAGS_RRO= expects a binary value (0/1) that switches linker flags needed to link executables and shared objects with full read-only relocations, contributing to a hardened binary build (Defaults to 1 or "on").
NOLTO= expects a binary value (0/1) that switches compiler and linker flags needed to disable/prevent LTO (Link Time Optimization) during build time (Defaults to 1 "on").
USECLANG= expects a binary value (0/1) that decides whether to use Clang (part of LLVM) for the build (Defaults to 0 or "off").
ABSHADOW= expects a binary value (0/1) that decides whether to perform a "shadow build", or building the source from a separate directory (outside the source root), some sources likes it, some not so much (Defaults to 1 or "on").
ABCLEAN= expects a binary value (0/1) that decides whether to perform cleaning before a repeated build (removing packaging root, build directory, source root; defaults to 1 or "on").
ABTHREADS= expects a positive integer that defines the threads to be used when building (used by make; defaults to $(nproc) + 1
, or number of processor cores plus one).
NOPARALLEL= expects a binary value (0/1) that decides whether to disable parallel build (equivalent to ABTHREADS=1
; defaults to 0 or "off").
MAKE_AFTER= expects a string value that defines extra arguments to be passed to make
.
Additional variables can be included inside autobuild/defines
as well, as this file is basically "sourced" by the Unix Shell (Bash in this case).
Autobuild has a set of pre-defined build routine called Build Types, or $ABTYPE
when expressed in the "autobuild/defines" file.
ABTYPE= expects a string value that defines which build type to use. Autobuild3 in most cases can detect the right build type to use. Here below is a list of available build types, in detection fallback order:
-
self: when a
autobuild/build
file is provided, uses user createdautobuild/build
as build script. -
autotools: generally used for GNU autotools-based source trees, with an available
configure
script in source root, or defined$configure
script. -
cmake: used for CMake-based source tree, Autobuild3 detects for
CMakeList.txt
in the source trees. - waf: used for waf-based source tree, Autobuild3 detects for
waf
file/script in the source trees. -
plainmake: used for source trees with a written
Makefile
, and therefore is able to be built withmake
command. - haskell: used for standard Haskell Cabal/Hackage source trees, comes with a set of scripts that provides Haskell package management functions like registering and unregistering.
- perl: used for standard CPAN source trees.
- python: used for standard PyPI source trees.
-
qtproj: used for Qt projects with
.pro
files in the source trees. - ruby: used for RubyGems source trees.
Usually it is not necessary to define $ABTYPE
, Autobuild can detect this variable automatically. However, some source trees, like kdelibs
comes with both a configure
script and a CMakeList.txt
file in its source tree, in this case, Autobuild will choose autotools
over cmake
as its build type, while cmake
is the valid build type for this source tree.
In such cases, define $ABTYPE
in autobuild/defines
.
Here below is a list of variables available for different $ABTYPE
.
Here below is a list of variables available when using the autotools
build type.
RECONF= expects a binary value (0/1) that decides whether to re-generate the configure
script, this is useful when changes are made to GNU autotools configuration files, like configure.ac
.
AUTOTOOLS_DEF= expects a string value containing default arguments to be passed to configure
, default is defined in "$AB"/etc/autobuild/ab3_defcfg.sh
.
AUTOTOOLS_AFTER= expects a string value containing all extra arguments to be passed to configure
, you may override any arguments defined in $AUTOTOOLS_DEF
using this variable.
Here below is a list of variables available when using the cmake
build type.
CMAKE_DEF= expects a string value containing default arguments to be passed to cmake
, default is defined in "$AB"/etc/autobuild/ab3_defcfg.sh
.
CMAKE_AFTER= expects a string value containing all extra arguments to be passed to cmake
, you may override any arguments defined in $CMAKE_DEF
using this variable.
Here below is a list of variables available when using the waf
build type.
WAF_DEF= expects a string value containing default arguments to be passed to waf
, default is defined in "$AB"/etc/autobuild/ab3_defcfg.sh
.
WAF_AFTER= expects a string value containing all extra arguments to be passed to waf
, you may override any arguments defined in $wAF_DEF
using this variable.
Here below is a list of variables available when using the python
build type.
NOPYTHON2= expects a binary value (0/1) deciding on whether not to build modules for Python 2.
NOPYTHON3= expects a binary value (0/1) deciding on whether not to build modules for Python 3.
Both variables default to 0 or "no", meaning modules will be built for both Python 2 and Python 3.
Here below is a list of variables available when using the qtproj
build type.
QT_SELECT= is used by qtchooser
to decide which Qt version to use. (4/5/default) defines to use Qt 4, Qt 5, or default (defined in /etc/xdg/qtchooser/default.conf), respectively.
QTPROJ_DEF= expects a string value containing default arguments to be passed to qmake
, default is defined in "$AB"/etc/autobuild/ab3_defcfg.sh
.
QTPROJ_AFTER= expects a string value containing all extra arguments to be passed to qmake
, you may override any arguments defined in $CMAKE_DEF
using this variable.