Skip to content

Commit

Permalink
Merge pull request #57 from essentialkaos/develop
Browse files Browse the repository at this point in the history
Version 2.2.0
  • Loading branch information
andyone authored May 11, 2018
2 parents 16379f2 + cfc03d3 commit 51b7106
Show file tree
Hide file tree
Showing 14 changed files with 222 additions and 117 deletions.
18 changes: 7 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@ language: bash

sudo: false

addons:
apt:
sources:
- debian-sid
packages:
- shellcheck
before_install:
- make get-shellcheck

script:
- bash -c 'shopt -s globstar; shellcheck SOURCES/rpmbuilder SOURCES/libexec/*.shx'
- bash -c 'shopt -s globstar; shellcheck SOURCES/rpmunbuilder'
- bash -c 'shopt -s globstar; shellcheck SOURCES/buildmon'
- bash -c 'shopt -s globstar; shellcheck SOURCES/initenv'
- bash -c 'shopt -s globstar; shellcheck SOURCES/nodeinfo'
- bash -c 'shopt -s globstar; ./shellcheck-latest/shellcheck SOURCES/rpmbuilder SOURCES/libexec/*.shx'
- bash -c 'shopt -s globstar; ./shellcheck-latest/shellcheck SOURCES/rpmunbuilder'
- bash -c 'shopt -s globstar; ./shellcheck-latest/shellcheck SOURCES/buildmon'
- bash -c 'shopt -s globstar; ./shellcheck-latest/shellcheck SOURCES/initenv'
- bash -c 'shopt -s globstar; ./shellcheck-latest/shellcheck SOURCES/nodeinfo'

matrix:
fast_finish: true
30 changes: 30 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

########################################################################################

export PATH := shellcheck-latest:$(PATH)

########################################################################################

.DEFAULT_GOAL := help
.PHONY = test help

########################################################################################

get-shellcheck: ## Download latest version of shellcheck
wget https://storage.googleapis.com/shellcheck/shellcheck-latest.linux.x86_64.tar.xz
tar xf shellcheck-latest.linux.x86_64.tar.xz

test: ## Run shellcheck tests
shellcheck SOURCES/rpmbuilder SOURCES/libexec/*.shx
shellcheck SOURCES/rpmunbuilder
shellcheck SOURCES/buildmon
shellcheck SOURCES/initenv
shellcheck SOURCES/nodeinfo

help: ## Show this info
@echo -e '\nSupported targets:\n'
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| awk 'BEGIN {FS = ":.*?## "}; {printf " \033[33m%-12s\033[0m %s\n", $$1, $$2}'
@echo -e ''

################################################################################
14 changes: 7 additions & 7 deletions readme.md → README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
<p align="center"><a href="#usage-demo">Usage demo</a> • <a href="#installation">Installation</a> • <a href="#usage">Usage</a> • <a href="#contributing">Contributing</a> • <a href="#license">License</a></p>

<p align="center"><a href="#readme"><img src="https://gh.kaos.io/rpmbuilder.svg"/></a></p>
<p align="center"><a href="#readme"><img src="https://gh.kaos.st/rpmbuilder.svg"/></a></p>

`rpmbuilder` is RPM package build helper.

### Usage demo

Building Redis rpm package for CentOS6 and CentOS7:

[![demo](https://gh.kaos.io/rpmbuilder-190.gif)](#usage-demo)
[![demo](https://gh.kaos.st/rpmbuilder-190.gif)](#usage-demo)

### Installation

#### From ESSENTIAL KAOS Public repo for RHEL6/CentOS6
```
[sudo] yum install -y https://yum.kaos.io/6/release/x86_64/kaos-repo-8.0-0.el6.noarch.rpm
[sudo] yum install -y https://yum.kaos.st/6/release/x86_64/kaos-repo-9.1-0.el6.noarch.rpm
[sudo] yum install rpmbuilder
```

Build node:

```
[sudo] yum install -y https://yum.kaos.io/6/release/x86_64/kaos-repo-8.0-0.el6.noarch.rpm
[sudo] yum install -y https://yum.kaos.st/6/release/x86_64/kaos-repo-9.1-0.el6.noarch.rpm
[sudo] yum install rpmbuilder-node
[sudo] passwd builder
... change builder user password here
Expand All @@ -31,14 +31,14 @@ Build node:

#### From ESSENTIAL KAOS Public repo for RHEL7/CentOS7
```
[sudo] yum install -y https://yum.kaos.io/7/release/x86_64/kaos-repo-8.0-0.el7.noarch.rpm
[sudo] yum install -y https://yum.kaos.st/7/release/x86_64/kaos-repo-9.1-0.el7.noarch.rpm
[sudo] yum install rpmbuilder
```

Build node:

```
[sudo] yum install -y https://yum.kaos.io/7/release/x86_64/kaos-repo-8.0-0.el7.noarch.rpm
[sudo] yum install -y https://yum.kaos.st/7/release/x86_64/kaos-repo-9.1-0.el7.noarch.rpm
[sudo] yum install rpmbuilder-node
[sudo] passwd builder
... change builder user password here
Expand Down Expand Up @@ -186,4 +186,4 @@ Before contributing to this project please read our [Contributing Guidelines](ht

[EKOL](https://essentialkaos.com/ekol)

<p align="center"><a href="https://essentialkaos.com"><img src="https://gh.kaos.io/ekgh.svg"/></a></p>
<p align="center"><a href="https://essentialkaos.com"><img src="https://gh.kaos.st/ekgh.svg"/></a></p>
10 changes: 10 additions & 0 deletions SOURCES/conf/rpmlint
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from Config import *

# This macro is platform specific and dumb, just skip this error
addFilter("E: lib-package-without-%mklibname")

# In some cases we build source archive with different tools (like gopack)
addFilter("W: invalid-url")

# Some configure scripts don't support libdir option
addFilter("W: configure-without-libdir-spec")
29 changes: 10 additions & 19 deletions SOURCES/libexec/build-local.shx
Original file line number Diff line number Diff line change
Expand Up @@ -139,35 +139,26 @@ localDepsInstall() {
# Code: No
# Echo: No
localSpecValidate() {
if ! checkDeps "rpmlint" ; then
error "Can't validate spec file - rpmlint not installed!" $RED
if ! hasApp "perfecto" ; then
error "Can't validate spec file - perfecto not installed!" $RED
return 1
fi

local spec="$1"
local opts="-e critical"

local result
result=$(rpmlint "$spec")
[[ -n "$strict" ]] && opts="-e error"
[[ -n "$pedantic" ]] && opts="-e warning"
[[ -n "$perfect" ]] && opts="-e notice"
[[ -n "$no_colors" ]] && opts="$opts -nc"

show "Spec file check result:" $CYAN
show "$result"
perfecto -f short $opts "$1"

# shellcheck disable=SC2143
if [[ -n "$strict" && $(echo "$result" | grep " E: ") ]] ; then
if [[ $? -ne 0 ]] ; then
show ""
error "Build canceled because spec has errors and strict mode is enabled" $YELLOW
error "Build canceled because spec contains problems reported by perfecto" $RED
doExit $ERROR_LINT
fi

if [[ -n "$pedantic" ]] ; then
# shellcheck disable=SC2143
if [[ $(echo "$result" | grep " E: ") || $(echo "$result" | grep " W: ") ]] ; then
show ""
error "Build canceled because spec has errors or warnings and a pedantic mode is enabled" $YELLOW
doExit $ERROR_LINT
fi
fi

[[ -n "$verbose" ]] && sleep $LINT_WAIT
}

Expand Down
28 changes: 11 additions & 17 deletions SOURCES/libexec/build-remote.shx
Original file line number Diff line number Diff line change
Expand Up @@ -269,32 +269,26 @@ remoteDepsInstall() {
remoteSpecValidate() {
local spec="$1"

local rpmbuild_dir specs_dir result
local opts="-e critical"

[[ -n "$strict" ]] && opts="-e error"
[[ -n "$pedantic" ]] && opts="-e warning"
[[ -n "$perfect" ]] && opts="-e notice"
[[ -n "$no_colors" ]] && opts="$opts -nc"

local rpmbuild_dir specs_dir

rpmbuild_dir=$(getRPMBuildDir)
specs_dir="$rpmbuild_dir/SPECS"

result=$(sshCommand "$user@$host" "cd $specs_dir && rpmlint $spec" 2> /dev/null)
sshCommand "$user@$host" "cd $specs_dir && perfecto -f short $opts $spec"

show "Spec file check result:" $CYAN
show "$result"

# shellcheck disable=SC2143
if [[ -n "$strict" && $(echo "$result" | grep " E: ") ]] ; then
if [[ $? -ne 0 ]] ; then
show ""
error "Build canceled because spec has errors and strict mode is enabled" $YELLOW
error "Build canceled because spec contains problems reported by perfecto" $RED
doExit $ERROR_LINT
fi

if [[ -n "$pedantic" ]] ; then
# shellcheck disable=SC2143
if [[ $(echo "$result" | grep " E: ") || $(echo "$result" | grep " W: ") ]] ; then
show ""
error "Build canceled because spec has errors or warnings and a pedantic mode is enabled" $YELLOW
doExit $ERROR_LINT
fi
fi

[[ -n "$verbose" ]] && sleep $LINT_WAIT
}

Expand Down
25 changes: 15 additions & 10 deletions SOURCES/libexec/build.shx
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ checkOptions() {
doExit $ERROR_ARGS
fi

if ! hasApp "perfecto" && [[ -n "$perfect" ]] ; then
error "Can't start build process - for using --perfect argument, you must install perfecto first" $RED
doExit $ERROR_DEPS
fi

if [[ -n "$dest_dir" && ! -d $dest_dir ]] ; then
error "Can't start build process - destination directory doesn't exist" $RED
doExit $ERROR_ARGS
Expand All @@ -220,47 +225,47 @@ checkOptions() {
doExit $ERROR_ARGS
fi

if ! checkDeps "git" && [[ -n "$git" ]] ; then
if ! hasApp "git" && [[ -n "$git" ]] ; then
error "Can't start build process - for using --git argument, you must install git first" $RED
doExit $ERROR_DEPS
fi

if ! checkDeps "svn" && [[ -n "$svn" ]] ; then
if ! hasApp "svn" && [[ -n "$svn" ]] ; then
error "Can't start build process - for using --svn argument, you must install svn first" $RED
doExit $ERROR_DEPS
fi

if ! checkDeps "hg" && [[ -n "$hg" ]] ; then
if ! hasApp "hg" && [[ -n "$hg" ]] ; then
error "Can't start build process - for using --hg argument, you must install hg first" $RED
doExit $ERROR_DEPS
fi

if ! checkDeps "bzr" && [[ -n "$bzr" ]] ; then
if ! hasApp "bzr" && [[ -n "$bzr" ]] ; then
error "Can't start build process - for using --bzr argument, you must install bzr first" $RED
doExit $ERROR_DEPS
fi

if ! checkDeps "gopack" && [[ -n "$gopack" ]] ; then
if ! hasApp "gopack" && [[ -n "$gopack" ]] ; then
error "Can't start build process - for using --gopack argument, you must install gopack first" $RED
doExit $ERROR_DEPS
fi

if ! checkDeps "sshpass" && [[ -n "$pass" ]] ; then
if ! hasApp "sshpass" && [[ -n "$pass" ]] ; then
error "Can't start build process - for using --pass argument, you must install sshpass first" $RED
doExit $ERROR_DEPS
fi

if ! checkDeps "rpmbuild" "rpmlint" && [[ -z "$remote" ]] ; then
if ! hasApp "rpmbuild" "rpmlint" && [[ -z "$remote" ]] ; then
error "Can't start local build process - you must install rpmbuild and rpmlint first" $RED
doExit $ERROR_DEPS
fi

if ! checkDeps "rpm" && [[ -n "$sign" && -z "$remote" ]] ; then
if ! hasApp "rpm" && [[ -n "$sign" && -z "$remote" ]] ; then
error "Can't start local build process - for signing packages you must install rpm first" $RED
doExit $ERROR_DEPS
fi

if ! checkDeps "spectool" ; then
if ! hasApp "spectool" ; then
error "Can't start local build process - spectool (part of rpmdevtools) is required" $RED
doExit $ERROR_DEPS
fi
Expand All @@ -276,7 +281,7 @@ checkOptions() {
fi

if [[ -n "$bump" ]] ; then
if ! checkDeps "rpmdev-packager" "rpmdev-bumpspec" ; then
if ! hasApp "rpmdev-packager" "rpmdev-bumpspec" ; then
error "Can't start build process - for automatic release bumping you must install rpmdev-bumpspec and rpmdev-packager (from rpmdevtools package) first" $RED
doExit $ERROR_DEPS
fi
Expand Down
6 changes: 3 additions & 3 deletions SOURCES/libexec/sources-remote.shx
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ isAccessibleURL() {
code=$(echo -e "$status" | grep "HTTP" | cut -f2 -d" " | tail -1)
nosniff=$(echo -e "$status" | grep "X-Content-Type-Options: nosniff")

# Nosniff mode works on Google Code, if we simple try check status server return
# code 404, but we can download this file
[[ -n $nosniff || "$code" == "200" ]] && return 0 || return 1
# Nosniff mode works on Google Code and if we simply try to check status server
# return code 404, but we can download this file
[[ -n "$nosniff" || "$code" == "200" ]] && return 0 || return 1
elif [[ "$1" =~ ftp: ]] ; then
status=$(curl -A "$USER_AGENT" "$1" -Is)
size=$(echo "$status" | grep "Content-Length" | cut -f2 -d" ")
Expand Down
4 changes: 2 additions & 2 deletions SOURCES/libexec/utils.shx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

################################################################################

# Check if command is supported on this system
# Checks if given binary is installed on the system
#
# *: Commands (String)
#
# Code: Yes
# Echo: No
checkDeps() {
hasApp() {
local app

for app in "$@" ; do
Expand Down
16 changes: 9 additions & 7 deletions SOURCES/rpmbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
APP="RPMBuilder"

# Utility version (String)
VER="2.1.0"
VER="2.2.0"

####################################################################

Expand Down Expand Up @@ -64,25 +64,26 @@ SEPARATOR="---------------------------------------------------------------------
PREFS_FILE="$HOME/.rpmbuilder"

SUPPORTED_ARGS="remote !parallel host user pass key source_dir source_list
!sign !no_build !no_clean !no_deps !no_lint !no_source pack !pedantic !strict
!sign !no_build !no_clean !no_deps !no_lint !no_source pack !attach
pre post dest dest_dir upload git svn hg bzr branch revision tag svn_user
svn_pass path !bump bump_comment tmp dlcache !depinstall !dep_install github
bitbucket launchpad with without define output !verbose !help !usage !ver
!version !raw_version qa_rpaths tmux_worker !no_colors !keep_log !notify
arch download !relative_pack enable_repo disable_repo exclude_package gopack
!attach"
!strict !pedantic !perfect"

SHORT_ARGS="r:remote P:!parallel hh:host uu:user pp:pass kk:key sd:source_dir
sl:source_list NB:!no_build NC:!no_clean ND:!no_deps NR:!no_binary NS:!no_source
p:pack 0:!no_lint 1:!strict 2:!pedantic pr:pre ps:post d:dest u:upload
p:pack 0:!no_lint 1:!strict 2:!pedantic 3:!perfect pr:pre ps:post d:dest u:upload
su:svn_user sp:svn_pass rp:path b:!bump bc:bump_comment dc:dlcache
di:!depinstall rb:branch rt:tag rr:revision gh:github bb:bitbucket lp:launchpad
w:with W:without s:!sign D:define O:output V:!verbose h:help v:!version
nc:!no_colors kl:!keep_log n:!notify a:arch dl:download R:relative_pack
ER:enable_repo DR:disable_repo EX:exclude_package G:gopack A:!attach"

INSPEC_ARGS="git svn hg bzr branch revision tag svn_user svn_pass github
bitbucket launchpad qa_rpaths pedantic strict no_lint relative_pack gopack"
bitbucket launchpad qa_rpaths no_lint relative_pack gopack strict
pedantic perfect"

MERGEABLE_ARGS="pack with without enable_repo disable_repo exclude_package define"

Expand Down Expand Up @@ -463,8 +464,9 @@ usage() {
show "Spec validation:" $BOLD
show ""
showo "--no-lint, -0" "Don't check spec file before package build"
showo "--strict, -1" "Don't build package if linter found errors in spec file"
showo "--pedantic, -2" "Don't build package if linter found errors or warnings in spec file"
showo "--strict, -1" "Don't build package if perfecto found major problems in spec file"
showo "--pedantic, -2" "Don't build package if perfecto found minor problems in spec file"
showo "--perfect, -3" "Don't build package if perfecto found any problems in spec file"
show ""
show "Other:" $BOLD
show ""
Expand Down
Loading

0 comments on commit 51b7106

Please sign in to comment.