ALT Linux Team development discussions
 help / color / mirror / Atom feed
From: "Alexey I. Froloff" <raorn@altlinux.org>
To: ALT Devel discussion list <devel@lists.altlinux.org>
Subject: Re: [devel] I: gear-massupdate subdir file... [-- gear-update options]
Date: Sun, 28 Jun 2009 21:17:31 +0400
Message-ID: <20090628171731.GD27278@altlinux.org> (raw)
In-Reply-To: <4A475B1C.8090707@altlinux.ru>


[-- Attachment #1.1: Type: text/plain, Size: 570 bytes --]

On Sun, Jun 28, 2009 at 03:59:24PM +0400, Alexey Gladkov wrote:
> > Правильно ли я понял, что эта утилита полезна лишь тогда, когда
> > какой-то проект добавляется в gear из исходников ?
> Если да, то тогда её стоит назвать gear-import и добавить функционал ldv.
Задача сводится к:

1. Распарсить имя файла на название проекта и версию.
2. Заполнить шаблон.

.gear/rules и спек недоступны.

Proof of concept в аттаче.  Не поддерживает тарболы вида
http://ftp.debian.org/debian/pool/main/a/adduser-ng/adduser-ng_0.1.2-1.3.tar.gz

-- 
Regards,
Sir Raorn.

[-- Attachment #1.2: gear-massupdate --]
[-- Type: text/plain, Size: 1325 bytes --]

#!/bin/sh -efu

. gear-sh-functions

name=
version=
file=
parse_filename()
{
	local sep tmp
	name=
	version=
	file="${1##*/}"

	# .(tar(.gz|.bz2.wtf)?|t(gz|bz?2|wtf))
	tmp="${file%.*}"
	tmp="${tmp%.tar}"
	# .orig.tar.gz
	tmp="${tmp%.orig}"

	# name-version-(src|sources|whatever)
	if printf %s "$tmp" | egrep -qse '-[a-z]+$' >/dev/null 2>&1; then
		tmp="${tmp%-*}"
	fi

	# name-version and name_version
	sep=_
	[ -z "${tmp##*_*}" -a -n "${tmp##*_*-*}" ] ||
		sep=-

	name="${tmp%$sep*}"
	version="${tmp#$name$sep}"
}

commit_msg='Imported @file@'
tag_name='@name@-@version@'
tag_msg='@name@ @version@'

subdir="$1" && shift
files=
while [ $# -gt 0 ]; do
	case "$1" in
		--) shift; break;;
		*) files="$files
$1" ;;
	esac
	shift
done

for f in $files; do
	parse_filename "$f"

	tmp_ci_msg="$commit_msg"
	tmp_tag_name="$tag_name"
	tmp_tag_msg="$tag_msg"
	
	subst_key_in_vars '@file@' "$file" tmp_ci_msg tmp_tag_name tmp_tag_msg
	subst_key_in_vars '@name@' "$name" tmp_ci_msg tmp_tag_name tmp_tag_msg
	subst_key_in_vars '@version@' "$version" tmp_ci_msg tmp_tag_name tmp_tag_msg

	git clean -f -d "$subdir"
	gear-update "$@" -- "$f" "$subdir"
	faketime -r "$f" -- git commit -m "$tmp_ci_msg"
	faketime -r "$f" -- git tag -f -m "$tmp_tag_msg" "$tmp_tag_name"
done

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

  reply	other threads:[~2009-06-28 17:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-28  8:00 Alexey I. Froloff
2009-06-28 11:14 ` Dmitry V. Levin
2009-06-28 11:51   ` Alexey Gladkov
2009-06-28 13:50     ` Alexey I. Froloff
2009-06-28 11:57 ` Alexey Gladkov
2009-06-28 11:59   ` Alexey Gladkov
2009-06-28 17:17     ` Alexey I. Froloff [this message]
2009-06-28 17:32       ` Alexey I. Froloff
2009-06-28 18:12         ` Dmitry V. Levin
2009-06-28 17:18     ` Alexey I. Froloff

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=20090628171731.GD27278@altlinux.org \
    --to=raorn@altlinux.org \
    --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