Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37791165
en ru br
Репозитории ALT

Группа :: Разработка/Прочее
Пакет: maintenance-utils

 Главная   Изменения   Спек   Патчи   Исходники   Загрузить   Gear   Bugs and FR  Repocop 

pax_global_header00006660000000000000000000000064121311106720014504gustar00rootroot0000000000000052 comment=bc5ea862bfd592427bdf9a15d774aa6eedbbf666
maintenance-utils-1.6/000075500000000000000000000000001213111067200147705ustar00rootroot00000000000000maintenance-utils-1.6/.gear/000075500000000000000000000000001213111067200157645ustar00rootroot00000000000000maintenance-utils-1.6/.gear/rules000064400000000000000000000000071213111067200170360ustar00rootroot00000000000000tar: .
maintenance-utils-1.6/Makefile000064400000000000000000000035161213111067200164350ustar00rootroot00000000000000#
# Copyright (C) 2009 Paul Wolneykien <manowar@altlinux.org>
#
# Makefile for the maintenance-utils project.
#
# 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.
#

PROJECT = maintenance-utils
VERSION = $(shell sed '/^Version: */!d;s///;q' $(PROJECT).spec)
PROGRAMS = make-release
MAN1PAGES = $(PROGRAMS:=.1)
MANRU1PAGES = $(PROGRAMS:=.ru.1)
TARGETS = $(MAN1PAGES)

bindir = /usr/bin
datadir = /usr/share
mandir = $(datadir)/man
man1dir = $(mandir)/man1
manru1dir = $(mandir)/ru/man1
DESTDIR =

HELP2MAN1 = env PATH=":$$PATH" help2man -N -s1 -S '$(PROJECT) $(VERSION)'
INSTALL = install
LN_S = ln -s
MKDIR_P = mkdir -p
TOUCH_R = touch -r
CP = cp -a

.PHONY: all install clean

all: $(TARGETS)

%: %.in
sed \
-e 's,@VERSION@,$(VERSION),g' \
<$< >$@
$(TOUCH_R) $< $@
chmod --reference=$< $@

%.1: % %.1.inc
$(HELP2MAN1) -i $@.inc ./$< >$@

install: all
$(MKDIR_P) -m755 $(DESTDIR)$(bindir)
$(INSTALL) -p -m755 $(PROGRAMS) $(DESTDIR)$(bindir)/
$(MKDIR_P) -m755 $(DESTDIR)$(man1dir)
$(INSTALL) -p -m644 $(MAN1PAGES) $(DESTDIR)$(man1dir)/
for f in $(MANRU1PAGES); do \
[ -f "$$f" ] || continue; \
$(INSTALL) -D -m644 "$$f" $(DESTDIR)$(manru1dir)/`basename "$$f" ".ru.1"`.1; \
done

clean:
$(RM) $(TARGETS) *~
maintenance-utils-1.6/maintenance-utils.spec000064400000000000000000000041001213111067200212570ustar00rootroot00000000000000Name: maintenance-utils
Version: 1.6
Release: alt1

Summary: Utilities for package maintenance
License: GPL
Group: Development/Other
Packager: Paul Wolneykien <manowar@altlinux.ru>
BuildArch: noarch

Source: %name-%version.tar

BuildPreReq: girar-utils help2man

%description
This package contains utilities for package maintenance for Sisyphus
and git.alt build server.

%prep
%setup

%build
%make_build

%install
%make_install install DESTDIR=%buildroot

%files
%_bindir/*
%_mandir/man?/*
%_mandir/ru/man?/*

%changelog
* Wed Apr 10 2013 Paul Wolneykien <manowar@altlinux.org> 1.6-alt1
- Add support for task subnums.
- Add the script to update a local RPM repo from hasher builds.
- Checkout the specified master branch in the dry run mode.

* Thu Jul 12 2012 Paul Wolneykien <manowar@altlinux.ru> 1.5-alt1
- Take the committer name from the git config by default.
- Implement the --closes option for autoclose of bugs.

* Thu Dec 08 2011 Paul Wolneykien <manowar@altlinux.ru> 1.4-alt1
- Update the Russian manual page.
- Use `gear --describe' as a better way to obtain version/release.
- Fix/improve the branch suffix handling.

* Fri Oct 21 2011 Paul Wolneykien <manowar@altlinux.ru> 1.3-alt1
- Do not remove an existing task on fail.
- Add option to merge branches.

* Wed Apr 06 2011 Paul Wolneykien <manowar@altlinux.ru> 1.2-alt1
- Do not add branch suffix for all sisyphus* repos.
- Handle multi-number release numbers properly.
- Handle epoch numbers properly.
- Fix package version extraction in the Makefile.

* Fri Sep 24 2010 Paul Wolneykien <manowar@altlinux.ru> 1.1-alt1
- Add support for test only builds.
- Fix empty annotations in Sisyphus release tags.

* Wed Dec 30 2009 Paul Wolneykien <manowar@altlinux.ru> 1.0-alt4
- Fix changelog extract.

* Thu Dec 17 2009 Paul Wolneykien <manowar@altlinux.ru> 1.0-alt3
- Fix missing branch switch in dry-run mode.

* Mon Dec 14 2009 Paul Wolneykien <manowar@altlinux.ru> 1.0-alt2
- Do not print commit message if the files are untouched.

* Sat Dec 13 2009 Paul Wolneykien <manowar@altlinux.ru> 1.0-alt1
- Initial version of the make-release utility.
maintenance-utils-1.6/make-release000075500000000000000000000255771213111067200172710ustar00rootroot00000000000000#!/bin/sh -efu
#
# Copyright (C) 2009 Paul Wolneykien <manowar@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] [<branch name>]

$PROG makes a new release branch and tag modifying the package release
version accordingly to the build policy. Control of the remote build
task can be done with the use of the corresponding options.

$PROG uses the git configuration file. The following variables are read:

* girar.remote, corresponding to --remote;

Options:
-R,--remote=NAME girar server alias, defaults to git.alt;
-o,--origin=NAME use NAME instead of 'origin' to set up git remote;
-M,--merge[=NAME] merge branch with the master branch (default: \`master');
-b,--build create and run a remote build task, implies -t;
-t,--task[=NUM[:SUBNUM]] create a remote build task or add entry to a task NUM,
optionally the subtask id can be specified;
-C,--committer=DATA information about the committer (i.e. full name <email>);
-m,--message=MSG changelog message;
-d,--dry-run output information, do not make any changes (implies -v);
-p,--push push modifications to the remote repository;
-f,--force ignore warnings and continue;
-T,--test create and run a remote test build task, implies -b;
-c BUGS,
--closes=BUGS add "closes" clause to the changelog with BUGS as bug
number list;

-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 Paul Wolneykien <manowar@altlinux.org>

Copyright (C) 2009 Paul Wolneykien <manowar@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
}

current_branch()
{
git branch | sed -n -e 's/^\*[[:space:]]*\(.*\)$/\1/p'
}

TEMP=`getopt -n $PROG -o R:,o:,M::,b,t::,C:,m:,d,p,f,T,c:,q,v,V,h \
-l remote:,origin:,merge::,build,task::,committer:,message:,dry-run,push,force,test,closes:,quiet,verbose,version,help -- "$@"` ||
show_usage
eval set -- "$TEMP"

origin="origin"
make_task=
task_number=
run_task=
committer=
dry_run=
changelog_message=
push=
force=
test_only=
master_branch=
closes=
while :; do
case "$1" in
-R|--remote) shift; girar_remote="$1";;
-o|--origin) shift; origin="$1";;
-M|--merge) shift; master_branch="${1:-master}";;
-b|--build) push=-p; make_task=-t; run_task=-b;;
-t|--task) shift; push=-p; make_task=-t; task_number="$1";;
-C|--committer) shift; committer="$1";;
-m|--message) shift; changelog_message="$1";;
-d|--dry-run) dry_run=-d; verbose=-v;;
-p|--push) push=-p;;
-f|--force) force=-f;;
-T|--test) test_only=-T; push=-p; make_task=-t; run_task=-b;;
-c|--closes) shift; closes="$closes$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 [ -n "$closes" ]; then
closes="$(echo "$closes" | sed -e 's/,[^[:space:]]/, /g' -e 's/[[:space:]]\+/ /g')"
fi

new_task=

subtask_number=
if [ "${task_number%%:*}" != "$task_number" ]; then
subtask_number="${task_number##*:}"
task_number="${task_number%%:*}"
fi

branch_name=
branch_suffix=
if [ $# -gt 0 ]; then
branch_name="$1"
case "$branch_name" in
c6) branch_suffix="M55C";;
[a-z][0-9]*) branch_suffix="M$(echo ${branch_name#[a-z]}0${branch_name%[0-9]*} | tr [:lower:] [:upper:])";;
sisyphus*) branch_suffix=;;
*) branch_suffix="M$(echo "$branch_name" | sed -e 's/\.//g')";;
esac
branch_suffix="$branch_suffix"
else
branch_name="sisyphus"
branch_suffix=
fi

verbose "Branch name: $branch_name"
verbose "Branch suffix: $branch_suffix"

rules="${RULES-}"
main_tree_id='HEAD'
specfile=

cleanup_handler()
{
[ -z "$workdir" ] || rm -rf -- "$workdir"
[ "$(current_branch)" = "$orig_branch" ] || git checkout "$orig_branch"
if [ "$1" -ne 0 ]; then
if [ -n "$new_task" ] && [ "$new_task" != "no" ]; then
message "Remove task $task_number from the $girar_remote"
run_remote_command task rm "$task_number"
fi
fi
}

install_cleanup_handler cleanup_handler
workdir="$(mktemp -dt "$PROG.XXXXXXXXXX")"

orig_branch="$(current_branch)"
if [ "$orig_branch" != "$branch_name" ]; then
if [ -z "$(git branch | sed -n -e "s/^\*\?[[:space:]]*\($branch_name\)$/\1/p")" ]; then
if [ -n "$dry_run" ]; then
message "Would create branch $branch_name"
else
git branch "$branch_name"
git checkout "$branch_name"
fi
else
if [ -n "$master_branch" ] && ! git diff --quiet "$master_branch" "$branch_name"; then
if [ -n "$dry_run" ]; then
message "Would merge branch $master_branch into $branch_name"
else
git checkout "$branch_name"
git merge "$master_branch"
fi
else
git checkout "$branch_name"
fi
fi
fi

find_specfile

[ -n "$specfile" ] || fatal "Spec file not found"
verbose "Working spec file: $specfile"
eval $(gear --describe | while read n v r; do echo "package_name='$n'; package_version='$v'; package_release='$r'"; done)

[ -n "$package_version" ] || fatal "Unable to get the package version"
package_version_plain="$package_version"
[ -n "$package_release" ] || fatal "Unable to get the package release"
package_epoch="$(sed -n -e "s/^Epoch:[[:space:]]\+\(.*\)$/\1/p" "$specfile")"
if [ -n "$package_epoch" ]; then
package_version="$package_epoch:$package_version"
fi

version_pattern="^\* ... ... .. .... .* <.*@.*> \([^-]\+-.*\)$"
last_version="$(cat $specfile | sed -n -e "/$version_pattern/ {s/$version_pattern/\1/p; q}")"

if [ "$package_version-$package_release" != "$last_version" ]; then
if [ -z "$force" ]; then
verbose "Package version: $package_version-$package_release"
verbose "Last changelog entry version: $last_version"
fatal "Warning! Package version doesn't match last changelog entry. Fix or use --force to ignore this warning."
fi
fi

branch_release_version=
if [ -n "$branch_suffix" ] && [ "${last_version%%*.$branch_suffix.*}" = "$last_version" ]; then
branch_release_pattern="^\* ... ... .. .... .* <.*@.*> [^-]\+-.*\.$branch_suffix\.\([0-9]\+\)$"
last_branch_release="$(cat $specfile | sed -n -e "/$branch_release_pattern/ {s/$branch_release_pattern/\1/p; q}")"
if [ -n "$last_branch_release" ]; then
branch_release_version="$(( $last_branch_release + 1 ))"
else
branch_release_version=1
fi
package_release="${package_release%%.M*}"
release_pref="${package_release%%[0-9]*}"
release_num="$(echo "$package_release" | sed -e 's/^.*alt\([0-9]\+\).*$/\1/')"
release_suf="${package_release##$release_pref$release_num}"
[ -n "$release_suf" ] && release_suf="$release_suf."
release_num=$(( $release_num - 1 ))
[ -n "$branch_suffix" ] && branch_suffix=".$branch_suffix"
package_release="$release_pref$release_num$release_suf$branch_suffix.$branch_release_version"
fi

verbose "Package version: $package_version-$package_release"

if [ -z "$committer" ]; then
committer="$(git config --get user.name) <$(git config --get user.email)>"
fi
if [ -z "$committer" ]; then
committer_pattern="^\* ... ... .. .... \(.*\) \(<.*@.*>\) .*$"
committer="$(cat $specfile | sed -n -e "/$committer_pattern/ {s/$committer_pattern/\1 \2/p; q}")"
[ -n "$committer" ] || fatal "Unable to get information about the last committer"
fi
verbose "Package committer: $committer"

if [ "$last_version" != "$package_version-$package_release" ]; then
[ -z "$changelog_message" ] && changelog_message="Release $branch_release_version for the branch $branch_name"
[ -n "$closes" ] && changelog_message="$changelog_message (closes: $closes)"
verbose "Commit comment message: $changelog_message"
changelog_entry="* $(LANG=C; date +'%a %b %d %Y') $committer $package_version-$package_release"
verbose "Changelog entry: $changelog_entry"
if [ -z "$dry_run" ]; then
sed -i -e "s/^\(Release:[[:space:]]\+\).*$/\1$package_release/" \
-e "/^%changelog/ a${changelog_entry}\n- ${changelog_message}.\n" "$specfile"
verbose "Commit spec file"
git add "$specfile"
git commit -q -m "$changelog_message" "$specfile"
fi
else
verbose "Files are untouched"
if [ -z "$changelog_message" ]; then
changelog_message="Release of v$package_version-$package_release"
fi
verbose "Tag annotation: $changelog_message"
fi

if [ -n "$dry_run" ] && [ -n "$test_only" ]; then
verbose "TEST only mode on"
fi

tag_name="v$package_version_plain-$package_release"
verbose "Release tag: $tag_name"
if [ -z "$dry_run" ]; then
verbose "Tag and sign the branch"
git tag -a -s $([ -n "$force" ] && echo -f) -m "$changelog_message" -u "${committer%<*@*>*}" "$tag_name"
fi

if [ -z "$dry_run" ] && [ -n "$push" ]; then
verbose "Push the $branch_name to the $origin remote"
git push -q "$origin" "$branch_name" $([ -n "$force" ] && echo --force)
verbose "Push the tags to the $origin remote"
git push -q --tags "$origin" $([ -n "$force" ] && echo --force)

if [ -n "$make_task" ]; then
remote_path="$(git remote -v | sed -n -e "s/^$origin[[:space:]]\+$girar_remote:\(.*\.git\)[[:space:]]\+(push)$/\1/p")"
[ -n "$remote_path" ] || fatal "Unable to figure out push path of the remote $origin at $girar_remote server"
if [ -z "$task_number" ]; then
verbose "Make new remote task at the $girar_remote server"
task_number="$(run_remote_command task new "$branch_name" 2>&1 | sed -n -e '/^new task/ {s/^.*#\([0-9]\+\):.*$/\1/p; q}')"
new_task=yes
fi
[ -n "$task_number" ] || fatal "No task number"
verbose "Task number: $task_number"
[ -z "$subtask_number" ] || verbose "Subtask number: $subtask_number"
verbose "Add a build tag for "$remote_path" "$tag_name" to the task $task_number"
run_remote_command task add "$task_number" $subtask_number repo "$remote_path" "$tag_name"
if [ -n "$run_task" ]; then
if [ -z "$test_only" ]; then
verbose "Run task $task_number"
run_remote_command task run "$task_number"
else
verbose "Run task $task_number in TEST mode"
run_remote_command task run --test-only "$task_number"
fi
fi
fi
fi
maintenance-utils-1.6/make-release.1.inc000064400000000000000000000023361213111067200201610ustar00rootroot00000000000000.\" Copyright (C) 2009 Paul Wolneykien <manowar@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.

[NAME]
make-release \- automatic make of a new release of a package, setting the next branch release version, adding a comment, tagging the branch, pushing it to the remote repository, queueing and running the build task for it.

[ENVIRONMENT]
.TP
.B GIT_DIR
If the
.B GIT_DIR
environment variable is set then it specifies a path to use instead of
the default for the base of the repository.

[SEE ALSO]
.BR git-config (1),
.BR gear (1),
.BR git-push (1).
maintenance-utils-1.6/make-release.ru.1000064400000000000000000000112101213111067200200250ustar00rootroot00000000000000.\" hey, Emacs: -*- nroff -*-
.TH MAKE-RELEASE 1 "Декабрь, 2009"

.\" Copyright (C) 2009 Paul Wolneykien <manowar@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.

.SH НАЗВАНИЕ
make-release \- автоматическое создание нового выпуска пакета на основе
текущей ветки gear-репозитария, включая установку следующей сборочной
версии в spec-файле, комментирование операции в журнале изменений,
установку тега, загрузку изменений в удалённый репозитарий и
отправления задания для удалённой сборки на сборочном сервере.

.SH АННОТАЦИЯ
.B make-release
.RI [ опции ]\ [<имя\ ветки>]

.SH ОПИСАНИЕ
С помощью программы \fBmake-release\fP можно легко выполнить все
формальные операции, необходимые для выпуска новой версии пакета для
определённой ветки после того, как все изменения в пакете уже
подготовлены. Программа сама определит правильную сборочную версию
исходя из анализа журнала изменений. Все изменения репозитария,
производимые программой, ограничиваются spec-файлом и тегами, и
снабжаются простыми комментариями.
.PP
Однако поскольку изменения всё же являются достаточно ответственными,
все они по умолчанию производятся лишь локально. С помошью
соответствующих опций можно вызвать загрузку изменений в удалённый
репозиторий, создание задания на удалённую его сборку и запуск
задания.

.SH АРГУМЕНТЫ
\fBmake-release\fP поддерживает следующие аргументы коммандной строки:
.TP
.BI \-R\ ПСЕВДОНИМ ,\ \-\-remote= ПСЕВДОНИМ
псевдоним сборочного сервера, по умолчанию `git.alt';
.TP
.BI \-o\ ИМЯ ,\ \-\-origin= ИМЯ
имя удалённого репозитария, по умолчанию `origin';
.TP
.BI \-M[ВЕТКА]\ ИМЯ ,\ \-\-merge[=ВЕТКА]
обновить целевую ветку из ветки `master' или указанной ветки;
.TP
.BR -b ", " --build
собрать новый выпуск пакета на сборочном сервере;
.TP
.BI \-t\ [НОМЕР[:SUBNUM]] ,\ \-\-task= [НОМЕР[:SUBNUM]]
создать новое задание или добавить операцию сборки пакета в задание с
указанным номером, но не запускать его; опционально может быть указан
номер подзадания;
.TP
.BI \-C\ ДАННЫЕ ,\ \-\-committer= ДАННЫЕ
информация о лице производящем изменения в формате `Имя Фамилия <адрес
электронной почты>';
.TP
.BI \-m\ ТЕКСТ ,\ \-\-message= ТЕКСТ
сообщение, помещаемое в качестве коментария вместо автоматического
комментария по умолчанию;
.TP
.BR -d ", " --dry-run
не производить, но сообщать о предполагаемых изменениях (режим
предварительного просмотра);
.TP
.BR -p ", " --push
загрузить изменения в удалённый репозитарий;
.TP
.BR -f ", " --force
действовать упорно, игнорируя возникающие ошибки и предупреждения
(используйте ОСТОРОЖНО);
.TP
.BR -T ", " --test
собрать новый выпуск пакета на сборочном сервере в ТЕСТОВОМ режиме;
.TP
.BI \-c\ БАГИ ,\ \-\-closes= БАГИ
добавляет в сообщение об изменениях команду вида (closes: БАГИ);
.TP
.BR -q ", " --quiet
подавляет вывод информационных сообщений;
.TP
.BR -v ", " --verbose
вывод информационных сообщений о производимых операциях;
.TP
.BR -V ", " --version
вывести информацию о версии программы и больше ничего не делать;
.TP
.BR -h ", " --help
вывести информацию об способе использования программы.

.SH АВТОР
Paul Wolneykien <manowar@altlinux.org>.
.SH ЛИЦЕНЗИЯ
Copyright (C) 2009 Paul Wolneykien.
.PP
Данная программа свободна: вы можете свободно распростанять и/или
изменять её по собственному желанию в соответствие с требованиями
Общественного Соглашения GNU (GNU General Public License) Фонда
Свободного программного обеспечения (Free Software Foundation), версии
3 или (по вашему желанию) любой, более новой версии Общественного
лицензионного Соглашения.
.PP
Программа распространяется в надежде, что она будет полезна но БЕЗ
ВСЯЧЕСКИХ ГАРАНТИЙ, включая подразумеваемую гарантию КАЧЕСТВА либо
ПРИГОДНОСТИ ДЛЯ ОПРЕДЕЛЕННЫХ ЦЕЛЕЙ. Для дополнительных сведений,
обращайтесь к полной версии GNU GPL, копию которой вы должны были
получить вместе с программой, или по адресу
<\fBhttp://www.gnu.org/licenses/\fR>.
.SH КОНТАКТНАЯ ИНФОРМАЦИЯ
.PP
Волнейкин Павел Анатольевич (manowar@altlinux.org).
.PP
119334, г. Москва, 5-й Донской проезд, д. 15, стр. 6, ООО "Альт Линукс"
maintenance-utils-1.6/update-repo000075500000000000000000000043001213111067200171400ustar00rootroot00000000000000#!/bin/sh -efu

src=
dst=

if [ $# -gt 1 ]; then
src="$1"
dst="$2"
elif [ $# -eq 1 ]; then
dst="$1"
if [ -d "$HOME/hasher/repo" ]; then
src="$HOME/hasher/repo"
elif [ -d "$TMPDIR/hasher/repo" ]; then
src="$TMPDIR/hasher/repo"
else
echo "Source repo not found. Try an explicit arg" >&2
exit 2
fi
else
echo "Usage: ${0##*/} [src] dst" >&2
exit 1
fi

if [ ! -d "$dst" ]; then
if [ -d "$HOME/$dst" ]; then
dst="$HOME/$dst"
elif [ -d "$HOME/repo/$dst" ]; then
dst="$HOME/repo/$dst"
else
echo "Destination $dst doesn't exist" >&2
exit 3
fi
fi

src="${src%/}"
dst="${dst%/}"

_strip_ver() {
local name="${1%-*.*.rpm}"
echo "${name%-*}"
}

_get_arch_cmp() {
local pkg="$1"
local cmp=

case "${pkg%%/*}" in
SRPMS.*)
echo -n 'SRPMS '
cmp="${pkg%%/*}"
echo "${cmp#SRPMS.}"
;;
*)
echo -n "${pkg%%/*} "
cmp="${pkg#*/}"
cmp="${cmp%%/*}"
echo "${cmp#RPMS.}"
;;
esac
}

_get_ver() {
local ver="${1#$(_strip_ver "$1")-}"
echo "${ver%.*.rpm}"
}

_get_lesser_ver() {
local basef="$(_strip_ver "$1")"
local basef2=

for f2 in $(find "$dst" -path "${dst%/}/${basef#$src/}-*.*.rpm"); do
basef2="$(_strip_ver "$f2")"
if [ "${basef#$src/}" = "${basef2#$dst/}" ]; then
echo "$f2"
fi
done
}

_touch_dir() {
local path="$1"
touch "${path%/*}/.updated"
}

for f in $(find "$src" -name '*.rpm'); do
basef="$(_strip_ver "$f")"
if [ -e "$dst/${f#$src/}" ]; then
echo "[sync] ${basef##*/} $(_get_ver "${f#$src/}") $(_get_arch_cmp "${f#$src/}")"
rsync -q "$f" "$dst/${f#$src/}"
_touch_dir "$dst/${f#$src/}"
else
f2="$(_get_lesser_ver "$f")"
if [ -n "$f2" ]; then
echo "[update] ${basef##*/} $(_get_ver "${f2#$dst/}") $(_get_ver "${f#$src/}") $(_get_arch_cmp "${f#$src/}")"
rm -f $f2
cp -a "$f" "$dst/${f#$src/}"
_touch_dir "$dst/${f#$src/}"
else
echo "[new] ${basef##*/} $(_get_ver "${f#$src/}") $(_get_arch_cmp "${f#$src/}")"
cp -a "$f" "$dst/${f#$src/}"
_touch_dir "$dst/${f#$src/}"
fi
fi
done | sort

for f in $(find "$dst" -name '.updated'); do
_get_arch_cmp "${f#$dst/}" | (
read -r arch cmp
if [ "$arch" != "SRPMS" ]; then
echo "[genbasedir] $arch $cmp" >&2
genbasedir --create --topdir="$dst" "$arch" "$cmp"
fi
)
rm -f "$f"
done
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin