diff options
author | 2015-06-22 19:55:07 +0000 | |
---|---|---|
committer | 2015-06-22 19:55:07 +0000 | |
commit | aa3bb2f4ac565031578d965c9757b457461bbbca (patch) | |
tree | c1f580ae815a53d444816afcd388eb7adbe3ffec | |
parent | Add python linter (diff) | |
download | ruby-tinderbox-aa3bb2f4ac565031578d965c9757b457461bbbca.tar.gz ruby-tinderbox-aa3bb2f4ac565031578d965c9757b457461bbbca.tar.bz2 ruby-tinderbox-aa3bb2f4ac565031578d965c9757b457461bbbca.zip |
Fix most issues raised by linters, some python ones remain
-rwxr-xr-x | bin/get_stage3.sh | 2 | ||||
-rwxr-xr-x | bin/packages.py | 17 | ||||
-rwxr-xr-x | bin/provision.sh | 8 | ||||
-rwxr-xr-x | bin/repoman.sh | 3 | ||||
-rwxr-xr-x | bin/tinder.sh | 5 | ||||
-rw-r--r-- | web/Gemfile.lock | 3 | ||||
-rw-r--r-- | web/Rakefile | 2 | ||||
-rw-r--r-- | web/lib/ci.rb | 4 | ||||
-rw-r--r-- | web/lib/helpers.rb | 78 | ||||
-rw-r--r-- | web/lib/packages.rb | 2 |
10 files changed, 70 insertions, 54 deletions
diff --git a/bin/get_stage3.sh b/bin/get_stage3.sh index da04ec2..13a5ce1 100755 --- a/bin/get_stage3.sh +++ b/bin/get_stage3.sh @@ -7,5 +7,5 @@ LATEST_STAGE3=$(curl -s $DIST_MIRROR/releases/amd64/autobuilds/latest-stage3-amd STAGE3_URI="$DIST_MIRROR/releases/amd64/autobuilds/$LATEST_STAGE3" if [[ ! -f "$SCRIPT_DIR/../cache/stage3-amd64.tar.bz2" ]]; then - curl -o "$SCRIPT_DIR/../cache/stage3-amd64.tar.bz2" $STAGE3_URI + curl -o "$SCRIPT_DIR/../cache/stage3-amd64.tar.bz2" "$STAGE3_URI" fi diff --git a/bin/packages.py b/bin/packages.py index ed07e68..fc464e9 100755 --- a/bin/packages.py +++ b/bin/packages.py @@ -4,8 +4,10 @@ import portage, hashlib def format_deps(dep_list): for item in list(dep_list): - if "||" in item: dep_list.remove(item) - if "?" in item: dep_list.remove(item) + if "||" in item: + dep_list.remove(item) + if "?" in item: + dep_list.remove(item) index = 0 for item in list(dep_list): @@ -34,7 +36,14 @@ def get_deps(cpv): def format_output(cpv, slot, iuse, keyword): category, pkgname, version, revision = portage.catpkgsplit(cpv) sha1 = hashlib.sha1(open(porttree.dbapi.findname(cpv), 'rb').read()).hexdigest() - print (sha1 + ' ' + category + ' ' + pkgname + ' ' + version + ' ' + revision + ' ' + slot + ' ' + keyword, end=' ') + print(sha1 + ' ' + \ + category + ' ' + \ + pkgname + ' ' + \ + version + ' ' + \ + revision + ' ' + \ + slot + ' ' + \ + keyword, \ + end=' ') if 'ruby_targets_ruby19' in iuse: print('ruby19', end=' ') else: @@ -66,7 +75,7 @@ for cp in porttree.dbapi.cp_all(): cpvbs = (porttree.dep_bestmatch(cp)) if cpvbs: - slot, iuse, keywords = porttree.dbapi.aux_get(cpvbs, ['SLOT', 'IUSE','KEYWORDS']) + slot, iuse, keywords = porttree.dbapi.aux_get(cpvbs, ['SLOT', 'IUSE', 'KEYWORDS']) if '~amd64' not in keywords and 'amd64' in keywords: format_output(cpvbs, slot, iuse, 'amd64') diff --git a/bin/provision.sh b/bin/provision.sh index cc4f726..c155b56 100755 --- a/bin/provision.sh +++ b/bin/provision.sh @@ -13,12 +13,12 @@ fi emerge-webrsync emerge --metadata -RUBIES="dev-lang/ruby:1.9 dev-lang/ruby:2.0 dev-lang/ruby:2.1 dev-lang/ruby:2.2" +RUBIES=(dev-lang/ruby:1.9 dev-lang/ruby:2.0 dev-lang/ruby:2.1 dev-lang/ruby:2.2) set +e -emerge --pretend --quiet $RUBIES +emerge --pretend --quiet "${RUBIES[@]}" if [[ $? == 1 ]]; then - emerge --autounmask-write $RUBIES + emerge --autounmask-write "${RUBIES[@]}" etc-update --automode -5 fi set -e -emerge --noreplace --quiet $RUBIES +emerge --noreplace --quiet "${RUBIES[@]}" diff --git a/bin/repoman.sh b/bin/repoman.sh index 923b8b2..32e9fc9 100755 --- a/bin/repoman.sh +++ b/bin/repoman.sh @@ -54,7 +54,7 @@ function CLEANUP() { ENV_SETUP -PKG_ARR=($(qatom $1)) +PKG_ARR=($(qatom "$1")) CATEGORY="${PKG_ARR[0]}" NAME="${PKG_ARR[1]}" if [[ ${PKG_ARR[3]:=foo} == 'foo' ]]; then @@ -63,7 +63,6 @@ else VERSION="${PKG_ARR[2]}-${PKG_ARR[3]}" fi -PACKAGE=$1 CURR_TARGET=$2 NEXT_TARGET=$3 SETUP diff --git a/bin/tinder.sh b/bin/tinder.sh index 6d246f4..4c75533 100755 --- a/bin/tinder.sh +++ b/bin/tinder.sh @@ -33,11 +33,12 @@ function SETUP () { cp "/usr/portage/$CATEGORY/$NAME/metadata.xml" "$SCRIPT_DIR/overlay/$CATEGORY/$NAME" cp -r "/usr/portage/$CATEGORY/$NAME/files" "$SCRIPT_DIR/overlay/$CATEGORY/$NAME" || true + ( cd "$SCRIPT_DIR/overlay/$CATEGORY/$NAME" sed -i -e "/^USE_RUBY/s/$CURR_TARGET/$CURR_TARGET $NEXT_TARGET/" "$NAME-$VERSION.ebuild" repoman manifest repoman full - cd - + ) fi set +e @@ -97,7 +98,7 @@ function CLEANUP() { ENV_SETUP -PKG_ARR=($(qatom $1)) +PKG_ARR=($(qatom "$1")) CATEGORY="${PKG_ARR[0]}" NAME="${PKG_ARR[1]}" if [[ ${PKG_ARR[3]:=foo} == "foo" ]]; then diff --git a/web/Gemfile.lock b/web/Gemfile.lock index 4e9f3dd..4f8f644 100644 --- a/web/Gemfile.lock +++ b/web/Gemfile.lock @@ -78,3 +78,6 @@ DEPENDENCIES rubocop sequel sinatra + +BUNDLED WITH + 1.10.3 diff --git a/web/Rakefile b/web/Rakefile index 2fa44ad..066d7a2 100644 --- a/web/Rakefile +++ b/web/Rakefile @@ -5,7 +5,7 @@ task default: 'test' desc 'Run the test suite' task :test do sh 'bundle exec rubocop' - sh "shellcheck #{Dir.glob('../**/*.sh').join(' ')}" + sh "shellcheck --exclude=SC2016 #{Dir.glob('../**/*.sh').join(' ')}" sh "pylint --reports=n #{Dir.glob('../**/*.py').join(' ')}" Dir.glob('./test/test_*.rb') { |f| require f } end diff --git a/web/lib/ci.rb b/web/lib/ci.rb index 80de8fb..c3839c9 100644 --- a/web/lib/ci.rb +++ b/web/lib/ci.rb @@ -8,9 +8,9 @@ def run_ci(volume_container, ci_image, ci_type, num_of_packages) next_target = package[2] if ci_type == 'build' - cmd = %W[/ruby-tinderbox/tinder.sh #{identifier} #{current_target} #{next_target}] + cmd = %W(/ruby-tinderbox/tinder.sh #{identifier} #{current_target} #{next_target}) elsif ci_type == 'repoman' - cmd = %W[/ruby-tinderbox/repoman.sh #{identifier} #{current_target} #{next_target}] + cmd = %W(/ruby-tinderbox/repoman.sh #{identifier} #{current_target} #{next_target}) end ci_container = Docker::Container.create( Cmd: cmd, diff --git a/web/lib/helpers.rb b/web/lib/helpers.rb index ab96e20..d01e39d 100644 --- a/web/lib/helpers.rb +++ b/web/lib/helpers.rb @@ -4,52 +4,56 @@ class String end end -module Archive::Tar::Minitar - class << self - def pack_file(entry, outputter) - outputter = outputter.tar if outputter.kind_of?(Archive::Tar::Minitar::Output) +module Archive + module Tar + module Minitar + class << self + def pack_file(entry, outputter) + outputter = outputter.tar if outputter.is_a?(Archive::Tar::Minitar::Output) - stats = {} + stats = {} - if entry.kind_of?(Hash) - name = entry[:name] + if entry.is_a?(Hash) + name = entry[:name] - entry.each { |kk, vv| stats[kk] = vv unless vv.nil? } - else - name = entry - end + entry.each { |kk, vv| stats[kk] = vv unless vv.nil? } + else + name = entry + end - name = name.sub(%r{\./}, '') - stat = File.stat(name) - stats[:mode] ||= stat.mode - stats[:mtime] ||= stat.mtime - stats[:size] = stat.size + name = name.sub(/\.\//, '') + stat = File.stat(name) + stats[:mode] ||= stat.mode + stats[:mtime] ||= stat.mtime + stats[:size] = stat.size - if RUBY_PLATFORM =~ /win32/ - stats[:uid] = nil - stats[:gid] = nil - else - stats[:uid] ||= stat.uid - stats[:gid] ||= stat.gid - end + if RUBY_PLATFORM =~ /win32/ + stats[:uid] = nil + stats[:gid] = nil + else + stats[:uid] ||= stat.uid + stats[:gid] ||= stat.gid + end - case - when File.file?(name) - outputter.add_file_simple(name, stats) do |os| - stats[:current] = 0 - yield :file_start, name, stats if block_given? - File.open(name, "rb") do |ff| - until ff.eof? - stats[:currinc] = os.write(ff.read(4096)) - stats[:current] += stats[:currinc] - yield :file_progress, name, stats if block_given? + case + when File.file?(name) + outputter.add_file_simple(name, stats) do |os| + stats[:current] = 0 + yield :file_start, name, stats if block_given? + File.open(name, 'rb') do |ff| + until ff.eof? + stats[:currinc] = os.write(ff.read(4096)) + stats[:current] += stats[:currinc] + yield :file_progress, name, stats if block_given? + end + end + yield :file_done, name, stats if block_given? end + when dir?(name) + yield :dir, name, stats if block_given? + outputter.mkdir(name, stats) end - yield :file_done, name, stats if block_given? end - when dir?(name) - yield :dir, name, stats if block_given? - outputter.mkdir(name, stats) end end end diff --git a/web/lib/packages.rb b/web/lib/packages.rb index 3e5a8bc..8cad6d4 100644 --- a/web/lib/packages.rb +++ b/web/lib/packages.rb @@ -1,5 +1,5 @@ def update_packages(ci_image) - cmd = %W[/ruby-tinderbox/packages.py | sort -u] + cmd = %w(/ruby-tinderbox/packages.py | sort -u) ci_container = Docker::Container.create( Cmd: cmd, Image: ci_image.id |