From 22d5adfae154c7c5628a6b0dd45360d01b295e3e Mon Sep 17 00:00:00 2001 From: "Kazushi (Jam) Marukawa" Date: Sun, 27 Aug 2017 11:43:22 +0900 Subject: [PATCH] Move tools from top directory to tools directory and add upload to bintray tools. --- tools/chkfrog.sh | 90 +++++++++++++++ create_package.sh => tools/create_package.sh | 0 .../create_sha_list.sh | 0 .../create_url_list.sh | 0 tools/upfrog.sh | 109 ++++++++++++++++++ .../upload_github_release.sh | 0 6 files changed, 199 insertions(+) create mode 100755 tools/chkfrog.sh rename create_package.sh => tools/create_package.sh (100%) mode change 100644 => 100755 rename create_sha_list.sh => tools/create_sha_list.sh (100%) mode change 100644 => 100755 rename create_url_list.sh => tools/create_url_list.sh (100%) mode change 100644 => 100755 create mode 100755 tools/upfrog.sh rename upload_github_release.sh => tools/upload_github_release.sh (100%) mode change 100644 => 100755 diff --git a/tools/chkfrog.sh b/tools/chkfrog.sh new file mode 100755 index 000000000..6b896dd85 --- /dev/null +++ b/tools/chkfrog.sh @@ -0,0 +1,90 @@ +#!/bin/bash + +# A script to check jfrog (bintray) for binaries existence and update package file +# +# Usage +# +# chkfrog package... Check packages +# +# Directory structure +# +# Unfortunately, we need to have sha256 files locally to update URL correctly. +# +# release/armv7l/*.tar.xz.sha256 SHA256 files for armv7l +# release/i686/*.tar.xz.sha256 SHA256 files for i686 +# release/x86_64/*.tar.xz.sha256 SHA256 files for x86_64 + +URL="https://dl.bintray.com/chromebrew/chromebrew" + +case $# in +0) set `basename -s .rb packages/*` +esac + +function update_url () { + if sed -e '/binary_url.*({/,/})/p; d' packages/$1.rb | grep -q $2:; then +# sed -e "/binary_url.*({/,/})/s,$2:.*,$2: '$3'," -i packages/$1.rb + sed -e "/$2:.*\(http\|https\|ftp\):/c\ \ \ \ $(printf %7s $2): '$3'," -i packages/$1.rb + else + sed -e "/binary_url.*({/a\ \ \ \ $(printf %7s $2): '$3'," -i packages/$1.rb + fi +} +function update_sha256 () { + if sed -e '/binary_sha256.*({/,/})/p; d' packages/$1.rb | grep -q $2:; then +# sed -e "/binary_sha256.*({/,/})/s,$2:.*,$2: '$3'," -i packages/$1.rb + sed -e "/$2:.*['\"][0-9a-f]*['\"]/c\ \ \ \ $(printf %7s $2): '$3'," -i packages/$1.rb + else + sed -e "/binary_sha256.*({/a\ \ \ \ $(printf %7s $2): '$3'," -i packages/$1.rb + fi +} +function get_sha256 () { + if [ -f release/$2/$1.sha256 ]; then + cut -d' ' -f1 release/$2/$1.sha256 + else + echo not found + fi +} +function check_url () { + curl --output /dev/null --silent --header -L --fail $1 +} + +for name in "$@"; do + name=`basename -s .rb $name` + pkg=`echo $name | sed -e 's/-.*//'` + + if ! grep -q binary_url packages/$pkg.rb; then + sed -e '/source_sha256/ a\ +\ +\ \ binary_url ({\ +\ \ })\ +\ \ binary_sha256 ({\ +\ \ })' -i packages/$pkg.rb + fi + version=`grep '\ /dev/null 2> /dev/null +} + +function create_pkg () { + jfrog bt pc $ORG/$REPO/$1 --pub-dn=true --vcs-url=https://github.com/ > /dev/null 2> /dev/null +} + +function check_pkg_ver () { + jfrog bt vs $ORG/$REPO/$1/$2 > /dev/null 2> /dev/null +} + +function upload_pkg_ver () { + jfrog bt u $DRYRUN --override=true --regexp "$REGEXPLOCALPATH/$1-$2-chrome.*\.tar\..z$" "$ORG/$REPO/$1/$2" # > /dev/null 2> /dev/null +} + +function publish_pkg_ver () { + jfrog bt vp "$ORG/$REPO/$1/$2" # > /dev/null 2> /dev/null +} + +function error () { + >&2 echo $1 + exit 1 +} + +for name in "$@"; do + name=`basename -s .rb $name` + pkg=`echo $name | sed -e 's/-.*//'` + + # check file existence + files= + for path in $LOCALPATHS; do + for file in $path/$name-*.tar.?z; do + [ -f $file ] && files="$file $files" + done + done + [ -s "$files" ] && continue + + # check version numbers + versions= + while read version; do + versions="$versions $version" + done < <(for file in $files; do + echo $file | sed -e "s:^.*/$pkg-::" -e 's:-chrome.*$::' + done | sort -n | uniq) + + if [ ! -s $DEBUG ]; then + echo "$name -> $pkg, $versions: $files" + continue + fi + + # create package first + check_pkg $pkg || create_pkg $pkg || error "failed to create $pkg package" + + # upload and publish + for v in $versions; do + v=`echo $v | sed -e s/,/./g` + # check_pkg_ver $pkg $v || error "failed to check version $pkg-$v" + upload_pkg_ver $pkg $v || error "failed to upload $pkg-$v" + publish_pkg_ver $pkg $v || error "failed to publish $pkg-$v" + done +done + diff --git a/upload_github_release.sh b/tools/upload_github_release.sh old mode 100644 new mode 100755 similarity index 100% rename from upload_github_release.sh rename to tools/upload_github_release.sh