From c9e8f60aba3477742fd9592e4e7a9416e6f51449 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sat, 4 Jan 2014 23:19:40 +0100 Subject: somewhat working Signed-off-by: Florian Pritz --- db-add | 40 ++++++++++++++++++++++++++++++++ db-functions | 75 ++++++++++++++++++++++++++++-------------------------------- db-remove | 17 +++----------- db-repo-add | 41 --------------------------------- db-update | 33 ++++++-------------------- 5 files changed, 85 insertions(+), 121 deletions(-) create mode 100755 db-add delete mode 100755 db-repo-add diff --git a/db-add b/db-add new file mode 100755 index 0000000..490ba43 --- /dev/null +++ b/db-add @@ -0,0 +1,40 @@ +#!/bin/bash + +. "$(dirname $0)/config" +. "$(dirname $0)/db-functions" + +if [ $# -lt 3 ]; then + msg "usage: ${0##*/} ..." + exit 1 +fi + +repo="$1" +arch="$2" +pkgfiles=(${@:3}) + +ftppath="$FTP_BASE/$repo/os" + +if ! check_repo_permission $repo; then + die "You don't have permission to add packages to ${repo}" +fi + +if [ "$arch" == "all" ]; then + tarches=(${ARCHES[@]}) +else + tarches=("$arch") +fi + +for tarch in ${tarches[@]}; do + repo_lock $repo $tarch || exit 1 +done + +for pkgfile in ${pkgfiles[@]}; do + if [[ -f "$pkgfile" ]]; then + arch_add_to_pool "$pkgfile" + fi + arch_db_add $repo "$pkgfile" ${tarches[@]} +done + +for tarch in ${tarches[@]}; do + repo_unlock $repo $tarch +done diff --git a/db-functions b/db-functions index 7e1b3aa..fbd25e6 100644 --- a/db-functions +++ b/db-functions @@ -26,11 +26,6 @@ mv_acl() { # set up general environment WORKDIR=$(mktemp -d "${TMPDIR}/${0##*/}.XXXXXXXXXX") -if [ -n "${SVNUSER}" ]; then - setfacl -m u:"${SVNUSER}":rwx "${WORKDIR}" - setfacl -m d:u:"${USER}":rwx "${WORKDIR}" - setfacl -m d:u:"${SVNUSER}":rwx "${WORKDIR}" -fi LOCKS=() REPO_MODIFIED=0 @@ -358,36 +353,6 @@ check_pkgfile() { fi } -check_pkgsvn() { - local pkgfile="${1}" - local _pkgbase="$(getpkgbase ${pkgfile})" - [ $? -ge 1 ] && return 1 - local _pkgname="$(getpkgname ${pkgfile})" - [ $? -ge 1 ] && return 1 - local _pkgver="$(getpkgver ${pkgfile})" - [ $? -ge 1 ] && return 1 - local _pkgarch="$(getpkgarch ${pkgfile})" - [ $? -ge 1 ] && return 1 - local repo="${2}" - - in_array "${repo}" ${PKGREPOS[@]} || return 1 - - if [ ! -f "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}" ]; then - mkdir -p "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}" - arch_svn export -q "${SVNREPO}/${_pkgbase}/repos/${repo}-${_pkgarch}/PKGBUILD" \ - "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}" >/dev/null - [ $? -ge 1 ] && return 1 - fi - - local svnver="$(. "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; echo $(get_full_version ${epoch:-0} ${pkgver} ${pkgrel}) )" - [ "${svnver}" == "${_pkgver}" ] || return 1 - - local svnnames=($(. "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; echo ${pkgname[@]})) - in_array "${_pkgname}" ${svnnames[@]} || return 1 - - return 0 -} - check_splitpkgs() { local repo="${1}" shift @@ -536,10 +501,40 @@ arch_repo_remove() { REPO_MODIFIED=1 } -arch_svn() { - if [ -z "${SVNUSER}" ]; then - /usr/bin/svn "${@}" - else - sudo -u "${SVNUSER}" -- /usr/bin/svn --username "${USER}" "${@}" +arch_add_to_pool() { + local pkgfile="$1" + if [ -f "${pkgfile}" ]; then + mv "${pkgfile}" "$FTP_BASE/${PKGPOOL}" + fi + + # also move signatures + if [ -f "${pkgfile}.sig" ]; then + mv "${pkgfile}.sig" "$FTP_BASE/${PKGPOOL}" fi } + +# add a package name (from the pool) to the database +# call arch_add_to_pool first +arch_db_add() { + local repo="$1" + local pkgfile="${2##*/}" + local tarches=(${@:3}) + + for tarch in ${tarches[@]}; do + srcfile="$FTP_BASE/${PKGPOOL}/${pkgfile}" + dstdir="$FTP_BASE/$repo/os/$tarch" + + if [[ ! -f "${srcfile}" ]]; then + die "Package file ${pkgfile} not found in ${FTP_BASE}/${PKGPOOL}" + else + msg "Adding $pkgfile to [$repo]-$tarch..." + fi + + ln -sr "$srcfile" "$dstdir/" + if [ -f "${srcfile}.sig" ]; then + ln -sr "${srcfile}.sig" "$dstdir/" + fi + + arch_repo_add "${repo}" "${tarch}" ${pkgfile} + done +} diff --git a/db-remove b/db-remove index 25cb9a7..bb1f5cb 100755 --- a/db-remove +++ b/db-remove @@ -13,13 +13,12 @@ arch="$2" pkgbases=(${@:3}) ftppath="$FTP_BASE/$repo/os" -svnrepo="$repo-$arch" if ! check_repo_permission $repo; then die "You don't have permission to remove packages from ${repo}" fi -if [ "$arch" == "any" ]; then +if [ "$arch" == "all" ]; then tarches=(${ARCHES[@]}) else tarches=("$arch") @@ -32,18 +31,8 @@ done remove_pkgs=() for pkgbase in ${pkgbases[@]}; do msg "Removing $pkgbase from [$repo]..." - arch_svn checkout -q "${SVNREPO}/${pkgbase}" "${WORKDIR}/svn/${pkgbase}" >/dev/null - - if [ -d "${WORKDIR}/svn/$pkgbase/repos/$svnrepo" ]; then - remove_pkgs=(${remove_pkgs[@]} $(. "${WORKDIR}/svn/$pkgbase/repos/$svnrepo/PKGBUILD"; echo ${pkgname[@]})) - arch_svn rm --force -q "${WORKDIR}/svn/$pkgbase/repos/$svnrepo" - arch_svn commit -q "${WORKDIR}/svn/$pkgbase" -m "${0##*/}: $pkgbase removed by $(id -un)" - else - warning "$pkgbase not found in $svnrepo" - warning "Removing only $pkgbase from the repo" - warning "If it was a split package you have to remove the others yourself!" - remove_pkgs[${#remove_pkgs[*]}]=$pkgbase - fi + # TODO: detect split packages; do we even want them to be removed automatically? + remove_pkgs[${#remove_pkgs[*]}]=$pkgbase done for tarch in ${tarches[@]}; do diff --git a/db-repo-add b/db-repo-add deleted file mode 100755 index 5d5b653..0000000 --- a/db-repo-add +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash - -. "$(dirname $0)/config" -. "$(dirname $0)/db-functions" - -if [ $# -lt 3 ]; then - msg "usage: ${0##*/} ..." - exit 1 -fi - -repo="$1" -arch="$2" -pkgfiles=(${@:3}) - -ftppath="$FTP_BASE/$repo/os" - -if ! check_repo_permission $repo; then - die "You don't have permission to add packages to ${repo}" -fi - -if [ "$arch" == "any" ]; then - tarches=(${ARCHES[@]}) -else - tarches=("$arch") -fi - -for tarch in ${tarches[@]}; do - repo_lock $repo $tarch || exit 1 -done - -for tarch in ${tarches[@]}; do - for pkgfile in ${pkgfiles[@]}; do - if [[ ! -f "${FTP_BASE}/${repo}/os/${arch}/${pkgfile##*/}" ]]; then - die "Package file ${pkgfile##*/} not found in ${FTP_BASE}/${repo}/os/${arch}/" - else - msg "Adding $pkgfile to [$repo]..." - fi - done - arch_repo_add "${repo}" "${tarch}" ${pkgfiles[@]} - repo_unlock $repo $tarch -done diff --git a/db-update b/db-update index cdc35a5..3828e8f 100755 --- a/db-update +++ b/db-update @@ -45,9 +45,6 @@ for repo in ${repos[@]}; do 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_pkgsvn "${pkg}" "${repo}"; then - die "Package ${repo}/${pkg##*/} is not consistent with svn repository" - fi if ! check_pkgrepos "${pkg}"; then die "Package ${repo}/${pkg##*/} already exists in another repository" fi @@ -64,31 +61,15 @@ for repo in ${repos[@]}; do done for repo in ${repos[@]}; do - msg "Updating [${repo}]..." - any_pkgs=($(getpkgfiles "${STAGING}/${repo}/"*-any${PKGEXT} 2>/dev/null)) - for pkgarch in ${ARCHES[@]}; do - add_pkgs=() - arch_pkgs=($(getpkgfiles "${STAGING}/${repo}/"*-${pkgarch}${PKGEXT} 2>/dev/null)) - for pkg in ${arch_pkgs[@]} ${any_pkgs[@]}; do - pkgfile="${pkg##*/}" - msg2 "${pkgfile} (${pkgarch})" - # any packages might have been moved by the previous run - if [ -f "${pkg}" ]; then - mv "${pkg}" "$FTP_BASE/${PKGPOOL}" - fi - ln -s "../../../${PKGPOOL}/${pkgfile}" "$FTP_BASE/$repo/os/${pkgarch}" - # also move signatures - if [ -f "${pkg}.sig" ]; then - mv "${pkg}.sig" "$FTP_BASE/${PKGPOOL}" + for pkgfile in $(getpkgfiles "${STAGING}/${repo}/"*${PKGEXT} 2>/dev/null); do + arch_add_to_pool "$pkgfile" + for pkgarch in ${ARCHES[@]}; do + pkgfile_arch="$STAGING/$repo/$pkgarch/${pkgfile##*/}" + if [[ -h "$pkgfile_arch" ]]; then + arch_db_add $repo "${pkgfile##*/}" $pkgarch + rm "$pkgfile_arch" fi - if [ -f "$FTP_BASE/${PKGPOOL}/${pkgfile}.sig" ]; then - ln -s "../../../${PKGPOOL}/${pkgfile}.sig" "$FTP_BASE/$repo/os/${pkgarch}" - fi - add_pkgs[${#add_pkgs[*]}]=${pkgfile} done - if [ ${#add_pkgs[@]} -ge 1 ]; then - arch_repo_add "${repo}" "${pkgarch}" ${add_pkgs[@]} - fi done done -- cgit v1.2.3-24-g4f1b