-
-
Save vicendominguez/88c1153fa34bd17faffa25623ea8306b to your computer and use it in GitHub Desktop.
Helper script to upload/remove RPM packages to/from bintray
This file contains hidden or 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 hidden or 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment