Skip to content

Commit

Permalink
Merge pull request #107 from ggtakec/update_common_tools
Browse files Browse the repository at this point in the history
Updated common build scripts
  • Loading branch information
Takeshi Nakatani authored Oct 27, 2022
2 parents 024f815 + a60cfc0 commit 3193b35
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 23 deletions.
24 changes: 16 additions & 8 deletions autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@
# REVISION:
#

#==============================================================
# Autotools
#==============================================================
#
# Instead of pipefail(for shells not support "set -o pipefail")
#
PIPEFAILURE_FILE="/tmp/.pipefailure.$(od -An -tu4 -N4 /dev/random | tr -d ' \n')"

#
# Common variables
#
Expand All @@ -32,7 +40,7 @@ AUTOGEN_DIR=$(dirname "${0}")
SRCTOP=$(cd "${AUTOGEN_DIR}" || exit 1; pwd)

#
# Run
# Start to run
#
echo "[RUN] autogen.sh"
echo ""
Expand Down Expand Up @@ -75,7 +83,7 @@ done
#
if [ "${UPDATE_VERSION_FILE}" -eq 1 ] && [ -f "${SRCTOP}/buildutils/make_release_version_file.sh" ]; then
echo " [INFO] run make_release_version_file.sh"
if ! /bin/sh -c "${SRCTOP}/buildutils/make_release_version_file.sh" "${PARAMETERS}" 2>&1 | sed -e 's|^| |g'; then
if ({ /bin/sh -c "${SRCTOP}/buildutils/make_release_version_file.sh" "${PARAMETERS}" 2>&1 || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's|^| |g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then
echo "[ERROR] update RELEASE_VERSION file"
exit 1
fi
Expand All @@ -102,7 +110,7 @@ fi
#
if [ ! -f configure.scan ] || [ -n "${FORCEPARAM}" ]; then
echo " [INFO] run autoscan"
if ! autoscan 2>&1 | sed -e 's|^| |g'; then
if ({ autoscan 2>&1 || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's|^| |g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then
echo "[ERROR] something error occurred in autoscan"
exit 1
fi
Expand All @@ -112,7 +120,7 @@ fi
# Copy libtools
#
if grep -q 'LT_INIT' configure.ac configure.scan; then
if ! libtoolize --force --copy 2>&1 | sed -e 's|^| |g'; then
if ({ libtoolize --force --copy 2>&1 || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's|^| |g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then
echo "[ERROR] something error occurred in libtoolize"
exit 1
fi
Expand All @@ -122,27 +130,27 @@ fi
# Build configure and Makefile
#
echo " [INFO] run aclocal ${FORCEPARAM}"
if ! /bin/sh -c "aclocal ${FORCEPARAM}" 2>&1 | sed -e 's|^| |g'; then
if ({ /bin/sh -c "aclocal ${FORCEPARAM}" 2>&1 || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's|^| |g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then
echo "[ERROR] something error occurred in aclocal ${FORCEPARAM}"
exit 1
fi

if grep -q 'AC_CONFIG_HEADERS' configure.ac configure.scan; then
echo " [INFO] run autoheader"
if ! autoheader 2>&1 | sed -e 's|^| |g'; then
if ({ autoheader 2>&1 || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's|^| |g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then
echo "[ERROR] something error occurred in autoheader"
exit 1
fi
fi

echo " [INFO] run automake -c --add-missing"
if ! automake -c --add-missing 2>&1 | sed -e 's|^| |g'; then
if ({ automake -c --add-missing 2>&1 || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's|^| |g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then
echo "[ERROR] something error occurred in automake -c --add-missing"
exit 1
fi

echo " [INFO] run autoconf"
if ! autoconf 2>&1 | sed -e 's|^| |g'; then
if ({ autoconf 2>&1 || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's|^| |g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then
echo "[ERROR] something error occurred in autoconf"
exit 1
fi
Expand Down
37 changes: 28 additions & 9 deletions buildutils/debian_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,28 @@
# REVISION:
#

#==============================================================
# Autobuild for debian package
#==============================================================
#
# Autobuid for debian 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
Expand Down Expand Up @@ -264,13 +283,13 @@ fi
# Run configure for package version
#
echo "[INFO] Run autogen"
if ! "${SRCTOP}"/autogen.sh | sed -e 's/^/ /'; then
if ({ "${SRCTOP}"/autogen.sh || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then
echo "[ERROR] Failed to run autogen.sh." 1>&2
exit 1
fi
echo ""
echo "[INFO] Run configure"
if ! /bin/sh -c "${SRCTOP}/configure ${CONFIGUREOPT}" | sed -e 's/^/ /'; then
if ({ /bin/sh -c "${SRCTOP}/configure ${CONFIGUREOPT}" || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then
echo "[ERROR] Failed to run configure." 1>&2
exit 1
fi
Expand All @@ -295,7 +314,7 @@ fi
#
echo ""
echo "[INFO] Create dist file(tar.gz)"
if ! make dist | sed -e 's/^/ /'; then
if ({ make dist || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then
echo "[ERROR] Failed to create dist package(make dist)." 1>&2
exit 1
fi
Expand All @@ -314,7 +333,7 @@ if ! cp "${SRCTOP}/${PACKAGE_NAME}-${PACKAGE_VERSION}.tar.gz" "${BUILDDEBDIR}/."
echo "[ERROR] Failed to copy ${SRCTOP}/${PACKAGE_NAME}-${PACKAGE_VERSION}.tar.gz file to ${BUILDDEBDIR}" 1>&2
exit 1
fi
if ! tar xvfz "${PACKAGE_NAME}-${PACKAGE_VERSION}.tar.gz" | sed -e 's/^/ /'; then
if ({ tar xvfz "${PACKAGE_NAME}-${PACKAGE_VERSION}.tar.gz" || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then
echo "[ERROR] Failed to expand source code from ${PACKAGE_NAME}-${PACKAGE_VERSION}.tar.gz" 1>&2
exit 1
fi
Expand All @@ -341,7 +360,7 @@ if [ -z "${LOGNAME}" ] && [ -z "${USER}" ]; then
export USER="root"
export LOGNAME="root"
fi
if ! /bin/sh -c "dh_make -f ${BUILDDEBDIR}/${PACKAGE_NAME}-${PACKAGE_VERSION}.tar.gz --createorig --${PKG_CLASS_NAME} ${DH_MAKE_AUTORUN_OPTION}" | sed -e 's/^/ /'; then
if ({ /bin/sh -c "dh_make -f ${BUILDDEBDIR}/${PACKAGE_NAME}-${PACKAGE_VERSION}.tar.gz --createorig --${PKG_CLASS_NAME} ${DH_MAKE_AUTORUN_OPTION}" || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then
echo "[ERROR] Failed to run dh_make with ${BUILDDEBDIR}/${PACKAGE_NAME}-${PACKAGE_VERSION}.tar.gz for initializing debian directory." 1>&2
exit 1
fi
Expand Down Expand Up @@ -520,7 +539,7 @@ fi
# This option can be removed if ubuntu16.04 is unsupported.
#
echo "[INFO] Create debian packages"
if ! debuild -us -uc -d | sed -e 's/^/ /'; then
if ({ debuild -us -uc -d || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then
echo "[ERROR] Failed to run \"debuild -us -uc\"." 1>&2
exit 1
fi
Expand All @@ -543,13 +562,13 @@ fi
for _one_pkg in ${FOUND_DEB_PACKAGES}; do
echo ""
echo "[INFO] ${_one_pkg} package information"
if ! dpkg -c "${_one_pkg}" | sed -e 's/^/ /'; then
if ({ dpkg -c "${_one_pkg}" || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then
echo "[ERROR] Failed to print ${_one_pkg} package insformation by \"dpkg -c\"." 1>&2
exit 1
fi
echo " ---------------------------"

if ! dpkg -I "${_one_pkg}" | sed -e 's/^/ /'; then
if ({ dpkg -I "${_one_pkg}" || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then
echo "[ERROR] Failed to print ${_one_pkg} package insformation by \"dpkg -I\"." 1>&2
exit 1
fi
Expand Down
31 changes: 25 additions & 6 deletions buildutils/rpm_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,28 @@
# REVISION:
#

#==============================================================
# Autobuild for rpm package
#==============================================================
#
# Autobuid for rpm 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
Expand Down Expand Up @@ -184,13 +203,13 @@ done
# Run configure for package version
#
echo "[INFO] Run autogen"
if ! "${SRCTOP}"/autogen.sh | sed -e 's/^/ /'; then
if ({ "${SRCTOP}"/autogen.sh || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then
echo "[ERROR] Failed to run autogen.sh." 1>&2
exit 1
fi
echo ""
echo "[INFO] Run configure"
if ! /bin/sh -c "${SRCTOP}/configure ${CONFIGUREOPT}" | sed -e 's/^/ /'; then
if ({ /bin/sh -c "${SRCTOP}/configure ${CONFIGUREOPT}" || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then
echo "[ERROR] Failed to run configure." 1>&2
exit 1
fi
Expand All @@ -217,7 +236,7 @@ if [ "$(git status -s | wc -l)" -eq 0 ]; then
#
# make source package(tar.gz) by git archive
#
if ! git archive HEAD --prefix="${PACKAGE_NAME}-${PACKAGE_VERSION}/" --output="${RPM_TOPDIR}/SOURCES/${PACKAGE_NAME}-${PACKAGE_VERSION}.tar.gz" | sed -e 's/^/ /'; then
if ({ git archive HEAD --prefix="${PACKAGE_NAME}-${PACKAGE_VERSION}/" --output="${RPM_TOPDIR}/SOURCES/${PACKAGE_NAME}-${PACKAGE_VERSION}.tar.gz" || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then
echo "[ERROR] Could not make source tar ball(${RPM_TOPDIR}/SOURCES/${PACKAGE_NAME}-${PACKAGE_VERSION}.tar.gz) from github repository." 1>&2
exit 1
fi
Expand All @@ -231,7 +250,7 @@ else
#
# make dist package(tar.gz) and copy it
#
if ! make dist | sed -e 's/^/ /'; then
if ({ make dist || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then
echo "[ERROR] Failed to create dist package(make dist)." 1>&2
exit 1
fi
Expand Down Expand Up @@ -259,7 +278,7 @@ fi
# build RPM packages
#
echo "[INFO] Create RPM packages"
if ! /bin/sh -c "rpmbuild -vv -ba ${RUN_AUTOGEN_FLAG} --define \"_topdir ${RPM_TOPDIR}\" --define \"_prefix /usr\" --define \"_mandir /usr/share/man\" --define \"_defaultdocdir /usr/share/doc\" --define \"package_revision ${BUILD_NUMBER}\" *.spec" 2>&1 | sed -e 's/^/ /'; then
if ({ /bin/sh -c "rpmbuild -vv -ba ${RUN_AUTOGEN_FLAG} --define \"_topdir ${RPM_TOPDIR}\" --define \"_prefix /usr\" --define \"_mandir /usr/share/man\" --define \"_defaultdocdir /usr/share/doc\" --define \"package_revision ${BUILD_NUMBER}\" *.spec" 2>&1 || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then
echo "[ERROR] Failed to build rpm packages by rpmbuild." 1>&2
exit 1
fi
Expand Down

0 comments on commit 3193b35

Please sign in to comment.