From c7103e6544863de1787c9b37b351c21595bd1219 Mon Sep 17 00:00:00 2001 From: Thiago Silva Date: Mon, 6 Jun 2022 17:10:48 -0300 Subject: [PATCH] Improve maksrc build-centos.sh scripts --- ci/build-centos.sh | 8 +++++--- util/makesrc | 22 ++++++++++++---------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/ci/build-centos.sh b/ci/build-centos.sh index 117a7555..bfd3f707 100755 --- a/ci/build-centos.sh +++ b/ci/build-centos.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash TAG=$(echo $TAG) -VERSIONS=${TAG//V/} +VERSION=$(echo "${TAG}" | sed 's/V//' | sed 's/-/_/g') RPM_RELEASE=$(echo $RPM_RELEASE) REPO_TO_BUILD=$(echo $REPO_TO_BUILD) @@ -10,7 +10,7 @@ run_source() { run_build() { mkdir -p ~/rpmbuild/SOURCES/ - mv -f ~/nano-${VERSIONS}.tar.gz ~/rpmbuild/SOURCES/. + mv -f ~/nano-${VERSION}.tar.gz ~/rpmbuild/SOURCES/. if [ "${LIVE:-}" == "1" ]; then scl enable devtoolset-7 'rpmbuild -ba nanocurrency.spec' else @@ -25,7 +25,7 @@ run_update() { echo "Updating \"${outfile}\"..." rm -f "${file}.new" - awk -v srch="@VERSION@" -v repl="$VERSIONS" -v srch2="@RELEASE@" -v repl2="$RPM_RELEASE" '{ sub(srch,repl,$0); sub(srch2,repl2, $0); print $0}' <${file} >${file}.new + awk -v srch="@VERSION@" -v repl="$VERSION" -v srch2="@RELEASE@" -v repl2="$RPM_RELEASE" '{ sub(srch,repl,$0); sub(srch2,repl2, $0); print $0}' <${file} >${file}.new rm -fr "${outfile}" cat "${file}.new" >"${outfile}" rm -f "${file}.new" @@ -33,6 +33,8 @@ run_update() { done } +set -x + run_update run_source run_build diff --git a/util/makesrc b/util/makesrc index 9ba5ba9e..8c33e714 100755 --- a/util/makesrc +++ b/util/makesrc @@ -1,26 +1,25 @@ #!/bin/bash -if [ -e $2 ]; then +if [ -e "${2}" ]; then echo "makesrc " >&2 echo " tag valid for " >&2 echo " repo repository to build" >&2 exit 1 fi -TAG="$1" +TAG="${1}" repository="${2:-nanocurrency/nano-node}" -VERSION=$(echo $TAG | sed 's/V//') +VERSION=$(echo "${TAG}" | sed 's/V//' | sed 's/-/_/g') TAG_DATE="" -VERSION_MAJOR=$(echo $VERSION | cut -d "." -f 1) scriptDir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" function make_source() { git clone --recursive --single-branch --branch "${TAG}" "https://github.com/${repository}" "nano-${VERSION}" - cd nano-$VERSION + cd "nano-${VERSION}" git fetch --tags COUNT=$(git tag -l "${TAG}" | wc -l) if [ "$COUNT" -eq 0 ]; then - echo "tag $TAG not found" + echo "tag ${TAG} not found" exit 1 else git checkout "${TAG}" @@ -35,13 +34,13 @@ function make_source() { function source_information() { DATE=$(git log --tags --simplify-by-decoration --pretty="format:%ai %d" | head -1 | cut -d " " -f1-3) COMMIT=$(git log | head -1 | cut -d " " -f 2) - TAG_DATE=$(TZ=UTC date -d"$DATE" +%s) + TAG_DATE=$(TZ=UTC date -d"${DATE}" +%s) export TAG_DATE } function cleanup_source() { - mv nano-$VERSION.tar.gz ~/. + mv "nano-${VERSION}.tar.gz" ~/. echo "ARCHIVE MOVDED TO HOME..." - rm -fr nano-$TAG/ + rm -fr "nano-${VERSION}"/ } function tarball_creation() { @@ -61,7 +60,10 @@ function tarball_creation() { tarArgs=("${tarArgs[@]}" --mtime="@${TAG_DATE}") fi fi - TZ=UTC LANG=C LC_ALL=C tar "${tarArgs[@]}" -cvf - nano-${VERSION} | TZ=UTC gzip --no-name -9c >"${ARCHIVE_FILE_NAME}" || exit 1 + TZ=UTC LANG=C LC_ALL=C tar "${tarArgs[@]}" -cvf - "nano-${VERSION}" | TZ=UTC gzip --no-name -9c >"${ARCHIVE_FILE_NAME}" || exit 1 } + +set -x + make_source cleanup_source