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

parent e061c1a9
#!/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
#!/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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment