2
您好,我在構建rpm包時遇到代碼重複問題。RPM規格。如何避免重複
我有這樣一個規範:
Summary : ${product.id} ${rpmType}
Name : ${product.id}_${rpmType}
.....
%build
%install
%files
%defattr(-,root,java,750)
%{home}
%clean
rm -rf %{buildroot}
%pre
CHECK_PAUSE=2;
echo -n "Stopping tomcat";
sh %{binary}/shutdown.sh
rc=0
while [ "$rc" == 0 ]; do
sleep $CHECK_PAUSE;
wget -q -O /dev/null -S http://localhost:8080/some-server/test;
rc=$?;
done;
echo "Tomcat: STOPPED"
mv %{home}/%{warname} %{home}/%{warname}.`date +%Y%d%m`
rm -rf %{home}/some-server
echo done.
%post
CHECK_PAUSE=2;
echo -n "Starting tomcat";
sh %{binary}/startup.sh
rc=1
while [ "$rc" -ne 0 ]; do
sleep $CHECK_PAUSE
wget -q -O /dev/null -S http://localhost:8080/some-server/test
rc=$?
done
echo "Tomcat: STARTED"
%preun
if [ "$1" == "0" ]; then
#STOP TOMCAT HERE SAME WAY AS IN PRE
fi
%postun
if [ "$1" == "0" ]; then
#START TOMCAT HERE SAME WAY AS IN POST
fi
這要在preun和postun部分要執行的腳本是一樣的前後段。但我不想複製/粘貼它們。有沒有一些複雜的解決方案來避免代碼重複?