Improve maksrc build-centos.sh scripts

This commit is contained in:
Thiago Silva 2022-06-06 17:10:48 -03:00
commit c7103e6544
No known key found for this signature in database
GPG key ID: 034303EB8F453169
2 changed files with 17 additions and 13 deletions

View file

@ -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

View file

@ -1,26 +1,25 @@
#!/bin/bash
if [ -e $2 ]; then
if [ -e "${2}" ]; then
echo "makesrc <tag> <repo>" >&2
echo " tag valid <tag> for <repo>" >&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