From e46334f479c7564818a7126d10c3dbd588aef8d4 Mon Sep 17 00:00:00 2001 From: Takeshi Nakatani Date: Wed, 15 Feb 2023 11:02:54 +0900 Subject: [PATCH] Changed CI OSs and added Alpine OS --- .github/workflows/build_helper.sh | 91 +++-- .github/workflows/ci.yml | 34 +- .github/workflows/ostypevars.sh | 146 ++++---- buildutils/APKBUILD.templ.in | 127 +++++++ buildutils/alpine_build.sh | 505 ++++++++++++++++++++++++++++ buildutils/control.in | 2 +- buildutils/debian_build.sh | 29 +- buildutils/k2hdkc-dbaas-cli.spec.in | 2 +- configure.ac | 3 +- test/test.sh | 12 - 10 files changed, 819 insertions(+), 132 deletions(-) create mode 100644 buildutils/APKBUILD.templ.in create mode 100755 buildutils/alpine_build.sh diff --git a/.github/workflows/build_helper.sh b/.github/workflows/build_helper.sh index 3802136..a3221f1 100755 --- a/.github/workflows/build_helper.sh +++ b/.github/workflows/build_helper.sh @@ -51,7 +51,7 @@ fi PRGNAME=$(basename "$0") SCRIPTDIR=$(dirname "$0") SCRIPTDIR=$(cd "${SCRIPTDIR}" || exit 1; pwd) -SRCTOP=$(cd "${SCRIPTDIR}"/.. || exit 1; pwd) +SRCTOP=$(cd "${SCRIPTDIR}"/../.. || exit 1; pwd) # # Message variables @@ -71,7 +71,7 @@ CI_FORCE_PUBLISH="" CI_USE_PACKAGECLOUD_REPO=1 CI_PACKAGECLOUD_TOKEN="" CI_PACKAGECLOUD_OWNER="antpickax" -CI_PACKAGECLOUD_PUBLISH_REPO="current" +CI_PACKAGECLOUD_PUBLISH_REPO="stable" CI_PACKAGECLOUD_DOWNLOAD_REPO="stable" CI_IN_SCHEDULE_PROCESS=0 @@ -749,7 +749,7 @@ MAKE_TEST_OPT_OTHER="check" CREATE_PACKAGE_TOOL_RPM="buildutils/rpm_build.sh" CREATE_PACKAGE_TOOL_DEBIAN="buildutils/debian_build.sh" -CREATE_PACKAGE_TOOL_ALPINE="buildutils/apline_build.sh" +CREATE_PACKAGE_TOOL_ALPINE="buildutils/alpine_build.sh" CREATE_PACKAGE_TOOL_OTHER="" CREATE_PACKAGE_TOOL_OPT_AUTO="-y" @@ -932,8 +932,14 @@ echo " IS_OS_CENTOS = ${IS_OS_CENTOS}" echo " IS_OS_FEDORA = ${IS_OS_FEDORA}" echo " IS_OS_ROCKY = ${IS_OS_ROCKY}" echo " IS_OS_ALPINE = ${IS_OS_ALPINE}" -echo " INSTALLER_BIN = ${INSTALLER_BIN}" echo " INSTALL_PKG_LIST = ${INSTALL_PKG_LIST}" +echo " INSTALLER_BIN = ${INSTALLER_BIN}" +echo " UPDATE_CMD = ${UPDATE_CMD}" +echo " UPDATE_CMD_ARG = ${UPDATE_CMD_ARG}" +echo " INSTALL_CMD = ${INSTALL_CMD}" +echo " INSTALL_CMD_ARG = ${INSTALL_CMD_ARG}" +echo " INSTALL_AUTO_ARG = ${INSTALL_AUTO_ARG}" +echo " INSTALL_QUIET_ARG = ${INSTALL_QUIET_ARG}" echo " PKG_OUTPUT_DIR = ${PKG_OUTPUT_DIR}" echo " PKG_EXT = ${PKG_EXT}" echo " DEBEMAIL = ${DEBEMAIL}" @@ -958,7 +964,7 @@ PRNTITLE "Update repository and Install curl" # Update local packages # PRNINFO "Update local packages" -if ({ RUNCMD "${INSTALLER_BIN}" update -y "${INSTALL_QUIET_ARG}" || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then +if ({ RUNCMD "${INSTALLER_BIN}" "${UPDATE_CMD}" "${UPDATE_CMD_ARG}" "${INSTALL_AUTO_ARG}" "${INSTALL_QUIET_ARG}" || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then PRNERR "Failed to update local packages" exit 1 fi @@ -968,7 +974,7 @@ fi # if ! CURLCMD=$(command -v curl); then PRNINFO "Install curl command" - if ({ RUNCMD "${INSTALLER_BIN}" install -y "${INSTALL_QUIET_ARG}" curl || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then + if ({ RUNCMD "${INSTALLER_BIN}" "${INSTALL_CMD}" "${INSTALL_CMD_ARG}" "${INSTALL_AUTO_ARG}" "${INSTALL_QUIET_ARG}" curl || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then PRNERR "Failed to install curl command" exit 1 fi @@ -992,19 +998,25 @@ if [ "${CI_USE_PACKAGECLOUD_REPO}" -eq 1 ]; then # if [ "${IS_OS_CENTOS}" -eq 1 ] || [ "${IS_OS_FEDORA}" -eq 1 ] || [ "${IS_OS_ROCKY}" -eq 1 ]; then PC_REPO_ADD_SH="script.rpm.sh" + PC_REPO_ADD_SH_RUN="bash" elif [ "${IS_OS_UBUNTU}" -eq 1 ] || [ "${IS_OS_DEBIAN}" -eq 1 ]; then PC_REPO_ADD_SH="script.deb.sh" + PC_REPO_ADD_SH_RUN="bash" + elif [ "${IS_OS_ALPINE}" -eq 1 ]; then + PC_REPO_ADD_SH="script.alpine.sh" + PC_REPO_ADD_SH_RUN="sh" else PC_REPO_ADD_SH="" + PC_REPO_ADD_SH_RUN="" fi if [ -n "${PC_REPO_ADD_SH}" ]; then PRNINFO "Download script and setup packagecloud.io reposiory" - if ({ RUNCMD "${CURLCMD} -s https://packagecloud.io/install/repositories/${CI_PACKAGECLOUD_OWNER}/${CI_PACKAGECLOUD_DOWNLOAD_REPO}/${PC_REPO_ADD_SH} | bash" || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then + if ({ RUNCMD "${CURLCMD} -s https://packagecloud.io/install/repositories/${CI_PACKAGECLOUD_OWNER}/${CI_PACKAGECLOUD_DOWNLOAD_REPO}/${PC_REPO_ADD_SH} | ${PC_REPO_ADD_SH_RUN}" || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then PRNERR "Failed to download script or setup packagecloud.io reposiory" exit 1 fi else - PRNWARN "OS is not debian/ubuntu nor centos/fedora/rocky, then we do not know which download script use. Thus skip to setup packagecloud.io repository." + PRNWARN "OS is not debian/ubuntu nor centos/fedora/rocky nor alpine, then we do not know which download script use. Thus skip to setup packagecloud.io repository." fi else PRNINFO "Not set packagecloud.io repository." @@ -1018,7 +1030,7 @@ PRNTITLE "Install packages for building/packaging" if [ -n "${INSTALL_PKG_LIST}" ]; then PRNINFO "Install packages" - if ({ RUNCMD "${INSTALLER_BIN}" install -y "${INSTALL_QUIET_ARG}" "${INSTALL_PKG_LIST}" || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then + if ({ RUNCMD "${INSTALLER_BIN}" "${INSTALL_CMD}" "${INSTALL_CMD_ARG}" "${INSTALL_AUTO_ARG}" "${INSTALL_QUIET_ARG}" "${INSTALL_PKG_LIST}" || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then PRNERR "Failed to install packages" exit 1 fi @@ -1036,6 +1048,7 @@ PRNTITLE "Install published tools for uploading packages to packagecloud.io" if [ "${CI_DO_PUBLISH}" -eq 1 ]; then PRNINFO "Install published tools for uploading packages to packagecloud.io" GEM_BIN="gem" + GEM_INSTALL_CMD="install" if [ "${IS_OS_CENTOS}" -eq 1 ] && echo "${CI_OSTYPE}" | sed -e 's#:##g' | grep -q -i -e 'centos7' -e 'centos6'; then # @@ -1043,25 +1056,35 @@ if [ "${CI_DO_PUBLISH}" -eq 1 ]; then # PRNWARN "OS is CentOS 7(6), so install ruby by special means(SCL)." - if ({ RUNCMD "${INSTALLER_BIN}" install -y "${INSTALL_QUIET_ARG}" centos-release-scl || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then + if ({ RUNCMD "${INSTALLER_BIN}" "${INSTALL_CMD}" "${INSTALL_CMD_ARG}" "${INSTALL_AUTO_ARG}" "${INSTALL_QUIET_ARG}" centos-release-scl || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then PRNERR "Failed to install SCL packages" exit 1 fi - if ({ RUNCMD "${INSTALLER_BIN}" install -y "${INSTALL_QUIET_ARG}" rh-ruby24 rh-ruby24-ruby-devel rh-ruby24-rubygem-rake || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then + if ({ RUNCMD "${INSTALLER_BIN}" "${INSTALL_CMD}" "${INSTALL_CMD_ARG}" "${INSTALL_AUTO_ARG}" "${INSTALL_QUIET_ARG}" rh-ruby24 rh-ruby24-ruby-devel rh-ruby24-rubygem-rake || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then PRNERR "Failed to install ruby packages" exit 1 fi . /opt/rh/rh-ruby24/enable - if ({ RUNCMD "${GEM_BIN}" install package_cloud || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then + if ({ RUNCMD "${GEM_BIN}" "${GEM_INSTALL_CMD}" package_cloud || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then PRNERR "Failed to install packagecloud.io upload tools" exit 1 fi + + elif [ "${IS_OS_ALPINE}" -eq 1 ]; then + # + # Case for Alpine + # + if ({ RUNCMD "${GEM_BIN}" "${GEM_INSTALL_CMD}" package_cloud || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then + PRNERR "Failed to install packagecloud.io upload tools" + exit 1 + fi + else # # Case for other than CentOS # - if ({ RUNCMD "${GEM_BIN}" install rake package_cloud || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then + if ({ RUNCMD "${GEM_BIN}" "${GEM_INSTALL_CMD}" rake package_cloud || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then PRNERR "Failed to install packagecloud.io upload tools" exit 1 fi @@ -1084,7 +1107,7 @@ if [ "${RUN_CPPCHECK}" -eq 1 ]; then # # CentOS # - if ({ RUNCMD "${INSTALLER_BIN}" install -y epel-release || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then + if ({ RUNCMD "${INSTALLER_BIN}" "${INSTALL_CMD}" "${INSTALL_CMD_ARG}" "${INSTALL_AUTO_ARG}" epel-release || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then PRNERR "Failed to install epel repository" exit 1 fi @@ -1092,7 +1115,7 @@ if [ "${RUN_CPPCHECK}" -eq 1 ]; then PRNERR "Failed to disable epel repository" exit 1 fi - if ({ RUNCMD "${INSTALLER_BIN}" --enablerepo=epel install -y cppcheck || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then + if ({ RUNCMD "${INSTALLER_BIN}" --enablerepo=epel "${INSTALL_CMD}" "${INSTALL_CMD_ARG}" "${INSTALL_AUTO_ARG}" cppcheck || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then PRNERR "Failed to install cppcheck from epel repository" exit 1 fi @@ -1102,7 +1125,7 @@ if [ "${RUN_CPPCHECK}" -eq 1 ]; then # # Fedora # - if ({ RUNCMD "${INSTALLER_BIN}" install -y cppcheck || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then + if ({ RUNCMD "${INSTALLER_BIN}" "${INSTALL_CMD}" "${INSTALL_CMD_ARG}" "${INSTALL_AUTO_ARG}" cppcheck || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then PRNERR "Failed to install cppcheck" exit 1 fi @@ -1112,7 +1135,7 @@ if [ "${RUN_CPPCHECK}" -eq 1 ]; then # # Rocky 8 # - if ({ RUNCMD "${INSTALLER_BIN}" install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then + if ({ RUNCMD "${INSTALLER_BIN}" "${INSTALL_CMD}" "${INSTALL_CMD_ARG}" "${INSTALL_AUTO_ARG}" https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then PRNERR "Failed to install epel repository" exit 1 fi @@ -1128,7 +1151,7 @@ if [ "${RUN_CPPCHECK}" -eq 1 ]; then # # Rocky 9 or later # - if ({ RUNCMD "${INSTALLER_BIN}" install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then + if ({ RUNCMD "${INSTALLER_BIN}" "${INSTALL_CMD}" "${INSTALL_CMD_ARG}" "${INSTALL_AUTO_ARG}" https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then PRNERR "Failed to install epel repository" exit 1 fi @@ -1137,7 +1160,7 @@ if [ "${RUN_CPPCHECK}" -eq 1 ]; then exit 1 fi fi - if ({ RUNCMD "${INSTALLER_BIN}" install -y cppcheck || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then + if ({ RUNCMD "${INSTALLER_BIN}" "${INSTALL_CMD}" "${INSTALL_CMD_ARG}" "${INSTALL_AUTO_ARG}" cppcheck || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then PRNERR "Failed to install cppcheck" exit 1 fi @@ -1147,7 +1170,16 @@ if [ "${RUN_CPPCHECK}" -eq 1 ]; then # # Ubuntu or Debian # - if ({ RUNCMD "${INSTALLER_BIN}" install -y cppcheck || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then + if ({ RUNCMD "${INSTALLER_BIN}" "${INSTALL_CMD}" "${INSTALL_CMD_ARG}" "${INSTALL_AUTO_ARG}" cppcheck || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then + PRNERR "Failed to install cppcheck" + exit 1 + fi + + elif [ "${IS_OS_ALPINE}" -eq 1 ]; then + # + # Alpine + # + if ({ RUNCMD "${INSTALLER_BIN}" "${INSTALL_CMD}" "${INSTALL_CMD_ARG}" "${INSTALL_AUTO_ARG}" cppcheck || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then PRNERR "Failed to install cppcheck" exit 1 fi @@ -1173,7 +1205,7 @@ if [ "${RUN_SHELLCHECK}" -eq 1 ]; then # CentOS # if [ "${IS_SET_ANOTHER_REPOSITORIES}" -eq 0 ]; then - if ({ RUNCMD "${INSTALLER_BIN}" install -y epel-release || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then + if ({ RUNCMD "${INSTALLER_BIN}" "${INSTALL_CMD}" "${INSTALL_CMD_ARG}" "${INSTALL_AUTO_ARG}" epel-release || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then PRNERR "Failed to install epel repository" exit 1 fi @@ -1183,7 +1215,7 @@ if [ "${RUN_SHELLCHECK}" -eq 1 ]; then fi IS_SET_ANOTHER_REPOSITORIES=1 fi - if ({ RUNCMD "${INSTALLER_BIN}" --enablerepo=epel install -y ShellCheck || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then + if ({ RUNCMD "${INSTALLER_BIN}" --enablerepo=epel "${INSTALL_CMD}" "${INSTALL_CMD_ARG}" "${INSTALL_AUTO_ARG}" ShellCheck || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then PRNERR "Failed to install ShellCheck from epel repository" exit 1 fi @@ -1192,7 +1224,7 @@ if [ "${RUN_SHELLCHECK}" -eq 1 ]; then # # Fedora # - if ({ RUNCMD "${INSTALLER_BIN}" install -y ShellCheck || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then + if ({ RUNCMD "${INSTALLER_BIN}" "${INSTALL_CMD}" "${INSTALL_CMD_ARG}" "${INSTALL_AUTO_ARG}" ShellCheck || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then PRNERR "Failed to install cppcheck" exit 1 fi @@ -1201,7 +1233,7 @@ if [ "${RUN_SHELLCHECK}" -eq 1 ]; then # # Rocky # - if ! LATEST_SHELLCHECK_DOWNLOAD_URL=$("${CURLCMD}" -s -S https://api.github.com/repos/koalaman/shellcheck/releases/latest | grep '"browser_download_url"' | grep 'linux.x86_64' | sed -e 's|"||g' -e 's|^.*browser_download_url:[[:space:]]*||g' | tr -d '\n'); then + if ! LATEST_SHELLCHECK_DOWNLOAD_URL=$("${CURLCMD}" -s -S https://api.github.com/repos/koalaman/shellcheck/releases/latest | grep '"browser_download_url"' | grep 'linux.x86_64' | sed -e 's|"||g' -e 's|^.*browser_download_url:[[:space:]]*||g' -e 's|^[[:space:]]*||g' -e 's|[[:space:]]*$||g' | tr -d '\n'); then PRNERR "Failed to get shellcheck download url path" exit 1 fi @@ -1219,7 +1251,16 @@ if [ "${RUN_SHELLCHECK}" -eq 1 ]; then # # Ubuntu or Debian # - if ({ RUNCMD "${INSTALLER_BIN}" install -y shellcheck || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then + if ({ RUNCMD "${INSTALLER_BIN}" "${INSTALL_CMD}" "${INSTALL_CMD_ARG}" "${INSTALL_AUTO_ARG}" shellcheck || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then + PRNERR "Failed to install cppcheck" + exit 1 + fi + + elif [ "${IS_OS_ALPINE}" -eq 1 ]; then + # + # Alpine + # + if ({ RUNCMD "${INSTALLER_BIN}" "${INSTALL_CMD}" "${INSTALL_CMD_ARG}" "${INSTALL_AUTO_ARG}" shellcheck || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then PRNERR "Failed to install cppcheck" exit 1 fi diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a9483e4..e26f482 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,33 +54,19 @@ jobs: # # matrix for containers # - # [NOTICE] - # The current matrix(OS) will be used until launching a new version - # is created, including the OS that will end support soon. - # The new version will support the following OS, and these OS list - # will replace current matrix. - # ubuntu:jammy - # ubuntu:focal - # ubuntu:bionic - # debian:bullseye - # debian:buster - # centos:centos7 - # rockylinux:9 - # rockylinux:8 - # fedora:36 - # fedora:35 - # matrix: container: + - ubuntu:22.04 - ubuntu:20.04 - ubuntu:18.04 - - ubuntu:16.04 + - debian:bullseye - debian:buster - - debian:stretch - centos:centos7 - - fedora:32 - - fedora:31 - - fedora:30 + - rockylinux:9 + - rockylinux:8 + - fedora:37 + - fedora:36 + - alpine:3.17 container: image: ${{ matrix.container }} @@ -108,9 +94,9 @@ jobs: # FORCE_PUBLISH : true means force to publish packages, false means never publish # USE_PACKAGECLOUD_REPO : true means using pacakgecloud.io repo, false is not using # * PACKAGECLOUD_TOKEN : The token for publishing to packagcloud.io - # PACKAGECLOUD_OWNER : owner name as a pat of path to packagcloud.io for publishing/downloading - # PACKAGECLOUD_PUBLISH_REPO : repo name as a pat of path to packagcloud.io for publishing - # PACKAGECLOUD_DOWNLOAD_REPO : repo name as a pat of path to packagcloud.io for downloading + # PACKAGECLOUD_OWNER : owner name as a part of path to packagcloud.io for publishing/downloading + # PACKAGECLOUD_PUBLISH_REPO : repo name as a part of path to packagcloud.io for publishing + # PACKAGECLOUD_DOWNLOAD_REPO : repo name as a part of path to packagcloud.io for downloading # # "PACKAGECLOUD_TOKEN" is a required variable to publish the # package. diff --git a/.github/workflows/ostypevars.sh b/.github/workflows/ostypevars.sh index 9411c75..2619b41 100644 --- a/.github/workflows/ostypevars.sh +++ b/.github/workflows/ostypevars.sh @@ -35,6 +35,12 @@ # packaging # CONFIGURE_EXT_OPT : Options to specify when running configure # INSTALLER_BIN : Package management command +# UPDATE_CMD : Update sub command for package management command +# UPDATE_CMD_ARG : Update sub command arguments for package management command +# INSTALL_CMD : Install sub command for package management command +# INSTALL_CMD_ARG : Install sub command arguments for package management command +# INSTALL_AUTO_ARG : No interaption arguments for package management command +# INSTALL_QUIET_ARG : Quiet arguments for package management command # PKG_OUTPUT_DIR : Set the directory path where the package will # be created relative to the top directory of the # source @@ -59,6 +65,12 @@ DIST_TAG="" INSTALL_PKG_LIST="" CONFIGURE_EXT_OPT="" INSTALLER_BIN="" +UPDATE_CMD="" +UPDATE_CMD_ARG="" +INSTALL_CMD="" +INSTALL_CMD_ARG="" +INSTALL_AUTO_ARG="" +INSTALL_QUIET_ARG="" PKG_OUTPUT_DIR="" PKG_EXT="" @@ -81,6 +93,11 @@ elif [ "${CI_OSTYPE}" = "ubuntu:22.04" ] || [ "${CI_OSTYPE}" = "ubuntu:jammy" ]; DIST_TAG="ubuntu/jammy" INSTALL_PKG_LIST="git autoconf autotools-dev make dh-make fakeroot dpkg-dev devscripts pkg-config ruby-dev rubygems rubygems-integration procps" INSTALLER_BIN="apt-get" + UPDATE_CMD="update" + UPDATE_CMD_ARG="" + INSTALL_CMD="install" + INSTALL_CMD_ARG="" + INSTALL_AUTO_ARG="-y" INSTALL_QUIET_ARG="-qq" PKG_OUTPUT_DIR="debian_build" PKG_EXT="deb" @@ -90,6 +107,11 @@ elif [ "${CI_OSTYPE}" = "ubuntu:20.04" ] || [ "${CI_OSTYPE}" = "ubuntu:focal" ]; DIST_TAG="ubuntu/focal" INSTALL_PKG_LIST="git autoconf autotools-dev make dh-make fakeroot dpkg-dev devscripts pkg-config ruby-dev rubygems rubygems-integration procps" INSTALLER_BIN="apt-get" + UPDATE_CMD="update" + UPDATE_CMD_ARG="" + INSTALL_CMD="install" + INSTALL_CMD_ARG="" + INSTALL_AUTO_ARG="-y" INSTALL_QUIET_ARG="-qq" PKG_OUTPUT_DIR="debian_build" PKG_EXT="deb" @@ -99,6 +121,11 @@ elif [ "${CI_OSTYPE}" = "ubuntu:18.04" ] || [ "${CI_OSTYPE}" = "ubuntu:bionic" ] DIST_TAG="ubuntu/bionic" INSTALL_PKG_LIST="git autoconf autotools-dev make dh-make fakeroot dpkg-dev devscripts pkg-config ruby-dev rubygems rubygems-integration procps" INSTALLER_BIN="apt-get" + UPDATE_CMD="update" + UPDATE_CMD_ARG="" + INSTALL_CMD="install" + INSTALL_CMD_ARG="" + INSTALL_AUTO_ARG="-y" INSTALL_QUIET_ARG="-qq" PKG_OUTPUT_DIR="debian_build" PKG_EXT="deb" @@ -108,6 +135,11 @@ elif [ "${CI_OSTYPE}" = "debian:11" ] || [ "${CI_OSTYPE}" = "debian:bullseye" ]; DIST_TAG="debian/bullseye" INSTALL_PKG_LIST="git autoconf autotools-dev make dh-make fakeroot dpkg-dev devscripts pkg-config ruby-dev rubygems rubygems-integration procps" INSTALLER_BIN="apt-get" + UPDATE_CMD="update" + UPDATE_CMD_ARG="" + INSTALL_CMD="install" + INSTALL_CMD_ARG="" + INSTALL_AUTO_ARG="-y" INSTALL_QUIET_ARG="-qq" PKG_OUTPUT_DIR="debian_build" PKG_EXT="deb" @@ -117,6 +149,11 @@ elif [ "${CI_OSTYPE}" = "debian:10" ] || [ "${CI_OSTYPE}" = "debian:buster" ]; t DIST_TAG="debian/buster" INSTALL_PKG_LIST="git autoconf autotools-dev make dh-make fakeroot dpkg-dev devscripts pkg-config ruby-dev rubygems rubygems-integration procps" INSTALLER_BIN="apt-get" + UPDATE_CMD="update" + UPDATE_CMD_ARG="" + INSTALL_CMD="install" + INSTALL_CMD_ARG="" + INSTALL_AUTO_ARG="-y" INSTALL_QUIET_ARG="-qq" PKG_OUTPUT_DIR="debian_build" PKG_EXT="deb" @@ -126,6 +163,11 @@ elif [ "${CI_OSTYPE}" = "rockylinux:9.0" ] || [ "${CI_OSTYPE}" = "rockylinux:9" DIST_TAG="el/9" INSTALL_PKG_LIST="git autoconf automake gcc-c++ make pkgconfig redhat-rpm-config rpm-build ruby-devel rubygems procps" INSTALLER_BIN="dnf" + UPDATE_CMD="update" + UPDATE_CMD_ARG="" + INSTALL_CMD="install" + INSTALL_CMD_ARG="" + INSTALL_AUTO_ARG="-y" INSTALL_QUIET_ARG="-q" PKG_OUTPUT_DIR="." PKG_EXT="rpm" @@ -135,6 +177,11 @@ elif [ "${CI_OSTYPE}" = "rockylinux:8.6" ] || [ "${CI_OSTYPE}" = "rockylinux:8" DIST_TAG="el/8" INSTALL_PKG_LIST="git autoconf automake gcc-c++ make pkgconfig redhat-rpm-config rpm-build ruby-devel rubygems procps" INSTALLER_BIN="dnf" + UPDATE_CMD="update" + UPDATE_CMD_ARG="" + INSTALL_CMD="install" + INSTALL_CMD_ARG="" + INSTALL_AUTO_ARG="-y" INSTALL_QUIET_ARG="-q" PKG_OUTPUT_DIR="." PKG_EXT="rpm" @@ -144,92 +191,57 @@ elif [ "${CI_OSTYPE}" = "centos:7" ] || [ "${CI_OSTYPE}" = "centos:centos7" ]; t DIST_TAG="el/7" INSTALL_PKG_LIST="git autoconf automake gcc-c++ make pkgconfig redhat-rpm-config rpm-build ruby-devel rubygems procps" INSTALLER_BIN="yum" + UPDATE_CMD="update" + UPDATE_CMD_ARG="" + INSTALL_CMD="install" + INSTALL_CMD_ARG="" + INSTALL_AUTO_ARG="-y" INSTALL_QUIET_ARG="-q" PKG_OUTPUT_DIR="." PKG_EXT="rpm" IS_OS_CENTOS=1 -elif [ "${CI_OSTYPE}" = "fedora:36" ]; then - DIST_TAG="fedora/36" +elif [ "${CI_OSTYPE}" = "fedora:37" ]; then + DIST_TAG="fedora/37" INSTALL_PKG_LIST="git autoconf automake gcc-c++ make pkgconfig redhat-rpm-config rpm-build ruby-devel rubygems procps" INSTALLER_BIN="dnf" + UPDATE_CMD="update" + UPDATE_CMD_ARG="" + INSTALL_CMD="install" + INSTALL_CMD_ARG="" + INSTALL_AUTO_ARG="-y" INSTALL_QUIET_ARG="-q" PKG_OUTPUT_DIR="." PKG_EXT="rpm" IS_OS_FEDORA=1 -elif [ "${CI_OSTYPE}" = "fedora:35" ]; then - DIST_TAG="fedora/35" +elif [ "${CI_OSTYPE}" = "fedora:36" ]; then + DIST_TAG="fedora/36" INSTALL_PKG_LIST="git autoconf automake gcc-c++ make pkgconfig redhat-rpm-config rpm-build ruby-devel rubygems procps" INSTALLER_BIN="dnf" + UPDATE_CMD="update" + UPDATE_CMD_ARG="" + INSTALL_CMD="install" + INSTALL_CMD_ARG="" + INSTALL_AUTO_ARG="-y" INSTALL_QUIET_ARG="-q" PKG_OUTPUT_DIR="." PKG_EXT="rpm" IS_OS_FEDORA=1 -# -# [NOTICE] -# The OS from here onwards will be used until a new version is created, but we will drop support for it soon. -# Newer versions will only support the OSes mentioned before this line. -# -elif [ "${CI_OSTYPE}" = "ubuntu:16.04" ] || [ "${CI_OSTYPE}" = "ubuntu:xenial" ]; then - DIST_TAG="ubuntu/xenial" - INSTALL_PKG_LIST="git autoconf autotools-dev make dh-make fakeroot dpkg-dev devscripts pkg-config ruby-dev rubygems rubygems-integration procps" - INSTALLER_BIN="apt-get" - INSTALL_QUIET_ARG="-qq" - PKG_OUTPUT_DIR="debian_build" - PKG_EXT="deb" - IS_OS_UBUNTU=1 - -elif [ "${CI_OSTYPE}" = "debian:9" ] || [ "${CI_OSTYPE}" = "debian:stretch" ]; then - DIST_TAG="debian/stretch" - INSTALL_PKG_LIST="git autoconf autotools-dev make dh-make fakeroot dpkg-dev devscripts pkg-config ruby-dev rubygems rubygems-integration procps" - INSTALLER_BIN="apt-get" - INSTALL_QUIET_ARG="-qq" - PKG_OUTPUT_DIR="debian_build" - PKG_EXT="deb" - IS_OS_DEBIAN=1 - -elif [ "${CI_OSTYPE}" = "centos:8" ] || [ "${CI_OSTYPE}" = "centos:centos8" ]; then - DIST_TAG="el/8" - INSTALL_PKG_LIST="git autoconf automake gcc-c++ make pkgconfig redhat-rpm-config rpm-build ruby-devel rubygems procps" - INSTALLER_BIN="dnf" - INSTALL_QUIET_ARG="-qq" - PKG_OUTPUT_DIR="." - PKG_EXT="rpm" - IS_OS_CENTOS=1 - - # - # Change mirrorlist - # - sed -i -e 's|^mirrorlist|#mirrorlist|g' -e 's|^#baseurl=http://mirror|baseurl=http://vault|g' /etc/yum.repos.d/CentOS-*repo - -elif [ "${CI_OSTYPE}" = "fedora:32" ]; then - DIST_TAG="fedora/32" - INSTALL_PKG_LIST="git autoconf automake gcc-c++ make pkgconfig redhat-rpm-config rpm-build ruby-devel rubygems procps" - INSTALLER_BIN="dnf" - INSTALL_QUIET_ARG="-qq" - PKG_OUTPUT_DIR="." - PKG_EXT="rpm" - IS_OS_FEDORA=1 - -elif [ "${CI_OSTYPE}" = "fedora:31" ]; then - DIST_TAG="fedora/31" - INSTALL_PKG_LIST="git autoconf automake gcc-c++ make pkgconfig redhat-rpm-config rpm-build ruby-devel rubygems procps" - INSTALLER_BIN="dnf" - INSTALL_QUIET_ARG="-qq" - PKG_OUTPUT_DIR="." - PKG_EXT="rpm" - IS_OS_FEDORA=1 - -elif [ "${CI_OSTYPE}" = "fedora:30" ]; then - DIST_TAG="fedora/30" - INSTALL_PKG_LIST="git autoconf automake gcc-c++ make pkgconfig redhat-rpm-config rpm-build ruby-devel rubygems procps" - INSTALLER_BIN="dnf" - INSTALL_QUIET_ARG="-qq" - PKG_OUTPUT_DIR="." - PKG_EXT="rpm" - IS_OS_FEDORA=1 +elif [ "${CI_OSTYPE}" = "alpine:3.17" ]; then + DIST_TAG="alpine/v3.17" + INSTALL_PKG_LIST="bash sudo alpine-sdk automake autoconf util-linux-misc musl-locales ruby-dev procps coreutils" + INSTALLER_BIN="apk" + UPDATE_CMD="update" + UPDATE_CMD_ARG="--no-progress" + INSTALL_CMD="add" + INSTALL_CMD_ARG="--no-progress --no-cache" + INSTALL_AUTO_ARG="" + INSTALL_QUIET_ARG="-q" + PKG_OUTPUT_DIR="apk_build" + PKG_EXT="apk" + IS_OS_ALPINE=1 fi #--------------------------------------------------------------- diff --git a/buildutils/APKBUILD.templ.in b/buildutils/APKBUILD.templ.in new file mode 100644 index 0000000..1e44bb5 --- /dev/null +++ b/buildutils/APKBUILD.templ.in @@ -0,0 +1,127 @@ +# +# K2HDKC DBaaS Command Line Interface - K2HR3 CLI Plugin +# +# Copyright 2020 Yahoo Japan Corporation. +# +# K2HDKC DBaaS is a DataBase as a Service provided by Yahoo! JAPAN +# which is built K2HR3 as a backend and provides services in +# cooperation with OpenStack. +# The Override configuration for K2HDKC DBaaS serves to connect the +# components that make up the K2HDKC DBaaS. K2HDKC, K2HR3, CHMPX, +# and K2HASH are components provided as AntPickax. +# +# For the full copyright and license information, please view +# the license file that was distributed with this source code. +# +# AUTHOR: Takeshi Nakatani +# CREATE: Wed, 8 Feb 2023 +# REVISION: +# + +#--------------------------------------------------------------- +# Local varibales as antpickax template +#--------------------------------------------------------------- +# +# Set variables by configure +# +_git_domain="@GIT_DOMAIN@" +_organization_name="@GIT_ORG@" +_repository_name="@GIT_REPO@" + +# +# Set variables by apk_build.sh +# +_package_revision=%%BUILD_NUMBER%% +_configure_option=%%CONFIGUREOPT%% +_source_archive_url=%%SOURCE_ARCHIVE_URL%% + +#--------------------------------------------------------------- +# Main variables for APKBUILD +#--------------------------------------------------------------- +# Contributor: @DEV_NAME@ <@DEV_EMAIL@> +# Maintainer: @DEV_NAME@ <@DEV_EMAIL@> + +# [NOTE] +# The $_organization_name is "k2hdkc_dbaas_cli", but the $pkgname +# should be "k2hdkc-dbaas-cli", so adjust with this variable. +# +pkgname="k2hdkc-dbaas-cli" +pkgver=@PKG_VERSION@ +pkgrel=$_package_revision +pkgdesc="K2HDKC DBaaS Command Line Interface" + +url="https://k2hr3.antpick.ax/" +arch="x86_64" +license="MIT" + +depends=" + curl +" +depends_dev="" +makedepends=" + $depends_dev + autoconf + automake + musl-locales + procps +" + +install="" +subpackages="" + +source="$pkgname-$pkgver.tar.gz%%SOURCE_ARCHIVE_URL%%" + +builddir="$srcdir/$pkgname-$pkgver" + +#--------------------------------------------------------------- +# Build functions for APKBUILD +#--------------------------------------------------------------- +prepare() { + default_prepare + # this function can be omitted if no extra steps are needed +} + +unpack() { + default_unpack + + # [NOTE] + # A github release archive is unzipped as a directory with the + # repository name(k2hdkc_dbaas_cli) and version number. + # In this case, change the directory name to the package name + # (k2hdkc-dbaas-cli) instead of the repository name. + # + if [ -d "$_repository_name-$pkgver" ]; then + mv "$_repository_name-$pkgver" "$pkgname-$pkgver" + fi +} + +build() { + if [ ! -f configure ]; then + ./autogen.sh + fi + ./configure --prefix=/usr $_configure_option + make build +} + +check() { + make check +} + +package() { + install -Dm 0444 src/libexec/database/CREDIT "$pkgdir"/usr/libexec/k2hr3/database/CREDIT + install -Dm 0444 src/libexec/database/VERSION "$pkgdir"/usr/libexec/k2hr3/database/VERSION + install -Dm 0444 src/libexec/database/k2hdkc_dbaas_create_host.templ "$pkgdir"/usr/libexec/k2hr3/database/k2hdkc_dbaas_create_host.templ + install -Dm 0444 src/libexec/database/k2hdkc_dbaas_resource_keys.config "$pkgdir"/usr/libexec/k2hr3/database/k2hdkc_dbaas_resource_keys.config + install -Dm 0444 src/libexec/database/k2hdkc_dbaas_resource.templ "$pkgdir"/usr/libexec/k2hr3/database/k2hdkc_dbaas_resource.templ + install -Dm 0444 src/libexec/database/command.sh "$pkgdir"/usr/libexec/k2hr3/database/command.sh + install -Dm 0444 src/libexec/database/functions.sh "$pkgdir"/usr/libexec/k2hr3/database/functions.sh + install -Dm 0444 src/libexec/database/help.sh "$pkgdir"/usr/libexec/k2hr3/database/help.sh + install -Dm 0444 src/libexec/database/openstack.sh "$pkgdir"/usr/libexec/k2hr3/database/openstack.sh + install -Dm 0444 src/libexec/database/options.sh "$pkgdir"/usr/libexec/k2hr3/database/options.sh + install -Dm 0444 src/libexec/database/summary.sh "$pkgdir"/usr/libexec/k2hr3/database/summary.sh + install -Dm 0444 src/libexec/database/variables.sh "$pkgdir"/usr/libexec/k2hr3/database/variables.sh +} + +# [NOTE] +# Subsequent lines print the checksum of the source archive. +# diff --git a/buildutils/alpine_build.sh b/buildutils/alpine_build.sh new file mode 100755 index 0000000..989fae9 --- /dev/null +++ b/buildutils/alpine_build.sh @@ -0,0 +1,505 @@ +#!/bin/sh +# +# Utility tools for building configure/packages by AntPickax +# +# Copyright 2018 Yahoo Japan Corporation. +# +# AntPickax provides utility tools for supporting autotools +# builds. +# +# These tools retrieve the necessary information from the +# repository and appropriately set the setting values of +# configure, Makefile, spec,etc file and so on. +# These tools were recreated to reduce the number of fixes and +# reduce the workload of developers when there is a change in +# the project configuration. +# +# For the full copyright and license information, please view +# the license file that was distributed with this source code. +# +# AUTHOR: Takeshi Nakatani +# CREATE: Fri, Jan 13 2023 +# REVISION: 1.1 +# + +#============================================================== +# Autobuild for apk package +#============================================================== +# +# Instead of pipefail(for shells not support "set -o pipefail") +# +PIPEFAILURE_FILE="/tmp/.pipefailure.$(od -An -tu4 -N4 /dev/random | tr -d ' \n')" + +# +# For shellcheck +# +if locale -a | grep -q -i '^[[:space:]]*C.utf8[[:space:]]*$'; then + LANG=$(locale -a | grep -i '^[[:space:]]*C.utf8[[:space:]]*$' | sed -e 's/^[[:space:]]*//g' -e 's/[[:space:]]*$//g' | tr -d '\n') + LC_ALL="${LANG}" + export LANG + export LC_ALL +elif locale -a | grep -q -i '^[[:space:]]*en_US.utf8[[:space:]]*$'; then + LANG=$(locale -a | grep -i '^[[:space:]]*en_US.utf8[[:space:]]*$' | sed -e 's/^[[:space:]]*//g' -e 's/[[:space:]]*$//g' | tr -d '\n') + LC_ALL="${LANG}" + export LANG + export LC_ALL +fi + +# +# Common variables +# +PRGNAME=$(basename "${0}") +MYSCRIPTDIR=$(dirname "${0}") +SRCTOP=$(cd "${MYSCRIPTDIR}/.." || exit 1; pwd) +SRCTOP_DIRNAME=$(basename "${SRCTOP}") + +# +# Variables +# +APK_TOPDIR="${SRCTOP}/apk_build" +APKBUILD_TEMPLATE_FILE="${SRCTOP}/buildutils/APKBUILD.templ" +APKBUILD_FILE="${APK_TOPDIR}/APKBUILD" +APKBUILD_CONFIG_DIR="${HOME}/.abuild" +MAKE_VARIABLES_TOOL="${SRCTOP}/buildutils/make_variables.sh" + +PRGNAME_NOEXT=$(echo "${PRGNAME}" | sed -e 's/[\.].*$//g' | tr -d '\n') +EXTRA_COPY_FILES_CONF="${MYSCRIPTDIR}/${PRGNAME_NOEXT}_copy.conf" + +#--------------------------------------------------------------- +# Utility functions +#--------------------------------------------------------------- +func_usage() +{ + echo "" + echo "Usage: $1 [--help(-h)] [--buildnum(-b) ] [--product(-p) ] [--yes(-y)]" + echo " --help(-h) print help." + echo " --buildnum(-b) specify build number for packaging(default 1)" + echo " --product(-p) specify product name(use PACKAGE_NAME in Makefile s default), this value is using a part of package directory path" + echo " --yes(-y) runs no interactive mode." + echo "" + echo "Environment:" + echo " CONFIGUREOPT specify options when running configure." + echo " GITHUB_REF_TYPE Github Actions CI sets \"branch\" or \"tag\"." + echo " DEBEMAIL Use this value to create an RSA key." + echo " DEBFULLNAME Use this value to create an RSA key." + echo "" +} + +#--------------------------------------------------------------- +# Parse parameters +#--------------------------------------------------------------- +NO_INTERACTIVE=0 +BUILD_NUMBER= +PACKAGE_NAME="" + +while [ $# -ne 0 ]; do + if [ -z "$1" ]; then + break + + elif [ "$1" = "-h" ] || [ "$1" = "-H" ] || [ "$1" = "--help" ] || [ "$1" = "--HELP" ]; then + func_usage "${PRGNAME}" + exit 0 + + elif [ "$1" = "-b" ] || [ "$1" = "-B" ] || [ "$1" = "--buildnum" ] || [ "$1" = "--BUILDNUM" ]; then + if [ -n "${BUILD_NUMBER}" ]; then + echo "[ERROR] Already --buildnum(-b) option is specified(${BUILD_NUMBER})." 1>&2 + exit 1 + fi + shift + if [ -z "$1" ]; then + echo "[ERROR] --buildnum(-b) option need parameter." 1>&2 + exit 1 + fi + if echo "$1" | grep -q "[^0-9]"; then + echo "[ERROR] --buildnum(-b) option parameter must be number." 1>&2 + exit 1 + fi + BUILD_NUMBER="$1" + + elif [ "$1" = "-p" ] || [ "$1" = "-P" ] || [ "$1" = "--product" ] || [ "$1" = "--PRODUCT" ]; then + if [ -n "${PACKAGE_NAME}" ]; then + echo "[ERROR] Already --product(-p) option is specified(${PACKAGE_NAME})." 1>&2 + exit 1 + fi + shift + if [ -z "$1" ]; then + echo "[ERROR] --product(-p) option need parameter." 1>&2 + exit 1 + fi + PACKAGE_NAME="$1" + + elif [ "$1" = "-y" ] || [ "$1" = "-Y" ] || [ "$1" = "--yes" ] || [ "$1" = "--YES" ]; then + if [ "${NO_INTERACTIVE}" -ne 0 ]; then + echo "[ERROR] Already --yes(-y) option is specified." 1>&2 + exit 1 + fi + NO_INTERACTIVE=1 + + else + echo "[ERROR] Unknown option $1." 1>&2 + exit 1 + fi + shift +done + +# +# Check input parameters +# +# [NOTE] +# APK package revision starts "0", it is default value. +# +if [ -z "${BUILD_NUMBER}" ]; then + BUILD_NUMBER=0 +elif [ "${BUILD_NUMBER}" -gt 0 ]; then + BUILD_NUMBER=$((BUILD_NUMBER - 1)) +fi +if [ -z "${PACKAGE_NAME}" ]; then + # + # Get default package name from Makefile or ChangeLog + # + if [ -f "${SRCTOP}/Makefile" ]; then + PACKAGE_NAME=$(grep '^PACKAGE_NAME' "${SRCTOP}"/Makefile 2>/dev/null | awk '{print $3}' | tr -d '\n') + fi + if [ -z "${PACKAGE_NAME}" ] && [ -f "${SRCTOP}/ChangeLog" ] ; then + PACKAGE_NAME=$(grep -v '^$' "${SRCTOP}"/ChangeLog | grep -v '^[[:space:]]' | head -1 | awk '{print $1}' | tr -d '\n') + fi + if [ -z "${PACKAGE_NAME}" ]; then + echo "[ERROR] Could not get package name from Makefile or ChangeLog, please use --product(-p) option." 1>&2 + exit 1 + fi +fi + +#--------------------------------------------------------------- +# Create a directory for building APK packages. +#--------------------------------------------------------------- +# [NOTE] +# This directory must be created to store RSA keys. +# +if [ -d "${APK_TOPDIR}" ] || [ -f "${APK_TOPDIR}" ]; then + rm -rf "${APK_TOPDIR}" +fi +if ! mkdir -p "${APK_TOPDIR}"; then + echo "[ERROR] Could not make ${APK_TOPDIR} directory." 1>&2 + exit 1 +fi + +#--------------------------------------------------------------- +# Check Environments and variables +#--------------------------------------------------------------- +# [NOTE] +# This script sets variables in the APKBUILD file from environment +# and variables. +# Use the following environment variables and variables. +# +# DEBEMAIL : Used for creating RSA keys +# DEBFULLNAME : Used for creating RSA keys +# CONFIGUREOPT : Parameters passed to configure. +# This variable is automatically passed when invoking this +# script. +# GITHUB_REF_TYPE : This environment variable is set by GithubActions. +# For release tagging, this value is set to "tag". +# Unset and otherwise("branch") indicate that the call was +# not made by the release process. +# BUILD_NUMBER : Parameter or default value("0") for this script. +# ABUILD_OPT : abuild common option for running as root user. +# + +if [ -z "${DEBEMAIL}" ]; then + echo "[WARNING] DEBEMAIL environment is not set, so set default \"${USER}@$(hostname)\"" 1>&2 + DEBEMAIL="${USER}@$(hostname)" +fi + +if [ -z "${DEBFULLNAME}" ]; then + echo "[WARNING] DEBFULLNAME environment is not set, so set default \"${USER}\"." 1>&2 + DEBFULLNAME="${USER}" +fi + +if [ -z "${GITHUB_REF_TYPE}" ] || [ "${GITHUB_REF_TYPE}" != "tag" ]; then + SOURCE_ARCHIVE_URL="" + SOURCE_ARCHIVE_SEPARATOR="" +else + SOURCE_ARCHIVE_URL="https://\$_git_domain/\$_organization_name/\$_repository_name/archive/refs/tags/v\$pkgver.tar.gz" + SOURCE_ARCHIVE_SEPARATOR="::" +fi + +# +# Check running as root user +# +# [NOTE] +# The abuild tool drains errors when run as root. +# To avoid this, the "-F" option is required. +# +RUN_USER_ID=$(id -u) +ABUILD_OPT="" + +if [ -n "${RUN_USER_ID}" ] && [ "${RUN_USER_ID}" -eq 0 ]; then + ABUILD_OPT="-F" +fi + +#--------------------------------------------------------------- +# Print information +#--------------------------------------------------------------- +# +# Information +# +echo "[INFO] Information for building APK packages." +echo "" +echo " APK_TOPDIR = ${APK_TOPDIR}" +echo " PACKAGE_NAME = ${PACKAGE_NAME}" +echo " NO_INTERACTIVE = ${NO_INTERACTIVE}" +echo "" +echo " GITHUB_REF_TYPE = ${GITHUB_REF_TYPE}" +echo " CONFIGUREOPT = ${CONFIGUREOPT}" +echo " SOURCE_ARCHIVE_URL = ${SOURCE_ARCHIVE_URL}" +echo " BUILD_NUMBER = ${BUILD_NUMBER}" +echo " ABUILD_OPT = ${ABUILD_OPT}" +echo "" + +# +# Welcome message and confirming for interactive mode +# +if [ "${NO_INTERACTIVE}" -eq 0 ]; then + echo " Do you create APK packages with above variables?" + IS_CONFIRMED=0 + while [ "${IS_CONFIRMED}" -eq 0 ]; do + printf ' [INPUT] Confirm (y/n) : ' + read -r CONFIRM + + if [ "${CONFIRM}" = "y" ] || [ "${CONFIRM}" = "Y" ] || [ "${CONFIRM}" = "yes" ] || [ "${CONFIRM}" = "YES" ]; then + IS_CONFIRMED=1 + elif [ "${CONFIRM}" = "n" ] || [ "${CONFIRM}" = "N" ] || [ "${CONFIRM}" = "no" ] || [ "${CONFIRM}" = "NO" ]; then + echo "Interrupt this processing, bye..." + exit 0 + fi + done + echo "" +fi + +#=============================================================== +# Main processing +#=============================================================== +cd "${SRCTOP}" || exit 1 + +#--------------------------------------------------------------- +# Create RSA key for signing +#--------------------------------------------------------------- +echo "[TITLE] Create RSA key for signing" + +# +# Check "${HOME}/.abuild" directory +# +if [ -d "${APKBUILD_CONFIG_DIR}" ] || [ -f "${APKBUILD_CONFIG_DIR}" ]; then + rm -rf "${APKBUILD_CONFIG_DIR}" +fi + +# +# Create temporary RSA key +# +# [NOTE] +# The keys that are created are the following files: +# ${APKBUILD_CONFIG_DIR}/${DEBEMAIL}-.rsa +# ${APKBUILD_CONFIG_DIR}/${DEBEMAIL}-.rsa.pub +# +if ({ PACKAGER="${DEBFULLNAME} <${DEBEMAIL}>" abuild-keygen -a -n 2>&1 || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's#^# #') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then + echo "[ERROR] Failed to create temporary RSA key for building APK packages." 1>&2 + exit 1 +fi + +# +# Check and Copy RSA keys +# +if ! find "${APKBUILD_CONFIG_DIR}" -name "${DEBEMAIL}"-\*\.rsa | grep -q "${DEBEMAIL}"; then + echo "[ERROR] Not found ${APKBUILD_CONFIG_DIR}/${DEBEMAIL}-.rsa files." 1>&2 + exit 1 +fi +if ! find "${APKBUILD_CONFIG_DIR}" -name "${DEBEMAIL}"-\*\.rsa\.pub | grep -q "${DEBEMAIL}"; then + echo "[ERROR] Not found ${APKBUILD_CONFIG_DIR}/${DEBEMAIL}-.rsa.pub files." 1>&2 + exit 1 +fi +if ! cp -p "${APKBUILD_CONFIG_DIR}"/"${DEBEMAIL}"-*.rsa "${APK_TOPDIR}"; then + echo "[ERROR] Failed to copy RSA private key(${APKBUILD_CONFIG_DIR}/${DEBEMAIL}-.rsa) to ${APK_TOPDIR} directory." 1>&2 + exit 1 +fi +if ! cp -p "${APKBUILD_CONFIG_DIR}"/"${DEBEMAIL}"-*.rsa.pub "${APK_TOPDIR}"; then + echo "[ERROR] Failed to copy RSA public key(${APKBUILD_CONFIG_DIR}/${DEBEMAIL}-.rsa.pub) to ${APK_TOPDIR} directory." 1>&2 +fi + +# +# Remove abuild configuration directory(with abuild.conf) +# +# [NOTE] +# When building the package, the RSA key is specified by an environment +# variable, so the presence of this configuration file is misleading. +# +rm -rf "${APKBUILD_CONFIG_DIR}" + +# +# Set file name/key contents to variables +# +APK_PACKAGE_PRIV_KEYNAME="$(find "${APK_TOPDIR}" -name "${DEBEMAIL}"-\*\.rsa 2>/dev/null | head -1 | sed -e "s#${APK_TOPDIR}/##g" | tr -d '\n')" +APK_PACKAGE_PUB_KEYNAME="$(find "${APK_TOPDIR}" -name "${DEBEMAIL}"-\*\.rsa\.pub 2>/dev/null | head -1 | sed -e "s#${APK_TOPDIR}/##g" | tr -d '\n')" + +echo "[SUCCEED] Created RSA keys" +echo " RSA private key : ${APK_TOPDIR}/${APK_PACKAGE_PRIV_KEYNAME}" +echo " RSA public key : ${APK_TOPDIR}/${APK_PACKAGE_PUB_KEYNAME}" +echo "" + +#--------------------------------------------------------------- +# Create source archive ( Not release processing ) +#--------------------------------------------------------------- +echo "[TITLE] Source archive" + +if [ -z "${GITHUB_REF_TYPE}" ] || [ "${GITHUB_REF_TYPE}" != "tag" ]; then + SOURCE_ARCHIVE_VERSION=$("${MAKE_VARIABLES_TOOL}" --pkg_version) + + # + # Create source archive by make dist + # + if ({ make dist || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's#^# #') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then + echo "[ERROR] Failed to create source archive." 1>&2 + exit 1 + fi + if [ ! -f "${SRCTOP}/${PACKAGE_NAME}-${SOURCE_ARCHIVE_VERSION}".tar.gz ]; then + echo "[ERROR] Not found created source archive(${PACKAGE_NAME}-${SOURCE_ARCHIVE_VERSION}.tar.gz)." 1>&2 + exit 1 + fi + + # + # Copy source archive file + # + if ! cp "${SRCTOP}/${PACKAGE_NAME}-${SOURCE_ARCHIVE_VERSION}".tar.gz "${APK_TOPDIR}"; then + echo "[ERROR] Copy source archive(${PACKAGE_NAME}-${SOURCE_ARCHIVE_VERSION}.tar.gz) to ${APK_TOPDIR} directory." 1>&2 + exit 1 + fi + + echo "[SUCCEED] Created source archive" + echo " Source archive file : ${SRCTOP}/${PACKAGE_NAME}-${SOURCE_ARCHIVE_VERSION}.tar.gz" + echo "" +else + echo "[SUCCEED] Source archive" + echo " Source archive URL : ${SOURCE_ARCHIVE_URL}" + echo "" +fi + +#--------------------------------------------------------------- +# Copy extra files +#--------------------------------------------------------------- +# [NOTE] +# If you have files to copy under "/apk_build" directory +# (includes in your package), you can prepare "buildutils/alpine_build_copy.conf" +# file and lists target files int it. +# The file names in this configuration file list with relative paths from the source +# top directory. +# ex) src/myfile +# lib/mylib +# +if [ -f "${EXTRA_COPY_FILES_CONF}" ]; then + echo "[TITLE] Copy extra files" + + EXTRA_COPY_FILES=$(sed -e 's/#.*$//g' -e 's/^[[:space:]]*//g' -e 's/[[:space:]]*$//g' -e '/^$/d' "${EXTRA_COPY_FILES_CONF}") + for _extra_file in ${EXTRA_COPY_FILES}; do + if [ ! -f "${SRCTOP}/${_extra_file}" ]; then + echo "[ERROR] Not found ${SRCTOP}/${_extra_file} file for extra copy." 1>&2 + exit 1 + fi + if ! cp -p "${SRCTOP}/${_extra_file}" "${APK_TOPDIR}"; then + echo "[ERROR] Failed to copy ${SRCTOP}/${_extra_file} file to ${APK_TOPDIR}." 1>&2 + exit 1 + fi + done + + echo "[SUCCEED] Copied extra files" +fi + +#--------------------------------------------------------------- +# Create APKBUILD file +#--------------------------------------------------------------- +echo "[TITLE] Create APKBUILD file from template" + +# +# Create APKBUILD file from template +# +if ! sed -e "s#%%BUILD_NUMBER%%#${BUILD_NUMBER}#g" \ + -e "s#%%CONFIGUREOPT%%#${CONFIGUREOPT}#g" \ + -e "s#%%SOURCE_ARCHIVE_URL%%#${SOURCE_ARCHIVE_SEPARATOR}${SOURCE_ARCHIVE_URL}#g" \ + "${APKBUILD_TEMPLATE_FILE}" > "${APKBUILD_FILE}" ; then + + echo "[ERROR] Failed to create APKBUILD file in ${APK_TOPDIR} directory." 1>&2 + exit 1 +fi + +# +# Add checksum to APKBUILD file +# +cd "${APK_TOPDIR}" || exit 1 + +if ! /bin/sh -c "abuild ${ABUILD_OPT} checksum"; then + echo "[ERROR] Failed to add checksum to APKBUILD file(${APKBUILD_FILE})." 1>&2 + exit 1 +fi + +# +# Get Arch name for a part of package directory path +# +ARCH_NAME=$(grep '^arch=' "${APKBUILD_FILE}" | sed -e 's#^arch=##g' -e 's#"##g' | tail -1 | tr -d '\n') + +# +# Print APKBUILD file +# +echo "[SUCCEED] Created APKBUILD file(${APKBUILD_FILE})" +echo "" +sed -e 's#^# #g' "${APKBUILD_FILE}" +echo "" + +#--------------------------------------------------------------- +# Create packages +#--------------------------------------------------------------- +echo "[TITLE] Build APK packages." + +# +# build APK packages +# +if ({ /bin/sh -c "PACKAGER_PRIVKEY=${APK_TOPDIR}/${APK_PACKAGE_PRIV_KEYNAME} abuild ${ABUILD_OPT} -r -P $(pwd)" || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's#^# #') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then + echo "[ERROR] Failed to create APK packages." 1>&2 + exit 1 +fi +echo "[SUCCEED] Built APK packages" + +# +# Show APK packages +# +for _one_pkg in "${APK_TOPDIR}"/"${SRCTOP_DIRNAME}"/"${ARCH_NAME}"/*.apk; do + echo "" + echo "[INFO] Dump APK package : ${_one_pkg}" + + if ({ tar tvfz "${_one_pkg}" 2>/dev/null || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's#^# #') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then + echo "[ERROR] Failed to extract ${_one_pkg} APK package." 1>&2 + exit 1 + fi +done + +# +# Copy APK packages +# +if ! cp -p "${APK_TOPDIR}"/"${SRCTOP_DIRNAME}"/"${ARCH_NAME}"/*.apk "${APK_TOPDIR}"; then + echo "[ERROR] Failed to copy ${APK_TOPDIR}/${SRCTOP_DIRNAME}/${ARCH_NAME}/*.apk package to ${APK_TOPDIR} directory." 1>&2 + exit 1 +fi + +#--------------------------------------------------------------- +# Finish +#--------------------------------------------------------------- +echo "" +echo "[SUCCEED] You can find APK package in ${APK_TOPDIR} directory" +echo "" + +exit 0 + +# +# Local variables: +# tab-width: 4 +# c-basic-offset: 4 +# End: +# vim600: noexpandtab sw=4 ts=4 fdm=marker +# vim<600: noexpandtab sw=4 ts=4 +# diff --git a/buildutils/control.in b/buildutils/control.in index 2e5d2df..ff3f9b4 100644 --- a/buildutils/control.in +++ b/buildutils/control.in @@ -12,7 +12,7 @@ Package: @PACKAGE_NAME@ Section: utils Architecture: all Depends: ${misc:Depends}, k2hr3-cli -Description: @SHORTDESC@ +Description: K2HDKC DBaaS Command Line Interface The K2HDKC DBaaS CLI (Command Line Interface of Database as a Service for K2HDKC) is a tool for building a K2HDKC cluster in conjunction with K2HR3. diff --git a/buildutils/debian_build.sh b/buildutils/debian_build.sh index bdf135e..858c8a1 100755 --- a/buildutils/debian_build.sh +++ b/buildutils/debian_build.sh @@ -216,6 +216,7 @@ if [ -z "${PACKAGE_NAME}" ]; then fi fi PACKAGE_DEV_NAME="${PACKAGE_NAME}-dev" +PACKAGE_DBGSYM_NAME="${PACKAGE_NAME}-dbgsym" LIB_BASENAME="lib${PACKAGE_NAME}" if [ "${BUILD_NUMBER}" -eq 0 ]; then @@ -550,10 +551,36 @@ fi # [NOTE] Check following files: # ${PACKAGE_NAME}_${PACKAGE_VERSION}-${BUILD_NUMBER}*.deb # ${PACKAGE_DEV_NAME}_${PACKAGE_VERSION}-${BUILD_NUMBER}*.deb +# ${PACKAGE_DBGSYM_NAME}_${PACKAGE_VERSION}-${BUILD_NUMBER}*.{deb,ddeb} # lib${PACKAGE_NAME}_${PACKAGE_VERSION}-${BUILD_NUMBER}*.deb # lib${PACKAGE_DEV_NAME}_${PACKAGE_VERSION}-${BUILD_NUMBER}*.deb +# lib${PACKAGE_DBGSYM_NAME}_${PACKAGE_VERSION}-${BUILD_NUMBER}*.{deb,ddeb} # -FOUND_DEB_PACKAGES=$(find "${BUILDDEBDIR}" -name \*"${PACKAGE_NAME}_${PACKAGE_VERSION}-${BUILD_NUMBER}"\*.deb 2>/dev/null; find "${BUILDDEBDIR}" -name \*"${PACKAGE_DEV_NAME}_${PACKAGE_VERSION}-${BUILD_NUMBER}"\*.deb 2>/dev/null) +# [NOTICE] ddeb files +# If the ".ddeb" files exist, those file is renamed the ".deb" file extension. +# This is because packagecloud.io site and cli tool do not accept ".ddeb" file +# extensions and treat dbgsym files as ".deb" file extensions. +# In the future, once packagecloud.io supports the ".ddeb" file extension, we +# will stop renaming it. +# Currently we display a warning when renaming this file extension. +# + +FOUND_DDEB_PACKAGES=$(find "${BUILDDEBDIR}" -name \*"${PACKAGE_DBGSYM_NAME}_${PACKAGE_VERSION}-${BUILD_NUMBER}"\*.ddeb 2>/dev/null) + +if [ -n "${FOUND_DDEB_PACKAGES}" ]; then + echo "" + echo "[WARNING] Found \".ddeb\" files, these files will be changed to \".deb\" extension. Please stop this renaming once packagecloud.io supports the \".ddeb\" extension." 1>&2 + echo "" +fi +for _one_pkg in ${FOUND_DDEB_PACKAGES}; do + _copied_pkg=$(echo "${_one_pkg}" | sed -e 's#\.ddeb$#\.deb#g') + if ! cp -p "${_one_pkg}" "${_copied_pkg}"; then + echo "[ERROR] Failed to copy ${_one_pkg} to ${_copied_pkg}" 1>&2 + exit 1 + fi +done + +FOUND_DEB_PACKAGES=$(find "${BUILDDEBDIR}" -name \*"${PACKAGE_NAME}_${PACKAGE_VERSION}-${BUILD_NUMBER}"\*.deb 2>/dev/null; find "${BUILDDEBDIR}" -name \*"${PACKAGE_DEV_NAME}_${PACKAGE_VERSION}-${BUILD_NUMBER}"\*.deb 2>/dev/null; find "${BUILDDEBDIR}" -name \*"${PACKAGE_DBGSYM_NAME}_${PACKAGE_VERSION}-${BUILD_NUMBER}"\*.deb 2>/dev/null) if [ -z "${FOUND_DEB_PACKAGES}" ]; then echo "[ERROR] No debian package in ${BUILDDEBDIR}." 1>&2 diff --git a/buildutils/k2hdkc-dbaas-cli.spec.in b/buildutils/k2hdkc-dbaas-cli.spec.in index 275a581..639342e 100644 --- a/buildutils/k2hdkc-dbaas-cli.spec.in +++ b/buildutils/k2hdkc-dbaas-cli.spec.in @@ -48,7 +48,7 @@ # # main package # -Summary: @SHORTDESC@ +Summary: K2HDKC DBaaS Command Line Interface Name: @PACKAGE_NAME@ Version: @VERSION@ Release: %{package_revision}%{?dist} diff --git a/configure.ac b/configure.ac index 80d48da..121f231 100644 --- a/configure.ac +++ b/configure.ac @@ -103,7 +103,8 @@ AC_CONFIG_FILES([Makefile buildutils/control buildutils/copyright buildutils/rules - buildutils/k2hdkc-dbaas-cli.spec]) + buildutils/k2hdkc-dbaas-cli.spec + buildutils/APKBUILD.templ]) AC_OUTPUT diff --git a/test/test.sh b/test/test.sh index c4a4a60..e919a69 100755 --- a/test/test.sh +++ b/test/test.sh @@ -98,18 +98,6 @@ done TEST_IDENTITY_URI="http://localhost:8080" set -- "--config" "${TESTDIR}/k2hr3.config" "--apiuri" "http://localhost" "--openstack_identity_uri" "${TEST_IDENTITY_URI}" "--dbaas_config" "${TESTDIR}/../src/libexec/database" -#--------------------------------------------------------------------- -# Functions -#--------------------------------------------------------------------- -func_usage() -{ - echo "" - echo "Usage: ${TESTMAINBIN} [option...]" - echo " --update(-u) update the test result comparison file with the current test result." - echo " --help(-h) print help." - echo "" -} - #--------------------------------------------------------------------- # Test all #---------------------------------------------------------------------