The "upload shell script" is updated to the current Bintray API and i have improved the output.
The "delete shell script" is just to remove version of packages from Bintray which you have in the local storage but you didn't want in Bintray (and they were uploaded previously). It is a proof of concept for the API, nothing else.
Two details:
- In the delete-script, I chose to use $1 parameter to point to the files (with wildcards).
- In the upload-script, RPMS_DIRS is used in the upload curl url, so be careful here. We are using relative path to avoid a long path in the Bintray web.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# You should define BINTRAY_ACCOUNT and BINTRAY_APIKEY here or from the outside | |
# BINTRAY_ACCOUNT is you Bintray account and BINTRAY_APIKEY, API Key generated under your Bintray profile | |
# Redefine following variables to match your own usage | |
BINTRAY_ACCOUNT=vicendominguez | |
BINTRAY_APIKEY=xxxxxxxxxxxxxxxxx | |
BINTRAY_REPO=CentOS6 | |
BASE_DESC=https://github.com/vicendominguez/CentOS6-SPECS.git | |
BINTRAY_USER=$BINTRAY_ACCOUNT | |
RPM_FILES="$1" | |
for RPM_FILE in $RPM_FILES; do | |
RPM_NAME=`rpm --queryformat "%{NAME}" -qp $RPM_FILE` | |
RPM_VERSION=`rpm --queryformat "%{VERSION}" -qp $RPM_FILE` | |
RPM_RELEASE=`rpm --queryformat "%{RELEASE}" -qp $RPM_FILE` | |
RPM_ARCH=`rpm --queryformat "%{ARCH}" -qp $RPM_FILE` | |
RPM_LICENSE=`rpm --queryformat "%{License}" -qp $RPM_FILE` | |
case $RPM_LICENSE in | |
*GPL*v2*) RPM_LICENSE="GPL-2.0" | |
;; | |
*GPL*) RPM_LICENSE="GPL-3.0" | |
;; | |
*BSD-3*) RPM_LICENSE="BSD 3-Clause" | |
;; | |
*BSD*) RPM_LICENSE="BSD" | |
;; | |
*MIT*) RPM_LICENSE="MIT" | |
;; | |
*) RPM_LICENSE="GPL-3.0" | |
esac | |
echo -e "\n\e[34mNew package: RPM_NAME=$RPM_NAME, RPM_VERSION=$RPM_VERSION, RPM_RELEASE=$RPM_RELEASE, RPM_ARCH=$RPM_ARCH, RPM_LICENS | |
echo -e "\n\e[4mdelete version\e[0m" | |
curl -s -u$BINTRAY_USER:$BINTRAY_APIKEY -X DELETE https://api.bintray.com/packages/$BINTRAY_ACCOUNT/$BINTRAY_REPO/$RPM_NAME/versions | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# You should define BINTRAY_ACCOUNT and BINTRAY_APIKEY here or from the outside | |
# BINTRAY_ACCOUNT is you Bintray account and BINTRAY_APIKEY, API Key generated under your Bintray profile | |
# Redefine following variables to match your own usage | |
RPMS_DIR=x86_64/ | |
BINTRAY_ACCOUNT=vicendominguez | |
BINTRAY_APIKEY=xxxxxxxxxxxxxxxxxxxxx | |
BINTRAY_REPO=CentOS6 | |
BASE_DESC=https://github.com/vicendominguez/CentOS6-SPECS.git | |
BINTRAY_USER=$BINTRAY_ACCOUNT | |
for RPM_FILE in $RPMS_DIR/*.rpm; do | |
RPM_NAME=`rpm --queryformat "%{NAME}" -qp $RPM_FILE` | |
RPM_VERSION=`rpm --queryformat "%{VERSION}" -qp $RPM_FILE` | |
RPM_RELEASE=`rpm --queryformat "%{RELEASE}" -qp $RPM_FILE` | |
RPM_ARCH=`rpm --queryformat "%{ARCH}" -qp $RPM_FILE` | |
RPM_LICENSE=`rpm --queryformat "%{License}" -qp $RPM_FILE` | |
case $RPM_LICENSE in | |
*GPL*v2*) RPM_LICENSE="GPL-2.0" | |
;; | |
*GPL*) RPM_LICENSE="GPL-3.0" | |
;; | |
*BSD-3*) RPM_LICENSE="BSD 3-Clause" | |
;; | |
*BSD*) RPM_LICENSE="BSD" | |
;; | |
*MIT*) RPM_LICENSE="MIT" | |
;; | |
*) RPM_LICENSE="GPL-3.0" | |
esac | |
echo -e "\n\e[34mNew package: RPM_NAME=$RPM_NAME, RPM_VERSION=$RPM_VERSION, RPM_RELEASE=$RPM_RELEASE, RPM_ARCH=$RPM_ARCH, RPM_LICENSE=$RPM_LICENSE\e[0m" | |
echo -e "\n\e[4mcreate package\e[0m" | |
curl -s -u$BINTRAY_USER:$BINTRAY_APIKEY -H "Content-Type: application/json" -X POST https://api.bintray.com/packages/$BINTRAY_ACCOUNT/$BINTRAY_REPO --data "{\"name\":\"$RPM_NAME\",\"desc\":\"Imported by script\",\"licenses\":[\"$RPM_LICENSE\"],\"vcs_url\":\"$BASE_DESC\"}" | |
echo -e "\n\e[4mdelete version\e[0m" | |
curl -s -u$BINTRAY_USER:$BINTRAY_APIKEY -X DELETE https://api.bintray.com/packages/$BINTRAY_ACCOUNT/$BINTRAY_REPO/$RPM_NAME/versions/$RPM_VERSION-$RPM_RELEASE | |
echo -e "\n\e[4mcreate version\e[0m" | |
curl -s -u$BINTRAY_USER:$BINTRAY_APIKEY -H "Content-Type: application/json" -X POST https://api.bintray.com/packages/$BINTRAY_ACCOUNT/$BINTRAY_REPO/$RPM_NAME/versions --data "{ \"name\": \"$RPM_VERSION-$RPM_RELEASE\", \"release_notes\": \"auto\", \"release_url\": \"$BASE_DESC\", \"released\": \"\" }" | |
echo -e "\n\e[4mupload content\e[0m" | |
curl -s -T $RPM_FILE -u$BINTRAY_USER:$BINTRAY_APIKEY -H "X-Bintray-Package:$RPM_NAME" -H "X-Bintray-Version:$RPM_VERSION-$RPM_RELEASE" https://api.bintray.com/content/$BINTRAY_ACCOUNT/$BINTRAY_REPO/$RPM_NAME/$RPM_VERSION/$RPM_FILE | |
# curl -vvf -T $RPM_FILE -u$BINTRAY_USER:$BINTRAY_APIKEY -H "X-Bintray-Package:$RPM_NAME" -H "X-Bintray-Version:$RPM_VERSION-$RPM_RELEASE" https://api.bintray.com/content/$BINTRAY_ACCOUNT/$BINTRAY_REPO/ | |
echo -e "\n\e[4mpublish content\e[0m" | |
curl -s -u$BINTRAY_USER:$BINTRAY_APIKEY -H "Content-Type: application/json" -X POST https://api.bintray.com/content/$BINTRAY_ACCOUNT/$BINTRAY_REPO/$RPM_NAME/$RPM_VERSION-$RPM_RELEASE/publish --data "{ \"discard\": \"false\" }" | |
done |