Move tools from top directory to tools directory and add upload to bintray tools.

This commit is contained in:
Kazushi (Jam) Marukawa
2017-08-27 11:43:22 +09:00
parent e061c1a9c5
commit 22d5adfae1
6 changed files with 199 additions and 0 deletions

90
tools/chkfrog.sh Executable file
View File

@@ -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 '\<version ['"'"'"]' packages/$pkg.rb | head -1 | sed -e 's/^.*version *['"'"'"]//' -e 's/['"'"'"].*$//'`
echo $pkg $version
for arch in x86_64 i686 armv7l; do
tarname="$pkg-$version-chromeos-$arch.tar"
if check_url "$URL/$tarname.xz"; then
url="$URL/$tarname.xz"
sha256=`get_sha256 $tarname.xz $arch`
elif check_url "$URL/$tarname.gz"; then
url="$URL/$tarname.gz"
sha256=`get_sha256 $tarname.gz $arch`
else
url=""
fi
echo $url : $sha256
case x$url in
x) ;;
*)
update_url $pkg $arch $url
update_sha256 $pkg $arch $sha256
case $arch in
armv7l)
update_url $pkg aarch64 $url
update_sha256 $pkg aarch64 $sha256
;;
esac
;;
esac
done
done

21
tools/create_package.sh Executable file
View File

@@ -0,0 +1,21 @@
#!/bin/bash
DIRNAME=${PWD##*/}
XZ_OPT=${XZ_OPT-"-7e"}
export XZ_OPT
echo creating file list
find . -type f > ../filelist && find . -type l >> ../filelist && cut -c2- ../filelist > filelist
echo creating directory list
find . -type d > ../dlist && cut -c2- ../dlist > dlistcut && tail -n +2 dlistcut > dlist
echo removing temporary files
rm dlistcut ../dlist ../filelist
echo building binary package
tar -cJf ../$DIRNAME.tar.xz *
sha1sum ../$DIRNAME.tar.xz > ../$DIRNAME.tar.xz.sha1
echo finished
cat ../$DIRNAME.tar.xz.sha1

40
tools/create_sha_list.sh Executable file
View File

@@ -0,0 +1,40 @@
#!/bin/bash
# Create SHA1/SHA256 list of binary files from packages/* and install.sh
#
# You can test SHA1/SHA256 by using 'sha1sum -c sha-file' or 'sha256sum -c sha-file'
case x$1 in
x|x-h)
echo "Usage: $0 [options] > output_file
Options:
-h: help
-a: show all SHA1/SHA256
Create SHA1/SHA256 list of binary files from packages/*.rb files and install.sh.
It is possible to check SHA1/SHA256 by using 'sha1sum -c file' or 'sha256sum -c file'"
exit 0;;
x-a)
;;
esac
grep -h '\(link=\|sha256=\)' install.sh |
sed -e 's/link=//' \
-e 's/sha256=//'\
-e 's/^[ \t]*["'"'"']//' \
-e 's/[\?&].*["'"'"'].*$//' \
-e 's/["'"'"'].*$//' \
-e 's/\(http\|https\|ftp\):.*\///' | \
sed -ne 'N;s/\(.*\)\n\(.*\)/\2 \1/;p'
for f in packages/*.rb; do
grep -h '\(armv7l\|i686\|x86_64\):' $f | \
sort | \
sed -e 's:/www\.dropbox\.com/:/dl.dropboxusercontent.com/:' \
-e 's/\(armv7l\|i686\|x86_64\)://' \
-e 's/^[ \t]*["'"'"']//' \
-e 's/[\?&].*["'"'"'].*$//' \
-e 's/["'"'"'].*$//' \
-e 's/\(http\|https\|ftp\):.*\///' | \
sed -ne 'N;s/\n/ /;p'
done

38
tools/create_url_list.sh Executable file
View File

@@ -0,0 +1,38 @@
#!/bin/bash
# Create URL list of binary URLs from packages/* and install.sh
#
# You can download all of them by using 'wget -N -P output_dir -i output_file' command
case x$1 in
x|x-h)
echo "Usage: $0 [options] > output_file
Options:
-h: help
-s: show URLs (ignore github URL)
-a: show all URLs (include github URL)
Create URL list of binary URLs from packages/*.rb files and install.sh.
It is possible to download them all using 'wget -N -P output_dir -i output_file'"
exit 0;;
x-s)
EXCLUDE_GITHUB_URL="grep -v 'github\.com'";;
x-a)
EXCLUDE_GITHUB_URL="cat";;
esac
grep -h 'link=.*\(http\|https\|ftp\):' install.sh | \
eval $EXCLUDE_GITHUB_URL | \
sed -e 's:/www\.dropbox\.com/:/dl.dropboxusercontent.com/:' \
-e 's/link=//' \
-e 's/^[ \t]*["'"'"']//' \
-e 's/[\?&].*["'"'"'].*$//' \
-e 's/["'"'"'].*$//'
grep -h '\(armv7l\|i686\|x86_64\):.*\(http\|https\|ftp\):' packages/*.rb | \
eval $EXCLUDE_GITHUB_URL | \
sed -e 's:/www\.dropbox\.com/:/dl.dropboxusercontent.com/:' \
-e 's/\(armv7l\|i686\|x86_64\)://' \
-e 's/^[ \t]*["'"'"']//' \
-e 's/[\?&].*["'"'"'].*$//' \
-e 's/["'"'"'].*$//'

109
tools/upfrog.sh Executable file
View File

@@ -0,0 +1,109 @@
#!/bin/bash
# Upload script to jfrog (bintray)
#
# Usage
#
# upfrog package... Upload all version of packages
# upfrog package-version... Upload only a given version of packages
# upfrog -t package... Performs only dry-run (not upload)
# upfrog -d package... Performs only debug-run (not execute jfrog)
#
# Note: OSS free account has limitation of the number of REST API uses by a day.
# If you see 'Forbidden' errors, please try it again in a next day.
#
ORG=chromebrew
REPO=chromebrew
DRYRUN=
DEBUG=
# Define your environment
#
# LOCALPATHS: Multiple paths for your pre-compiled binaries
# REGEXPLOCALPATH: Single path using regexp to points all of your LOCALPATHS.
# If your LOCALPATHS contains single directory, still "(|)"
# is required by jfrog, so write something like
# "(real-path|dummy-path)".
# For the case of multiple paths
LOCALPATHS="release/armv7l release/i686 release/x86_64"
REGEXPLOCALPATH="release/(armv7l|i686|x86_64)"
# For the case of single paths
#LOCALPATHS="release/bin"
#REGEXPLOCALPATH="release/(bin|dummy_zzzzz)"
case $1 in
-d) # debug
DEBUG=1
DRYRUN=--dry-run
shift;;
-t) # test
DRYRUN=--dry-run
shift;;
esac
function check_pkg () {
jfrog bt ps $ORG/$REPO/$1 > /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

38
tools/upload_github_release.sh Executable file
View File

@@ -0,0 +1,38 @@
#!/bin/bash
# Script to upload binary files to github release page.
#
# Prerequirement:
# github-release (https://github.com/aktau/github-release)
# golang
owner=skycocker
repo=chromebrew
case x$1 in
x|x-h)
echo "Usage: $0 [options] tag files...
Options:
-h: help
-d: dump status of repository
Upload files to tagged release page of http://github.com/$owner/$repo"
exit 0;;
x-d)
github-release info -u "$owner" -r "$repo"
exit 0;;
*)
tag=$1
shift;;
esac
case x$GITHUB_TOKEN in
x)
echo "It is required to set your public_repo token to GITHUB_TOKEN environment variable to upload"
exit 1;;
esac
for file in "$@"; do
name=$(basename $file)
github-release upload -u "$owner" -r "$repo" -t "$tag" -n "$name" -f "$file"
done