while getopts "t:d:j:cpSnDRuamh" opt; do
case $opt in
t) BUILD_TYPE="$OPTARG" ;;
d) OS="$OPTARG" ;;
j) CPUS="$OPTARG" ;;
c) CI_MODE=true ;;
p) BUILD_PACKAGES=true ;;
S) START_MDB=true ;;
n) NO_CLEAN=true ;;
D) INSTALL_DEPS=true ;;
R) GCC_TOOLSET=true ;;
u) UNIT_TESTS=true ;;
a) WITH_ASAN=true ;;
m) WITH_MSAN=true ;;
h) usage ;;
*) usage ;;
esac done
if [[ ! " ${BUILD_TYPE_OPTIONS[*]} " =~ " ${BUILD_TYPE} " ]]; then
menu_choice "Select build type:" BUILD_TYPE_OPTIONS
BUILD_TYPE="$MENU_RESULT" fi
detect_distro() { if [ -f /etc/os-release ]; then
. /etc/os-release
local os_name=$(echo"$NAME" | cut -f1 -d" " | tr '[:upper:]''[:lower:]')
OS="${os_name}:${VERSION_ID}" elif [ -f /etc/lsb-release ]; then
. /etc/lsb-release
OS=$(echo"$DISTRIB_ID" | tr '[:upper:]''[:lower:]'):"$DISTRIB_RELEASE" else
fail "Cannot detect distro, specify with -d" fi
info "Detected distro: ${_CLR_YELLOW}$OS"
}
select_pkg_format() { if [[ "$1" == *rocky* ]]; then
PKG_FORMAT="rpm" else
PKG_FORMAT="deb" fi
}
if [[ $BUILD_PACKAGES = true ]]; then if [[ ! " ${DISTRO_OPTIONS[*]} " =~ " ${OS} " ]]; then if [[ -z "$OS" ]]; then
warn "Distro not specified, detecting..."
detect_distro fi if [[ ! " ${DISTRO_OPTIONS[*]} " =~ " ${OS} " ]]; then
menu_choice "Select distro:" DISTRO_OPTIONS
OS="$MENU_RESULT" fi fi
select_pkg_format "$OS" fi
header "DuckDB Storage Engine Build"
info "Source: ${_CLR_YELLOW}$MDB_SOURCE_PATH"
info "Build dir: ${_CLR_YELLOW}$BUILD_PATH"
info "Build type: ${_CLR_YELLOW}$BUILD_TYPE"
info "Jobs: ${_CLR_YELLOW}$CPUS"
info "ASAN/UBSAN: ${_CLR_YELLOW}$WITH_ASAN"
info "MSAN: ${_CLR_YELLOW}$WITH_MSAN"
info "Unit tests: ${_CLR_YELLOW}$UNIT_TESTS" if [[ $BUILD_PACKAGES = true ]]; then
info "Packages: ${_CLR_YELLOW}$PKG_FORMAT ($OS)" fi echo""
check_user_and_group() {
local user=$1 if [ -z "$(grep "$user" /etc/passwd)" ]; then
info "Adding user $user"
useradd -r -U "$user" -d /var/lib/mysql fi if [ -z "$(grep "$user" /etc/group)" ]; then
local gid=$(awk -F: '{uid[$3]=1}END{for(x=100; x<=999; x++) {if(uid[x] != ""){}else{print x; exit;}}}' /etc/group)
info "Adding group $user with id $gid"
groupadd -g "$gid""$user" fi
}
clean_old_installation() { if [[ $NO_CLEAN = true ]]; then
return fi rm -rf "${DEFAULT_MDB_DATADIR}" rm -rf /var/run/mysqld
}
local max_attempts=30
local attempt=0 while ! "$INSTALL_PREFIX/bin/mariadb-admin" ping --silent 2>/dev/null; do
attempt=$((attempt + 1)) if [[ $attempt -ge $max_attempts ]]; then
local err_log="${DEFAULT_MDB_DATADIR}/$(hostname).err" if [[ -f "$err_log" ]]; then
error "Last 50 lines of $err_log:"
tail -50"$err_log" fi
fail "MariaDB failed to start within ${max_attempts} seconds" fi
sleep 1 done
success "MariaDB is ready"
}
setup_dev_user() {
local current_user=$(logname 2>/dev/null || echo"$SUDO_USER") if [[ -n "$current_user" && "$current_user" != "root" ]]; then
info "Creating dev user '${_CLR_YELLOW}$current_user${_CLR_CYAN}'" "$INSTALL_PREFIX/bin/mariadb" -e \ "CREATE USER IF NOT EXISTS '$current_user'@'localhost' IDENTIFIED VIA unix_socket;
GRANT ALL PRIVILEGES ON *.* TO '$current_user'@'localhost';" fi
}
create_config() { # Put config in /etc/my.cnf.d/ which is included by /etc/my.cnf
mkdir -p /etc/my.cnf.d cp"$DUCKDB_SOURCE_PATH/duckdb.cnf" /etc/my.cnf.d/duckdb.cnf
}
if [[ "$BUILD_TYPE" == "Debug" ]]; then
MDB_CMAKE_FLAGS+=(-DDUCKDB_WERROR=ON) fi
if [[ $UNIT_TESTS = true ]]; then
MDB_CMAKE_FLAGS+=(-DDUCKDB_UNIT_TESTS=ON) fi
if [[ $WITH_ASAN = true ]]; then
MDB_CMAKE_FLAGS+=(
-DWITH_ASAN=ON
-DWITH_ASAN_SCOPE=ON
-DWITH_UBSAN=ON
-DWITH_UNIT_TESTS=OFF
) fi
if [[ $WITH_MSAN = true ]]; then
MDB_CMAKE_FLAGS+=(
-DWITH_MSAN=ON
-DWITH_UNIT_TESTS=OFF
) fi
if [[ $BUILD_PACKAGES = true ]]; then if [[ "$PKG_FORMAT" == "rpm" ]]; then
local os_version=${OS//[^0-9]/} if [[ "$OS" == *rocky* ]]; then
MDB_CMAKE_FLAGS+=(-DRPM=rockylinux${os_version}) fi else
local codename=""
case "$OS" in
debian:12*) codename="bookworm" ;;
debian:13*) codename="trixie" ;;
ubuntu:22.04) codename="jammy" ;;
ubuntu:24.04) codename="noble" ;;
*) fail "Unknown DEB codename for $OS" ;;
esac
MDB_CMAKE_FLAGS+=(-DDEB=${codename} -DINSTALL_LAYOUT=DEB) fi else
MDB_CMAKE_FLAGS+=(-DDEB=noble -DINSTALL_LAYOUT=DEB) fi
}
install_deps() { if [[ $INSTALL_DEPS = false ]]; then
return fi
if [[ -z "$OS" ]]; then
detect_distro fi
local SUDO="" if [[ $EUID -ne 0 ]]; then
SUDO="sudo" fi
# rpm-build is only needed to build RPM packages; on some bases (e.g. UBI 9) # installing it forces an rpm upgrade that conflicts with pinned @System rpm. if [[ $BUILD_PACKAGES = true ]]; then
RPM_DEPS="$RPM_DEPS rpm-build" fi
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.