diff options
author | Florian Pritz <bluewind@xinu.at> | 2014-01-31 17:24:00 +0100 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2015-05-27 15:46:04 +0200 |
commit | 5340bef937c5ce288d323873529545ffd5878e21 (patch) | |
tree | 546ad67fecd1109d6d9e8c2c133e6e4858bf6a72 | |
parent | c9e8f60aba3477742fd9592e4e7a9416e6f51449 (diff) | |
download | dbscripts-5340bef937c5ce288d323873529545ffd5878e21.tar.gz dbscripts-5340bef937c5ce288d323873529545ffd5878e21.tar.xz |
add historical git repo; fix db-move
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rwxr-xr-x | db-add | 2 | ||||
-rw-r--r-- | db-functions | 49 | ||||
-rwxr-xr-x | db-move | 100 | ||||
-rwxr-xr-x | db-remove | 8 | ||||
-rwxr-xr-x | db-update | 5 |
5 files changed, 67 insertions, 97 deletions
@@ -35,6 +35,8 @@ for pkgfile in ${pkgfiles[@]}; do arch_db_add $repo "$pkgfile" ${tarches[@]} done +arch_git commit -q -m "db-add: ${tarches[@]}: ${pkgfiles[@]}" + for tarch in ${tarches[@]}; do repo_unlock $repo $tarch done diff --git a/db-functions b/db-functions index fbd25e6..4b90d51 100644 --- a/db-functions +++ b/db-functions @@ -521,8 +521,8 @@ arch_db_add() { local tarches=(${@:3}) for tarch in ${tarches[@]}; do - srcfile="$FTP_BASE/${PKGPOOL}/${pkgfile}" - dstdir="$FTP_BASE/$repo/os/$tarch" + local srcfile="$FTP_BASE/${PKGPOOL}/${pkgfile}" + local dstdir="$FTP_BASE/$repo/os/$tarch" if [[ ! -f "${srcfile}" ]]; then die "Package file ${pkgfile} not found in ${FTP_BASE}/${PKGPOOL}" @@ -536,5 +536,50 @@ arch_db_add() { fi arch_repo_add "${repo}" "${tarch}" ${pkgfile} + arch_history_add "$repo" "$dstdir/$pkgfile" "$tarch" done } + +arch_db_remove() { + local repo=$1 + local arch=$2 + local pkgs=(${@:3}) + + arch_repo_remove "$@" + + for pkgname in "${pkgs[@]}"; do + arch_history_remove "$repo" "$pkgname" "$arch" + done +} + +arch_history_add() { + local repo="$1" + local pkgfile="$2" + local tarches="$3" + local pkgname=$(getpkgname "$pkgfile") + local pkgbase=$(getpkgbase "$pkgfile") + local pkgver=$(getpkgver "$pkgfile") + + local history_file="$GITREPO/$repo/$tarch/$pkgname" + + mkdir -p "${history_file%/*}" + echo "$pkgbase $pkgver" > "$history_file" + + arch_git add "$history_file" +} + +arch_history_remove() { + local repo="$1" + local pkgname="$2" + local tarches="$3" + + local history_file="$GITREPO/$repo/$tarch/$pkgname" + arch_git rm "$history_file" +} + +arch_git() { + pushd "$GITREPO" + git "$@" + popd +} + @@ -4,13 +4,15 @@ . "$(dirname $0)/db-functions" if [ $# -lt 3 ]; then - msg "usage: ${0##*/} <repo-from> <repo-to> <pkgname|pkgbase> ..." + msg "usage: ${0##*/} <repo-from> <repo-to> <arch> <pkgname> ..." exit 1 fi args=(${@}) repo_from="${args[0]}" repo_to="${args[1]}" +arch="${args[2]}" +pkgs="${args[@]:3}" ftppath_from="${FTP_BASE}/${repo_from}/os/" ftppath_to="${FTP_BASE}/${repo_to}/os/" @@ -24,100 +26,16 @@ for pkgarch in ${ARCHES[@]}; do repo_lock ${repo_from} ${pkgarch} || exit 1 done -# check if packages to be moved exist in svn and ftp dir -arch_svn checkout -q -N "${SVNREPO}" "${WORKDIR}/svn" >/dev/null -for pkgbase in ${args[@]:2}; do - arch_svn up -q "${WORKDIR}/svn/${pkgbase}" >/dev/null - for pkgarch in ${ARCHES[@]} 'any'; do - svnrepo_from="${WORKDIR}/svn/${pkgbase}/repos/${repo_from}-${pkgarch}" - if [ -r "${svnrepo_from}/PKGBUILD" ]; then - pkgnames=($(. "${svnrepo_from}/PKGBUILD"; echo ${pkgname[@]})) - if [ ${#pkgnames[@]} -lt 1 ]; then - die "Could not read pkgname" - fi - - pkgver=$(. "${svnrepo_from}/PKGBUILD"; echo $(get_full_version ${epoch:-0} ${pkgver} ${pkgrel})) - if [ -z "${pkgver}" ]; then - die "Could not read pkgver" - fi - - if [ "${pkgarch}" == 'any' ]; then - tarches=(${ARCHES[@]}) - else - tarches=("${pkgarch}") - fi - - for pkgname in ${pkgnames[@]}; do - for tarch in ${tarches[@]}; do - getpkgfile "${ftppath_from}/${tarch}/"${pkgname}-${pkgver}-${pkgarch}${PKGEXT} >/dev/null - done - done - continue 2 - fi - done - die "${pkgbase} not found in ${repo_from}" -done - msg "Moving packages from [${repo_from}] to [${repo_to}]..." -declare -A add_pkgs -declare -A remove_pkgs -for pkgbase in ${args[@]:2}; do - tag_list="" - for pkgarch in ${ARCHES[@]} 'any'; do - svnrepo_from="${WORKDIR}/svn/${pkgbase}/repos/${repo_from}-${pkgarch}" - svnrepo_to="${WORKDIR}/svn/${pkgbase}/repos/${repo_to}-${pkgarch}" - - if [ -f "${svnrepo_from}/PKGBUILD" ]; then - if [ "${pkgarch}" == 'any' ]; then - tarches=(${ARCHES[@]}) - else - tarches=("${pkgarch}") - fi - msg2 "${pkgbase} ($(echo ${tarches[@]}))" - pkgnames=($(. "${svnrepo_from}/PKGBUILD"; echo ${pkgname[@]})) - pkgver=$(. "${svnrepo_from}/PKGBUILD"; echo $(get_full_version ${epoch:-0} ${pkgver} ${pkgrel})) - - if [ -d "${svnrepo_to}" ]; then - for file in $(arch_svn ls "${svnrepo_to}"); do - arch_svn rm -q "${svnrepo_to}/$file@" - done - else - mkdir "${svnrepo_to}" - arch_svn add -q "${svnrepo_to}" - fi - - for file in $(arch_svn ls "${svnrepo_from}"); do - arch_svn mv -q -r HEAD "${svnrepo_from}/$file@" "${svnrepo_to}/" - done - arch_svn rm --force -q "${svnrepo_from}" - tag_list="$tag_list, $pkgarch" - - for pkgname in ${pkgnames[@]}; do - for tarch in ${tarches[@]}; do - pkgpath=$(getpkgfile "${ftppath_from}/${tarch}/"${pkgname}-${pkgver}-${pkgarch}${PKGEXT}) - pkgfile="${pkgpath##*/}" - - ln -s "../../../${PKGPOOL}/${pkgfile}" ${ftppath_to}/${tarch}/ - if [ -f ${FTP_BASE}/${PKGPOOL}/${pkgfile}.sig ]; then - ln -s "../../../${PKGPOOL}/${pkgfile}.sig" ${ftppath_to}/${tarch}/ - fi - add_pkgs[${tarch}]+="${FTP_BASE}/${PKGPOOL}/${pkgfile} " - remove_pkgs[${tarch}]+="${pkgname} " - done - done - fi - done - tag_list="${tag_list#, }" - arch_svn commit -q "${WORKDIR}/svn/${pkgbase}" -m "${0##*/}: moved ${pkgbase} from [${repo_from}] to [${repo_to}] (${tag_list})" +for pkg in "${pkgs[@]}"; do + pkgname=$(getpkgname "$FTP_BASE/$PKGPOOL/$pkg") + # TODO: interfaces for db_add and db_remove need some work + arch_db_add "${repo_to}" "$pkg" "$arch" + arch_db_remove "${repo_from}" "$arch" "$pkgname" done -for tarch in ${ARCHES[@]}; do - if [ -n "${add_pkgs[${tarch}]}" ]; then - arch_repo_add "${repo_to}" "${tarch}" ${add_pkgs[${tarch}]} - arch_repo_remove "${repo_from}" "${tarch}" ${remove_pkgs[${tarch}]} - fi -done +arch_git commit -q -m "db-move: $add_pkgs[@]" for pkgarch in ${ARCHES[@]}; do repo_unlock ${repo_from} ${pkgarch} @@ -36,6 +36,12 @@ for pkgbase in ${pkgbases[@]}; do done for tarch in ${tarches[@]}; do - arch_repo_remove "${repo}" "${tarch}" ${remove_pkgs[@]} + arch_db_remove "${repo}" "${tarch}" ${remove_pkgs[@]} +done + +arch_git commit -q -m "db-remove: ${remove_pkgs[@]}" + +for tarch in ${tarches[@]}; do repo_unlock $repo $tarch done + @@ -52,9 +52,6 @@ for repo in ${repos[@]}; do die "Package ${repo}/${pkg##*/} does not have a valid packager" fi done - if ! check_splitpkgs ${repo} ${pkgs[@]}; then - die "Missing split packages for ${repo}" - fi else die "Could not read ${STAGING}" fi @@ -73,6 +70,8 @@ for repo in ${repos[@]}; do done done +arch_git commit -q -m "db-update: ${repos[@]}" + for repo in ${repos[@]}; do for pkgarch in ${ARCHES[@]}; do repo_unlock ${repo} ${pkgarch} |