#!/bin/bash . "$(dirname $0)/config" . "$(dirname $0)/db-functions" if [ $# -ge 1 ]; then warning "Calling ${0##*/} with a specific repository is no longer supported" exit 1 fi # Find repos with packages to release staging_repos=($(find "${STAGING}" -mindepth 1 -type f -name "*${PKGEXT}" -printf '%h\n' | sort -u)) if [ $? -ge 1 ]; then die "Could not read ${STAGING}" fi repos=() for staging_repo in ${staging_repos[@]##*/}; do if in_array ${staging_repo} ${PKGREPOS[@]}; then repos+=(${staging_repo}) fi done # TODO: this might lock too much (architectures) for repo in ${repos[@]}; do for pkgarch in ${ARCHES[@]}; do repo_lock ${repo} ${pkgarch} || exit 1 done done # check if packages are valid for repo in ${repos[@]}; do if ! check_repo_permission "${repo}"; then die "You don't have permission to update packages in ${repo}" fi pkgs=($(getpkgfiles "${STAGING}/${repo}/"*${PKGEXT})) if [ $? -eq 0 ]; then for pkg in ${pkgs[@]}; do if [ -h "${pkg}" ]; then die "Package ${repo}/${pkg##*/} is a symbolic link" fi if ! check_pkgfile "${pkg}"; then die "Package ${repo}/${pkg##*/} is not consistent with its meta data" fi if ${REQUIRE_SIGNATURE} && ! pacman-key -v "${pkg}.sig" >/dev/null 2>&1; then die "Package ${repo}/${pkg##*/} does not have a valid signature" fi if ! check_pkgrepos "${pkg}"; then die "Package ${repo}/${pkg##*/} already exists in another repository" fi if ! check_packager "${pkg}"; then die "Package ${repo}/${pkg##*/} does not have a valid packager" fi done else die "Could not read ${STAGING}" fi done # TODO: check if all packages of a splitpkg are being pushed (or if they already exist in the repo: foo-x86_64 foo-data, later push foo-i686) # TODO: detect if a pkgname has been removed from a split package and clean up the repo for repo in ${repos[@]}; do for pkgfile in $(getpkgfiles "${STAGING}/${repo}/"*${PKGEXT} 2>/dev/null); do arch_add_to_pool "$pkgfile" done for file in "$STAGING/$repo"/*/*; do if [[ -h $file ]]; then pkgfiles=("${pkgfiles[@]}" "${file##*/}") fi done for pkgarch in ${ARCHES[@]}; do declare -a pkgs_to_add=() for pkgfile in "${pkgfiles[@]}"; do pkgfile_arch="$STAGING/$repo/$pkgarch/$pkgfile" if [[ -h "$pkgfile_arch" ]]; then pkgs_to_add=("${pkgs_to_add[@]}" "$pkgfile") rm "$pkgfile_arch" fi done if [[ ${#pkgs_to_add[@]} = 0 ]]; then continue fi arch_db_add $repo "$pkgarch" "${pkgs_to_add[@]}" done done arch_history_commit "db-update: ${repos[@]}" for repo in ${repos[@]}; do for pkgarch in ${ARCHES[@]}; do repo_unlock ${repo} ${pkgarch} done done