From: Michael Shigorin <mike@osdn.org.ua>
To: devel@lists.altlinux.org
Subject: [devel] RFC: girar-download (was: [newbies] gear. Первый опыт)
Date: Fri, 1 Jan 2010 22:44:19 +0200
Message-ID: <20100101204419.GA10094@osdn.org.ua> (raw)
In-Reply-To: <20091230131439.GA21933@altlinux.org>
[-- Attachment #1: Type: text/plain, Size: 838 bytes --]
On Wed, Dec 30, 2009 at 04:14:39PM +0300, Alexey I. Froloff wrote:
> > git remote add origin git.alt:packages/$(basename `pwd`)
> girar-upload
Подумал и сочинил по мотивам того письма girar-download наконец.
Возможно, лучше было бы назвать girar-remotes, но так очевидней.
К сожалению, разуть глаза на girar-clone сообразил только уже
при написании этого письма -- но он всё равно реализует немного
другую задачу: вытащить/обновить всех, кто занимается пакетом
(возможно, стоя в уже существующем репо).
Прилагаю демо-версию (также отправлена в мой girar-utils.git),
прошу комментариев по TODO в конце скрипта и надеюсь увидеть
доработанный вариант в пакете.
* http://lists.altlinux.org/pipermail/devel-newbies/2009-December/000123.html
--
---- WBR, Michael Shigorin <mike@altlinux.ru>
------ Linux.Kiev http://www.linux.kiev.ua/
[-- Attachment #2: girar-download --]
[-- Type: text/plain, Size: 3459 bytes --]
#!/bin/sh -efu
#
# Copyright (C) 2010 Michael Shigorin <mike@altlinux.org>
#
# This file 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, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
#
. gear-sh-functions
. girar-client-sh-functions
show_help()
{
cat <<EOF
Usage: $PROG [options] [<package> [<maintainer>...]]
$PROG facilitates downloading an existing project repo from git.alt.
Desired package name should be either specified explicitly
or $PROG will assume that current working directory is inside
a corresponding existing git repo (to just add remotes).
Options:
-N,--no-update do not try to download remote repos;
-q,--quiet try to be more quiet;
-v,--verbose print a message for each action;
-V,--version print program version and exit;
-h,--help show this text and exit.
Report bugs to http://bugs.altlinux.ru/
EOF
exit
}
print_version()
{
cat <<EOF
$PROG version $PROG_VERSION
Written by Michael Shigorin <mike@altlinux.org>
Copyright (C) 2010 Michael Shigorin <mike@altlinux.org>
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE.
EOF
exit
}
init_repo()
{
verbose "initializing gear repo"
mkdir -p "$1"
cd "$1"
git init
}
git_dir()
{
verbose "figuring out git directory"
GIT_DIR="$(git rev-parse --git-dir)"
GIT_DIR="$(readlink -ev "$GIT_DIR")"
export GIT_DIR
package="${GIT_DIR%.git}"
package="${package%/}"
printf "%s\n" "${package##*/}"
}
add_remote()
{
verbose "adding $1"
git remote add "$1" "$(girar-remote-uri "$package" "$1")"
}
TEMP=`getopt -n $PROG -o N,q,v,V,h \
-l no-update,quiet,verbose,version,help -- "$@"` ||
show_usage
eval set -- "$TEMP"
no_update=
while :; do
case "$1" in
-N|--no-update) no_update=1;;
-q|--quiet) quiet=-q;;
-v|--verbose) verbose=-v;;
-V|--version) print_version;;
-h|--help) show_help;;
--) shift; break;;
*) fatal "unrecognized option: $1";;
esac
shift
done
if [ "$#" -gt 0 ]; then
package="$1"; shift
[ -d "$package" ] || init_repo "$package"
else
package="$(git_dir)" || show_help
fi
if [ "$#" -gt 0 ]; then
verbose "going after specified maintainers"
for maintainer in "$@"; do
add_remote "$maintainer"
done
else
verbose "looking for remote repositories"
run_remote_command find-package "$package" |
while read path timestamp; do
maintainer="${path#/people/}"
add_remote "${maintainer%/packages/*}"
done
fi
[ -n "$no_update" ] || {
verbose "updating remotes"
git remote update
}
# TODO:
# - options to add only package maintainer/acl folks/N recent
# - add gears remote too
# - automate initial merge e.g. according to gears archive
# - compare proposed remotes against `git remote show`
# to either skip or force adding existing ones
# - consider --max-age option to omit stale repos
parent reply other threads:[~2010-01-01 20:44 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <20091230131439.GA21933@altlinux.org>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100101204419.GA10094@osdn.org.ua \
--to=mike@osdn.org.ua \
--cc=devel@lists.altlinux.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
ALT Linux Team development discussions
This inbox may be cloned and mirrored by anyone:
git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \
devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru
public-inbox-index devel
Example config snippet for mirrors.
Newsgroup available over NNTP:
nntp://lore.altlinux.org/org.altlinux.lists.devel
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git