From 8f67551473004a9487fa47cf7f9e953c4c46cd7f Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 29 Nov 2013 17:57:39 -0500 Subject: initial implementation of xbs-abs --- Makefile | 3 +- src/xbs-abs/.gitignore | 1 + src/xbs-abs/Makefile | 12 +++++ src/xbs-abs/helper-abs | 138 +++++++++++++++++++++++++++++++++++++++++++++++ src/xbs-abs/xbs-abs.conf | 9 ++++ 5 files changed, 162 insertions(+), 1 deletion(-) create mode 100644 src/xbs-abs/.gitignore create mode 100644 src/xbs-abs/Makefile create mode 100755 src/xbs-abs/helper-abs create mode 100644 src/xbs-abs/xbs-abs.conf diff --git a/Makefile b/Makefile index ab6db63..e7c46ec 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ include config.mk ################################################################################ # these are the resulting packages -packages=doc libretools libretools-mips64el librelib gitget xbs xbs-abslibre +packages=doc libretools libretools-mips64el librelib gitget xbs xbs-abs xbs-abslibre # and which directories they contain doc=doc libretools=\ @@ -19,6 +19,7 @@ libretools-mips64el=src/mips64el-tools librelib=src/lib gitget=src/gitget xbs=src/xbs +xbs-abs=src/xbs-abs xbs-abslibre=src/xbs-abslibre ################################################################################ diff --git a/src/xbs-abs/.gitignore b/src/xbs-abs/.gitignore new file mode 100644 index 0000000..41ee0f5 --- /dev/null +++ b/src/xbs-abs/.gitignore @@ -0,0 +1 @@ +archrelease* diff --git a/src/xbs-abs/Makefile b/src/xbs-abs/Makefile new file mode 100644 index 0000000..7582592 --- /dev/null +++ b/src/xbs-abs/Makefile @@ -0,0 +1,12 @@ +pkgconfdir = $(sysconfdir)/xbs +bindir = $(libexecdir)/xbs +pkglibexecdir = $(libexecdir)/xbs/helper-abs.d +copy_files = archrelease.in +libs = archrelease +include ../../common.mk + +archrelease: %: %.in + @echo "GEN $@" + @$(edit) <"$<" >"$@" || { rm -f -- '$@'; false; } + @sed -i '/valid-tags\.sh/d' '$@' || { rm -f -- '$@'; false; } + @chmod 755 "$@" || { rm -f -- '$@'; false; } diff --git a/src/xbs-abs/helper-abs b/src/xbs-abs/helper-abs new file mode 100755 index 0000000..0471c81 --- /dev/null +++ b/src/xbs-abs/helper-abs @@ -0,0 +1,138 @@ +#!/bin/bash + +# Copyright (c) 2013 Luke Shumaker +# For code from db-functions (arch_svn): +# Copyright (c) 2012 Pierre Schmitz +# For code from db-move+db-remove (move+unrelease): +# Copyright (c) 2008-2009 Aaron Griffin +# Copyright (c) 2009 Abhishek Dasgupta +# Copyright (c) 2009, 2011 Dan McGee +# Copyright (c) 2009-2012 Pierre Schmitz +# For code just from db-move (move): +# Copyright (c) 2011 Rémy Oudompheng +# Copyright (c) 2012 Florian Pritz +# For code just from db-remove (unrelease): +# Copyright (c) 2009 Eric Bélanger +# Copyright (c) 2011 Florian Pritz +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +load_config() { + . $(librelib conf.sh) + load_files xbs-abs + check_vars SVNURL SVNREPO ARCHES || exit 1 +} + +# This is taken from dbscripts:db-fuctions +arch_svn() { + if [[ -z "${SVNUSER}" ]]; then + /usr/bin/svn "${@}" + else + sudo -u "${SVNUSER}" -- /usr/bin/svn --username "${USER}" "${@}" + fi +} + +status() { + load_config + [[ -z $(arch_svn status -q) ]] +} + +download() { + load_config + if [[ -d "$SVNREPO/.svn" ]]; then + arch_svn -q up "$SVNREPO"/* + else + # checkout non-recursive, then lazy load + # nescessary because: + # > DO NOT CHECK OUT THE ENTIRE SVN REPO. Your address may be blocked. + arch_svn -q checkout -N "$SVNURL" "$SVNREPO" + fi +} + +release() { + local repo=$1 + local arch=$2 + + "${0}.d/archrelease" -f "${repo}-${arch}" +} + +unrelease() { + local pkgbase=$1 + local repo=$2 + local arch=$3 + + local svnrepo="$repo-$arch" + load_config + + arch_svn up -q "${SVNREPO}/${pkgbase}" + + # This is based off code from dbscripts:db-remove + remove_pkgs=$(. "${SVNREPO}/$pkgbase/repos/$svnrepo/PKGBUILD"; echo ${pkgname[@]}) + arch_svn rm --force -q "${SVNREPO}/$pkgbase/repos/$svnrepo" + arch_svn commit -q "${SVNREPO}/$pkgbase" -m "${0##*/}: $pkgbase removed by $(id -un)" +} + +move() { + local repo_from=$1 + local repo_to=$2 + local pkgbase=$3 + + load_config + arch_svn up -q "${SVNREPO}/${pkgbase}" + + local tag_list="" + local pkgarch + local arches=() + # this is based off code from dbscripts:db-move + for pkgarch in "${ARCHES[@]}" 'any'; do + dir_from="${SVNREPO}/${pkgbase}/repos/${repo_from}-${pkgarch}" + dir_to="${SVNREPO}/${pkgbase}/repos/${repo_to}-${pkgarch}" + + if [ -f "${dir_from}/PKGBUILD" ]; then + if [ -d "${dir_to}" ]; then + for file in $(arch_svn ls "${dir_to}"); do + arch_svn rm -q "${dir_to}/$file@" + done + else + mkdir "${dir_to}" + arch_svn add -q "${dir_to}" + fi + + for file in $(arch_svn ls "${dir_from}"); do + arch_svn mv -q -r HEAD "${dir_from}/$file@" "${dir_to}/" + done + arch_svn rm --force -q "${dir_from}" + tag_list="$tag_list, $pkgarch" + arches+=("$pkgarch") + fi + done + tag_list="${tag_list#, }" + arch_svn commit -q "${SVNREPO}/${pkgbase}" -m "${0##*/}: moved ${pkgbase} from [${repo_from}] to [${repo_to}] (${tag_list})" + echo "${arches[*]}" +} + +releasepath() { + local pkgbase=$1 + local repo=$2 + local arch=$3 + + load_config + arch_svn up -q "${SVNREPO}/${pkgbase}" + echo "${SVNREPO}/${pkgbase}/repos/${repo}-${arch}" +} + +case "$1" in + status|download|release|unrelease|move|releasepath) "$@";; + *) exit 127;; +esac diff --git a/src/xbs-abs/xbs-abs.conf b/src/xbs-abs/xbs-abs.conf new file mode 100644 index 0000000..be5b756 --- /dev/null +++ b/src/xbs-abs/xbs-abs.conf @@ -0,0 +1,9 @@ +SVNDIR= +ARCHES=(i686 x86_64) + +# name url repos... +SVNREPOS=( + 'packages svn://svn.archlinux.org/packages core extra testing' + 'commuity svn://svn.archlinux.org/community community community-testing multilib multilib-testing' +) + -- cgit v1.2.2