[Momonga-devel.ja:00337] myomokon.sh


ほそのひでともです。

自分がインストールしているパッケージだけを
OmoiKondaraするスクリプト
myomokon.shを作成してみました(添付)。

私の場合、日常作業環境をMomonga HEADの環境にしており、
絶対に使うとは思えないのでインストールしていないパッケージ、
というものが当然あります。

で、今まではターミナル上で
  for i in $(rpm -qa --qf '%{NAME}\n'); do test -d ${i} && echo ${i}; done  
した結果をOmoiKondaraに引数として与えていたわけですが、
遂にこのコマンドラインがそらんじて打てるようになってしまい、
シェルスクリプトにしないのはマズいだろう、ということで、
2、3日ちまちまと作ってみました。一応手元ではまともに使えています。

myomokon.shはOmoiKondaraスクリプトと同じ場所に配置する必要があります。
で、配置したら

  $ cd あなたのCVSROOT/tools
  $ make myomokon
  $ cd ../pkgs
  $ ../tools/myomokon

でビルドを開始します。

一応オプションもありまして、
  [-i]: ビルドするパッケージを表示し、問い合わせる。
  [-n]: 実際にはビルドしない。
  [-o OmoiKondaraへのオプション]: OmoiKondaraへのオプションを記述。
  [-q]: 黙ってビルドします。-iオプションも無視します(!)。
てな感じでしょうか(あ、usage()表示できるようにするの忘れた)。

使ってくださる方がいそうなら、
${CVSROOT}/tools以下に含めてしまおうか、と思っています。

--
ほそのひでとも
#!/bin/sh
### $Id$

interactive=no
quiet=no
noexec=no
verbose=no
omoikondara="../tools/OmoiKondara"
omoikondaraopts="-v -r -ba -S"
LANG=C && export LANG
LC_ALL=C && export LC_ALL

while getopts "ino:q" option
do
	case ${option} in 
	i)
  		interactive=yes
  		;;
	n)
		noexec=yes
		;;
	o)
		omoikondaraopts=${OPTARG}
		;;
	q)
		quiet=yes
		;;
  	esac
done
shift $((${OPTIND} - 1))
  
rpmpackages=`rpm -qa --qf '%{NAME}\n'`
buildtargets=`for i in ${rpmpackages}; do test -d ${i} && echo ${i}; done`
targetcount=`echo ${buildtargets} | wc -l | awk '{print $1}'`

if [ ${targetcount} == "0" ]; then
	if [ x${quiet} != "xyes" ]; then
		echo "No Package is found in this directory, exiting now..."
	fi
	exit 1
fi

if [ x${quiet} != "xyes" ]; then
	if [ ${targetcount} == "1" ]; then
		echo "following package will be built:"
	else
		echo "following package(s) will be built:"
	fi
	for i in "${buildtargets}"; do
		echo -n ${i}
	done; echo ""
fi

if [ x${quiet} != "xyes" -a x${interactive} == "xyes" ]; then
	read -p 'Proceed[y/N]?: ' continuep
	if [ x${continuep} != "xY" -a x${continuep} != "xy" ]; then
		echo "Done nothing."
		exit 1
	fi
	echo "Okey, now we start to build all you need..."
fi

if [ x${noexec} != "xyes" ]; then
	${omoikondara} ${omoikondaraopts} ${buildtargets}
else
	true
fi

status=${?}

if [ x${quiet} != "xyes" ]; then
	if [ ${status} != 0 ]; then
		echo 'Sorry, it seems to be failure.'
		echo 'Please check */OmoiKondara.log.'
	else
		echo 'Building done.'
	fi
fi

exit ${status}