[Momonga-devel.ja:01894] Re: xsane packaging fail


小松です。

From: Shibata <cipher@xxxxxxxxxxxxxxxx>
Subject: [Momonga-devel.ja:01893] Re: xsane packaging fail
Date: Wed, Jul 09, 2003 at 11:34:08PM JST

> > ということで、xsane.specで
> >     ln -sf %{_bindir}/xsane .
> > としているところを
> >     ln -sf ../../../../bin/xsane .
> > もしくは
> >     ln -sf ../../../../..%{_bindir}/xsane .
> > とするのはいかがでしょうか。
> plug-insへのlinkをインストール後へ移しました。
> 何回もテストしましたので問題ないと思います。

0.91-1m -> 0.91-2m への upgrade でこの symlink が消されますね。
これは、rpm が次のような動作をするからです
(オプション -vv をつければ確認できます)。

    (1.1) まず 0.91-2m が install され、%post が実行される。
    (1.2) 0.91-1m の file のうち、0.91-2m の %files に
          存在しないものが消される。
          gimp plugin の symlink は 0.91-2m の %files には存在しないため、
	  ここで消されている。

%files でニギっていた symlink を %post などの移す時に
注意しないといけない点なのですが、あまり知られていないかもしれません。
対策としては次のような方法があります。

    (2.1) %install section で dummy のファイルを作る。
    (2.2) %files section でそのファイルを %ghost としてニギっておく。

0.91-2m と 0.91-3m との差分を添付しておくので、
詳しくはそちらを御覧下さい。


もう1点。%postun で symlink を消していますが、
upgrade 時には rpm が次のような動作をするため、問題を起こします。

    (3.1) まず、0.91-2m を install し、その %post を実行する。
    (3.2) その後で 0.91-1m の %postun を実行する。

upgrade 時はまず install が実行され、その後で erase が実行されると
覚えておけばよいでしょう。
対策としては、upgrade 時に実行して欲しくない script は

    if [ $1 -eq 0 ]; then
    ...
    fi

で括っておけばよいでしょう。


以上を fix した xsane-0.91-3m を commit しましたが、
xsane-0.91-2m の %postun で plugin の symlink が消されると思います。
手動で symlink を張り直すか、install し直して下さい。

-- 
---------------------------------------
東京大学大学院総合文化研究科
広域科学専攻相関基礎科学系 
  佐々研究室  博士4年
    小松  晋一朗            
koma2@xxxxxxxxxxxxxxxxxxxx
koma2@xxxxxxxxxxxxxxxxx
http://kamuy.c.u-tokyo.ac.jp/~koma2/
---------------------------------------
Index: xsane.spec
===================================================================
RCS file: /home/cvs/pkgs/xsane/xsane.spec,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -u -r1.10 -r1.11
--- xsane.spec	9 Jul 2003 14:30:26 -0000	1.10
+++ xsane.spec	9 Jul 2003 21:06:36 -0000	1.11
@@ -1,4 +1,4 @@
-%define momorel 2
+%define momorel 3
 
 Summary: XSANE -- scanner frontend for SANE
 Name: xsane
@@ -65,6 +65,15 @@
 rm -rf %{buildroot}
 %makeinstall
 
+## make dummy file into gimp-plugin dir
+## this file is included as %%ghost in %%files section
+# currently xsane does not support gimp-1.3
+for gimpver in 1.2; do
+    gimpplugindir=`gimptool-${gimpver} --gimpplugindir`/plug-ins
+    mkdir -p %{buildroot}${gimpplugindir}
+    touch %{buildroot}${gimpplugindir}/xsane
+done
+
 %clean
 rm -rf %{buildroot}
 
@@ -77,23 +86,34 @@
 %{_datadir}/sane/*
 %{_datadir}/locale/*/LC_MESSAGES/xsane.mo
 %{_mandir}/man1/*.1*
-
-# %{_libdir}/gimp/*/plug-ins/xsane
+%ghost %{_libdir}/gimp/*/plug-ins/xsane
 
 %post
 # currently xsane does not support gimp-1.3
 for gimpver in 1.2; do
     gimpplugindir=`gimptool-${gimpver} --gimpplugindir`/plug-ins
-    mkdir -p ${gimpplugindir} > /dev/null
     pushd ${gimpplugindir} > /dev/null
     ln -sf %{_bindir}/xsane . > /dev/null
     popd > /dev/null
 done
 
 %postun
-  rm -f /usr/lib/gimp/1.2/plug-ins/xsane
+if [ "$1" -eq 0 ]; then
+    # currently xsane does not support gimp-1.3
+    for gimpver in 1.2; do
+        gimpplugindir=`gimptool-${gimpver} --gimpplugindir`/plug-ins
+	if [ -L ${gimpplugindir}/xsane ]; then
+	    rm -f ${gimpplugindir}/xsane
+	fi
+    done
+fi
 
 %changelog
+* Thu Jul 10 2003 KOMATSU Shinichiro <koma2@xxxxxxxxxxxxxxxxx>
+- (0.91-3m)
+- re-add gimp plug-ins to %%files (this time, as %%ghost)
+- modify %%postun section (do not run at upgrading time)
+
 * Wed Jul  9 2003 Kimitake Shibata <cipher@xxxxxxxxxxxxxxxx>
 - (0.91-2m)
 - gimp plug-ins is changed into the post.