From 4c8e118e400cddccef9115545e8ca130bd9bc169 Mon Sep 17 00:00:00 2001 From: Jamie Curnow Date: Thu, 8 Dec 2022 10:19:49 +1000 Subject: [PATCH] v2.2.1 --- .gitignore | 7 +++ Jenkinsfile.centos7 | 45 +++++++++++++++++ Jenkinsfile.centos8 | 45 +++++++++++++++++ README.md | 3 ++ SPECS/ncdu.spec | 36 ++++++++++++++ build | 115 ++++++++++++++++++++++++++++++++++++++++++++ rpm.json | 7 +++ 7 files changed, 258 insertions(+) create mode 100644 .gitignore create mode 100644 Jenkinsfile.centos7 create mode 100644 Jenkinsfile.centos8 create mode 100644 README.md create mode 100644 SPECS/ncdu.spec create mode 100755 build create mode 100644 rpm.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e561d90 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +.idea +._* +.DS_Store +RPMS +SRPMS +DEPS +SOURCES/* diff --git a/Jenkinsfile.centos7 b/Jenkinsfile.centos7 new file mode 100644 index 0000000..c47d0ce --- /dev/null +++ b/Jenkinsfile.centos7 @@ -0,0 +1,45 @@ +@Library('jc21') _ + +pipeline { + options { + buildDiscarder(logRotator(numToKeepStr: '10')) + disableConcurrentBuilds() + ansiColor('xterm') + } + agent { + label 'rpmbuild' + } + stages { + stage('Build') { + steps { + sh './build 7' + } + } + stage('Sign') { + steps { + rpmSign() + } + } + stage('Publish') { + steps { + dir(path: 'RPMS') { + archiveArtifacts(artifacts: '**/*/*.rpm', caseSensitive: true, onlyIfSuccessful: true) + } + dir(path: 'SRPMS') { + archiveArtifacts(artifacts: '**/*.src.rpm', caseSensitive: true, onlyIfSuccessful: true, allowEmptyArchive: true) + } + rpmGithubRelease('centos7') + } + } + } + post { + success { + juxtapose event: 'success' + sh 'figlet "SUCCESS"' + } + failure { + juxtapose event: 'failure' + sh 'figlet "FAILURE"' + } + } +} diff --git a/Jenkinsfile.centos8 b/Jenkinsfile.centos8 new file mode 100644 index 0000000..c5c3579 --- /dev/null +++ b/Jenkinsfile.centos8 @@ -0,0 +1,45 @@ +@Library('jc21') _ + +pipeline { + options { + buildDiscarder(logRotator(numToKeepStr: '10')) + disableConcurrentBuilds() + ansiColor('xterm') + } + agent { + label 'rpmbuild' + } + stages { + stage('Build') { + steps { + sh './build 8' + } + } + stage('Sign') { + steps { + rpmSign() + } + } + stage('Publish') { + steps { + dir(path: 'RPMS') { + archiveArtifacts(artifacts: '**/*/*.rpm', caseSensitive: true, onlyIfSuccessful: true) + } + dir(path: 'SRPMS') { + archiveArtifacts(artifacts: '**/*.src.rpm', caseSensitive: true, onlyIfSuccessful: true, allowEmptyArchive: true) + } + rpmGithubRelease('centos8') + } + } + } + post { + success { + juxtapose event: 'success' + sh 'figlet "SUCCESS"' + } + failure { + juxtapose event: 'failure' + sh 'figlet "FAILURE"' + } + } +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..212c760 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# [ncdu](https://dev.yorhel.nl/ncdu) + +Builds for Centos 7/8 hosted on [yum.jc21.com](https://yum.jc21.com) diff --git a/SPECS/ncdu.spec b/SPECS/ncdu.spec new file mode 100644 index 0000000..b82fbe7 --- /dev/null +++ b/SPECS/ncdu.spec @@ -0,0 +1,36 @@ +%global debug_package %{nil} + +Name: ncdu +Version: 2.2.1 +Release: 1 +Summary: Ncdu is a disk usage analyzer with an ncurses interface +Group: Applications/System +License: GPLv2 +URL: https://dev.yorhel.nl/%{name} +Source: https://dev.yorhel.nl/download/%{name}-%{version}-linux-x86_64.tar.gz + +%description +Ncdu is a disk usage analyzer with an ncurses interface. It is designed to find +space hogs on a remote server where you don’t have an entire graphical setup +available, but it is a useful tool even on regular desktop systems. Ncdu aims +to be fast, simple and easy to use, and should be able to run in any minimal +POSIX-like environment with ncurses installed. + +%prep +%setup -q -c %{name}-%{version} + +%install +rm -rf %{buildroot} +mkdir -p %{buildroot}/usr/bin +cp %{name} %{buildroot}/usr/bin/ + +%clean +rm -rf %{buildroot} + +%files +%defattr(-,root,root,-) +/usr/bin/%{name} + +%changelog +* Thu Dec 8 2022 Jamie Curnow - 2.2.1-1 +- Initial spec diff --git a/build b/build new file mode 100755 index 0000000..6808d60 --- /dev/null +++ b/build @@ -0,0 +1,115 @@ +#!/bin/bash + +################################################## +# +# ./build CENTOS_VERSION [DOCKER_TAG] [SPEC_FILE] +# +# If no docker tag, `latest` is used +# If no Spec file (without .spec), all spec files +# found will be built. +# +# ie: +# ./build 7 golang php-pecl-memcache_php72_php73 +# +################################################## + +CWD=$(pwd) +CYAN='\E[1;36m' +RED='\E[1;31m' +YELLOW='\E[1;33m' +GREEN='\E[1;32m' +BLUE='\E[1;34m' +RESET='\E[0m' + +CENTOS_VERSION=$1 +if [ "$CENTOS_VERSION" == "" ]; then + echo -e "${RED}ERROR: You must specify a Centos version to build for, either 7 or 8" + echo -e "ie: ./build 7${RESET}" + exit 1 +fi + +DOCKER_TAG=$2 +if [ "$DOCKER_TAG" == "" ]; then + DOCKER_TAG=latest +fi + +SPECIFIC_SPEC_FILE=$3 + +# Loop over all Specs in the SPECS folder +for SPECFILE in SPECS/*.spec; do + PACKAGE=${SPECFILE#"SPECS/"} + PACKAGE=${PACKAGE%".spec"} + + if [ "${SPECIFIC_SPEC_FILE}" == "" ] || [ "${SPECIFIC_SPEC_FILE}" == "${PACKAGE}" ]; then + echo -e "${BLUE}❯ ${GREEN}Building ${CYAN}${PACKAGE} ${GREEN}for Centos ${CENTOS_VERSION}${RESET}" + + # Make sure docker exists + if hash docker 2>/dev/null; then + # Generate a Docker image based on env vars and centos version, for use both manually and in CI + eval "DOCKER_IMAGE=\$\{DOCKER_RPMBUILD_EL${CENTOS_VERSION}:-jc21/rpmbuild-centos${CENTOS_VERSION}\}" + eval "DOCKER_IMAGE=${DOCKER_IMAGE}" + + # Folder setup + echo -e "${BLUE}❯ ${YELLOW}Folder setup${RESET}" + rm -rf RPMS/* SRPMS/* + mkdir -p {RPMS,SRPMS,DEPS,SPECS,SOURCES} + chmod -R 777 {RPMS,SRPMS} + + # Pull latest builder image + echo -e "${BLUE}❯ ${YELLOW}Pulling docker image: ${DOCKER_IMAGE}:${DOCKER_TAG}${RESET}" + docker pull "${DOCKER_IMAGE}:${DOCKER_TAG}" + + # Use the build to change the ownership of folders + echo -e "${BLUE}❯ ${YELLOW}Temporarily changing ownership${RESET}" + docker run --rm \ + -v "${CWD}:/home/rpmbuilder/rpmbuild" \ + "${DOCKER_IMAGE}:${DOCKER_TAG}" \ + sudo chown -R rpmbuilder:rpmbuilder /home/rpmbuilder/rpmbuild + + # Do the build + echo -e "${BLUE}❯ ${YELLOW}Building ${PACKAGE}${RESET}" + + DISABLE_MIRROR= + if [ -n "$NOMIRROR" ]; then + DISABLE_MIRROR=-m + fi + + # If centos 8, we want -n option + NOBEST= + if [ "${CENTOS_VERSION}" == "8" ]; then + NOBEST=-n + fi + + # Docker Run + RPMBUILD=/home/rpmbuilder/rpmbuild + docker run --rm \ + --name "rpmbuild-${BUILD_TAG:-centos${CENTOS_VERSION}-${PACKAGE}}" \ + -v "${CWD}/DEPS:${RPMBUILD}/DEPS" \ + -v "${CWD}/RPMS:${RPMBUILD}/RPMS" \ + -v "${CWD}/SRPMS:${RPMBUILD}/SRPMS" \ + -v "${CWD}/SPECS:${RPMBUILD}/SPECS" \ + -v "${CWD}/SOURCES:${RPMBUILD}/SOURCES" \ + -e "GOPROXY=${GOPROXY}" \ + "${DOCKER_IMAGE}:${DOCKER_TAG}" \ + /bin/build-spec ${DISABLE_MIRROR} ${NOBEST} -o -r /home/rpmbuilder/rpmbuild/DEPS/*/*.rpm -- "/home/rpmbuilder/rpmbuild/SPECS/${PACKAGE}.spec" + + BUILD_SUCCESS=$? + + # Change ownership back + echo -e "${BLUE}❯ ${YELLOW}Reverting ownership${RESET}" + docker run --rm \ + -v "${CWD}:/home/rpmbuilder/rpmbuild" \ + "${DOCKER_IMAGE}:${DOCKER_TAG}" \ + sudo chown -R "$(id -u):$(id -g)" /home/rpmbuilder/rpmbuild + + # do we need to exit the loop? + if [ $BUILD_SUCCESS -ne 0 ]; then + echo -e "${BLUE}❯ ${RED}Exiting due to error${RESET}" + exit ${BUILD_SUCCESS} + fi + else + echo -e "${RED}ERROR: Docker command is not available${RESET}" + exit 1 + fi + fi +done diff --git a/rpm.json b/rpm.json new file mode 100644 index 0000000..d03e7b8 --- /dev/null +++ b/rpm.json @@ -0,0 +1,7 @@ +{ + "publish": { + "PACKAGE": "ncdu", + "GH_USER": "jc21-rpm", + "VERSION": "2.2.1" + } +}