mirror of
https://git.centos.org/centos-git-common.git
synced 2025-02-23 08:12:56 +00:00
Initial upload tool for git.stg test, more to be included in centpkg later
Signed-off-by: Fabian Arrotin <arrfab@centos.org>
This commit is contained in:
parent
4ec6d6633e
commit
9023a882e1
1 changed files with 94 additions and 0 deletions
94
lookaside_upload
Executable file
94
lookaside_upload
Executable file
|
@ -0,0 +1,94 @@
|
|||
#!/bin/bash
|
||||
|
||||
# This script will let you upload sources/blobs to new CentOS lookaside cache
|
||||
# requirements:
|
||||
# - curl
|
||||
# - valid TLS certs from https://accounts.centos.org (or dev instance for testing)
|
||||
# - valid group membership to let you upload to specific "branch"
|
||||
|
||||
# Some variables, switch for new url
|
||||
lookaside_baseurl="https://git.stg.centos.org"
|
||||
|
||||
function usage {
|
||||
|
||||
cat << EOF
|
||||
|
||||
You need to call the script like this : $0 -arguments
|
||||
|
||||
-f : filename/source to upload (required, default:none)
|
||||
-n : package name for that source (requred, default:none, example "httpd")
|
||||
-b : "branch" where to upload to (required, default:none, example "c7-sig-core")
|
||||
-h : display this help
|
||||
|
||||
EOF
|
||||
|
||||
}
|
||||
|
||||
function varcheck {
|
||||
if [ -z "$1" ] ; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
function f_log {
|
||||
echo "[+] CentOS Lookaside upload tool -> $*"
|
||||
}
|
||||
|
||||
|
||||
|
||||
while getopts “hf:n:b:” OPTION
|
||||
do
|
||||
case $OPTION in
|
||||
h)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
f)
|
||||
file=$OPTARG
|
||||
;;
|
||||
n)
|
||||
pkgname=$OPTARG
|
||||
;;
|
||||
b)
|
||||
branch=$OPTARG
|
||||
;;
|
||||
?)
|
||||
usage
|
||||
exit
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
varcheck $file
|
||||
varcheck $pkgname
|
||||
varcheck $branch
|
||||
|
||||
if [ ! -f ~/.centos.cert ] ;then
|
||||
f_log "No mandatory TLS cert found (~/.centos.cert) .."
|
||||
f_log "please use centos-cert to retrieve your ACO TLS cert"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
f_log "Initialing new upload to lookaside"
|
||||
checksum=$(sha1sum ${file}|awk '{print $1}')
|
||||
f_log "URL : $lookaside_baseurl"
|
||||
f_log "Source to upload : ${file} "
|
||||
f_log "Package name: $pkgname"
|
||||
f_log "sha1sum: ${checksum}"
|
||||
f_log "Remote branch: ${branch}"
|
||||
f_log " ====== Trying to upload ======="
|
||||
echo ""
|
||||
curl ${lookaside_baseurl}/sources/upload.cgi \
|
||||
--fail \
|
||||
--cert ~/.centos.cert \
|
||||
--form "name=${pkgname}" \
|
||||
--form "branch=${branch}" \
|
||||
--form "sha1sum=${checksum}" \
|
||||
--form "file=@${file}" \
|
||||
--progress-bar | tee /dev/null
|
||||
|
||||
f_log "Returned value: $?"
|
||||
f_log "Source should be available at ${lookaside_baseurl}/sources/${pkgname}/${branch}/${checksum}"
|
||||
|
Loading…
Add table
Reference in a new issue