| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | set -eu -o pipefail |
| 3 | |
| 4 | diescip-shell shell shell-project 0.0.0 die().() { |
| 5 | echoscip-shell system . . echo. "Error: ${*}" >&2 |
| 6 | exit 1 |
| 7 | } |
| 8 | |
| 9 | declare nexus_repo_name="${NEXUS_REPO_NAME:-saunafs}" |
| 10 | declare nexus_url="${NEXUS_URL:-http://localhost:8081}" |
| 11 | nexus_url="${nexus_url%/}" |
| 12 | declare nexus_username="${NEXUS_USERNAME:-}" |
| 13 | declare nexus_password="${NEXUS_PASSWORD:-}" |
| 14 | if [scip-shell system . . `[`. -z "${nexus_username}" ] || [scip-shell system . . `[`. -z "${nexus_password}" ]; then |
| 15 | diescip-shell shell shell-project 0.0.0 die(). "Nexus username and password must be set" |
| 16 | fi |
| 17 | declare nexus_auth="$(echoscip-shell system . . echo. ${nexus_username}:${nexus_password})" |
| 18 | |
| 19 | |
| 20 | declare source_dir="${1:-}" |
| 21 | |
| 22 | declare files=$(findscip-shell system . . find. "${source_dir}" -type f -name '*.deb') |
| 23 | |
| 24 | for file in ${files}; do |
| 25 | echoscip-shell system . . echo. "Uploading ${file}..." |
| 26 | curlscip-shell system . . curl. -u "${nexus_auth}" --fail -X POST \ |
| 27 | "${nexus_url}/service/rest/v1/components?repository=${nexus_repo_name,,}" \ |
| 28 | -H "accept: application/json" \ |
| 29 | -H "Content-Type: multipart/form-data" \ |
| 30 | -F "apt.asset=@${file}" |
| 31 | done |