diff options
author | Florian Pritz <bluewind@xinu.at> | 2014-01-04 23:19:40 +0100 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2015-05-27 15:46:04 +0200 |
commit | c9e8f60aba3477742fd9592e4e7a9416e6f51449 (patch) | |
tree | 0c69ecc95210b2ace101ed1fd87f8a7f0462b706 | |
parent | 4fcedea4ae5fb8788c7ef0ddd907ed8b02d14a5b (diff) | |
download | dbscripts-c9e8f60aba3477742fd9592e4e7a9416e6f51449.tar.gz dbscripts-c9e8f60aba3477742fd9592e4e7a9416e6f51449.tar.xz |
somewhat working
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rwxr-xr-x | db-add (renamed from db-repo-add) | 17 | ||||
-rw-r--r-- | db-functions | 75 | ||||
-rwxr-xr-x | db-remove | 17 | ||||
-rwxr-xr-x | db-update | 33 |
4 files changed, 53 insertions, 89 deletions
@@ -18,7 +18,7 @@ if ! check_repo_permission $repo; then die "You don't have permission to add packages to ${repo}" fi -if [ "$arch" == "any" ]; then +if [ "$arch" == "all" ]; then tarches=(${ARCHES[@]}) else tarches=("$arch") @@ -28,14 +28,13 @@ 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 - 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-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 +} @@ -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 @@ -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 |