ALT Linux Team development discussions
 help / color / mirror / Atom feed
From: Alexey Tourbin <at@altlinux.ru>
To: devel@lists.altlinux.org
Subject: [devel] alternatives.prov
Date: Wed, 28 Mar 2007 21:30:44 +0400
Message-ID: <20070328173044.GC5336@solemn.turbinal> (raw)

[-- Attachment #1: Type: text/plain, Size: 6230 bytes --]

При сборке git-1.5.1 с kernel.org с моим rpm-build (бранч mod) у пакета
git-core появился unmet на /usr/bin/emacs.  Выяснилось, что новый скрипт
/usr/bin/git-mergetool вытаскивает много лишних зависимостей на всякие
утилиты типа vimdiff, kdiff3 и до кучи emacs.  Наиболее правильным
решением тут будет просто отключить поиск зависимостей в
/usr/bin/git-mergetool, но образование unmet'а на /usr/bin/emacs 
требует отедльного рассмотрения.

Дело в том, что /usr/bin/emacs никто не предоставляет как зависимость,
и файл /usr/bin/emacs тоже не принадлежт ни одному пакету, а висит на
альтернативах.  В связи с этим новый rpm-build проставляет голую
зависимость на /usr/bin/emacs, и я считаю, что это правильно.

Проблема тут в том, что maintainer пакета emacs22 забыл добавить
в некоторые пакеты Provides: /usr/bin/emacs.  Не он один забывает это
сделать, напр. /usr/bin/javac тоже висит на альтернативах и никем не
прдоставляется.  Полагаю, что этим список потенциальных анметов не
исчерпывается.

Чтобы решить эту проблему, я решил добавить специальный provides метод
в пакет alternatives.  Он добавляет в provides все альтернативы которые
начинаются с /usr/bin/ и /usr/sbin/.

Ниже приведены некоторые подробности.  Есть ли недостатки у этого
подхода?  Может образоваться некоторое (небольшое) количество "мусорных"
provides, типа /usr/bin/autoconf-default или /usr/bin/i586-alt-linux-gcc.
С другой стороны, в принципе предусмотрено отключение любого prov метода.


commit 28c294aeb30f638727477724b1f3cf3328855d7e
Author: Alexey Tourbin <at@altlinux>
Date:   Wed Mar 28 14:58:54 2007 +0400

    alternatives.prov: check that alternative target is acutally available
    
    $ rpm -qf /etc/alternatives/packages.d/xemacs
    xemacsen-0.4-alt1
    $ cat /etc/alternatives/packages.d/xemacs
    /usr/bin/xemacs /usr/bin/xemacs-x11             80
    /usr/bin/xemacs /usr/bin/xemacs-nox             70
    /usr/bin/xemacs /usr/bin/xemacs-mule            60
    /usr/bin/xemacs /usr/bin/xemacs-mule-nextaw     50
    /usr/bin/xemacs /usr/bin/xemacs-nomule          40
    /usr/bin/xemacs /usr/bin/xemacs-nomule-nextaw   30
    /usr/bin/xemacs /usr/bin/xemacs-nox-mule        20
    /usr/bin/xemacs /usr/bin/xemacs-nox-nomule      10
    $ ls /usr/bin/xemacs*
    zsh: no matches found: /usr/bin/xemacs*
    $
    
    In this case, we should NOT provide /usr/bin/xemacs.

diff --git a/alternatives/alternatives.prov b/alternatives/alternatives.prov
index e7e7e58..ccba5d5 100755
--- a/alternatives/alternatives.prov
+++ b/alternatives/alternatives.prov
@@ -5,7 +5,18 @@
 AlternativesProv()
 {
 	local f="$1"; shift
-	awk '$1 ~ /^\/usr\/s?bin\// {print $1}' "$f"
+	local link bin rest
+	while read -r link bin rest; do
+		case "${link-}" in
+			/usr/bin/*|/usr/sbin/*)
+				;;
+			*)
+				continue ;;
+		esac
+		if [ -x "${RPM_BUILD_ROOT-}$bin" ]; then
+			echo "$link"
+		fi
+	done <"$f"
 }
 
 ArgvFileAction AlternativesProv "$@"

commit e51b5a69a2f3a2bc92abc16462e3137366ce995e
Author: Alexey Tourbin <at@altlinux>
Date:   Wed Mar 28 14:23:42 2007 +0400

    added alternatives.prov and alternatives.prov.files, for new rpm-build
    
    /usr/bin/emacs is not provided by any package:
    
    $ rpm -q --whatprovides /usr/bin/emacs
    warning: no package provides /usr/bin/emacs
    $
    
    Now consider shell script which invokes emacs.  Depending on
    /usr/lib/rpm/find-package peculiarities, there are two possible outcomes:
    1) dependency on emacs is lost;
    2) /usr/bin/emacs unmet dependency is generated.
    
    I think that both variants are not quite acceptable.
    
    Note that the root of the problem is that /usr/bin/emacs is not provided
    by any package.  Also note that /usr/bin/emacs is really an alternative:
    
    $ ls -l /usr/bin/emacs
    lrwxrwxrwx 1 root root 38 Jul  5  2006 /usr/bin/emacs -> /etc/alternatives/links/|usr|bin|emacs
    $
    
    The idea is that we can process the alternatives/packages.d/ file
    and automatically provide paths under /usr/bin and /usr/sbin.
    
    $ grep /usr/bin/ /etc/alternatives/packages.d/emacs22-nox
    /usr/bin/emacs22        /usr/bin/emacs22-nox    10
    /usr/bin/emacs  /usr/bin/emacs22-nox    10
    $ alternatives/alternatives.prov /etc/alternatives/packages.d/emacs22-nox
    /usr/bin/emacs22
    /usr/bin/emacs
    $
    
    Also note that there are a few other similar cases:
    
    $ rpm -q --whatprovides /usr/bin/javac
    warning: no package provides /usr/bin/javac
    $ rpm -q --whatprovides `realpath /usr/bin/javac`
    j2se1.5-sun-devel-1.5.0_11-alt1
    $

diff --git a/alternatives.spec b/alternatives.spec
index ef2f759..327de0d 100644
--- a/alternatives.spec
+++ b/alternatives.spec
@@ -62,6 +62,9 @@ cat >$RPM_BUILD_ROOT%_sysconfdir/rpm/macros.d/%name<<EOF
 %%preun_remove_alts %%preun_remove_alternatives
 EOF
 
+install -pD -m755 alternatives.prov %buildroot%_rpmlibdir/alternatives.prov
+install -pD -m755 alternatives.prov.files %buildroot%_rpmlibdir/alternatives.prov.files
+
 %post
 %_bindir/%name-upgrade
 %_bindir/%name-update
@@ -75,6 +78,8 @@ chmod 644 /etc/alternatives/packages.d/* 2>/dev/null ||:
 %_sbindir/*
 %_datadir/%name
 %_man1dir/*
+%_rpmlibdir/alternatives.prov
+%_rpmlibdir/alternatives.prov.files
 
 %changelog
 * Thu Feb 01 2007 Stanislav Ievlev <inger@altlinux> 0.3-alt1
diff --git a/alternatives/alternatives.prov b/alternatives/alternatives.prov
new file mode 100755
index 0000000..e7e7e58
--- /dev/null
+++ b/alternatives/alternatives.prov
@@ -0,0 +1,11 @@
+#!/bin/sh -efu
+
+. /usr/lib/rpm/functions
+
+AlternativesProv()
+{
+	local f="$1"; shift
+	awk '$1 ~ /^\/usr\/s?bin\// {print $1}' "$f"
+}
+
+ArgvFileAction AlternativesProv "$@"
diff --git a/alternatives/alternatives.prov.files b/alternatives/alternatives.prov.files
new file mode 100755
index 0000000..7b98b83
--- /dev/null
+++ b/alternatives/alternatives.prov.files
@@ -0,0 +1,5 @@
+#!/bin/sh -efu
+while IFS=$'\t' read -r f t; do
+	[ -z "${f##${RPM_BUILD_ROOT-}/etc/alternatives/packages.d/*}" ] &&
+		[ -z "${t##* text*}" ] && echo "$f" ||:
+done

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

             reply	other threads:[~2007-03-28 17:30 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-28 17:30 Alexey Tourbin [this message]
2007-03-28 18:39 ` Alexey Tourbin
2007-03-28 23:22   ` Dmitry V. Levin
2007-04-15  3:01     ` Alexey Tourbin
2007-03-29 12:44 ` Igor Vlasenko
2007-04-15  6:29 ` [devel] не могу собрать профиль сервера Денис Смирнов
2007-04-15  8:32   ` Sergey Bolshakov
2007-04-15  9:21     ` Денис Смирнов
2007-04-15  9:35       ` Dmitry V. Levin
2007-04-15 11:09         ` Sergey Bolshakov
2007-04-15 12:17           ` Konstantin A. Lepikhov
2007-04-15 12:29             ` Dmitry V. Levin
2007-04-15 19:36               ` Konstantin A. Lepikhov
2007-04-15 20:19                 ` Dmitry V. Levin

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=20070328173044.GC5336@solemn.turbinal \
    --to=at@altlinux.ru \
    --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