rpm构建帮助SPEC.file

时间:2013-08-27 11:29:12

标签: java rpm rpmbuild specifications

我有一个建立rpm包的问题。我将bild一个rpm包,它应该复制计算机上的一些文件。如果Pc上没有openssl,我也会安装它。最后我想启动一些java程序来验证成功安装。

为什么不能从%post部分调用java类datei。我做错了什么?甚至可以从rpm内部调用一个吗?

$ home变量未在%post部分中解析。如何写入相应的文件?

我也对改进的想法持开放态度。这是我的第一个rpm包。

非常感谢您的帮助

这是相应的SPEC文件。

### PI JDBC Driver Spec-File

Summary: Installs the PIJDBC Driver

Name: pijdbcdriver_installer
Version: 1.0
Release: 1
License: Probably not
Source: PI-JDBC_2012-x86-x64_.tar.gz
Source1: openssl-0.9.8k-3.4_3.8.1.x86_64.delta.rpm
Source2: lib
Source3: openssl-1.0.0k-34.20.1.x86_64.rpm
Source4: test.sh



%description
pijdbcdriver_installer installs

%prep

rm -rf Build/*

%setup -c pijdbcdriver_installer-1.0
cp -p %SOURCE1 .
cp -pr %SOURCE2 .
cp -pr %SOURCE3 .
cp -p %SOURCE4 .

%build


%install

rm -rf $RPM_BUILD_ROOT

mkdir -p $RPM_BUILD_ROOT/opt
mkdir -p $RPM_BUILD_ROOT/etc
mkdir -p $RPM_BUILD_ROOT/usr
mkdir -p $RPM_BUILD_ROOT/tmp
mkdir -p $RPM_BUILD_ROOT/usr/lib

cp -r $RPM_BUILD_DIR/pijdbcdriver_installer-1.0/pipc $RPM_BUILD_ROOT/opt/pipc
cp -r $RPM_BUILD_DIR/pijdbcdriver_installer-1.0/openssl-0.9.8k-3.4_3.8.1.x86_64.delta.rpm $RPM_BUILD_ROOT/tmp/openssl-0.9.8k-3.4_3.8.1.x86_64.delta.rpm
cp -r $RPM_BUILD_DIR/pijdbcdriver_installer-1.0/openssl-1.0.0k-34.20.1.x86_64.rpm $RPM_BUILD_ROOT/tmp/openssl-1.0.0k-34.20.1.x86_64.rpm
cp -pr $RPM_BUILD_DIR/pijdbcdriver_installer-1.0/lib/* $RPM_BUILD_ROOT/usr/lib
cp $RPM_BUILD_DIR/pijdbcdriver_installer-1.0/test.sh $RPM_BUILD_ROOT

versionsnummerVonOpenSSL=`openssl version -v`
openssslVersionIs_1_0=`echo $versionsnummerVonOpenSSL | awk '{print      index($versionsnummerVonOpenSSL, 1.0)}'`
openssslVersionIs_0_9_8=`echo $versionsnummerVonOpenSSL | awk '{print index($versionsnummerVonOpenSSL, 0.9.8)}'`
openssslVersion_Exists=`echo $versionsnummerVonOpenSSL | awk '{print length($versionsnummerVonOpenSSL)}'`


if [ openssslVersionIs_1_0 > 0 ]
then

  rm $RPM_BUILD_ROOT/opt/pipc/jdbc/lib/libRdsaWrapper-1.3.0a.so
  rm $RPM_BUILD_ROOT/opt/pipc/jdbc/lib/libRdsaWrapper64-1.3.0a.so

elif [ openssslVersionIs_0_9_8 > 0 ]
then


  rm $RPM_BUILD_ROOT/opt/jdbc/lib/libRdsaWrapper-1.3.0b.so
  rm $RPM_BUILD_ROOT/opt/pipc/jdbc/lib/libRdsaWrapper64-1.3.0b.so

elif  [ openssslVersion_Exists = 0 ]
then

  sudo rpm -i tmp/openssl-1.0.0k-34.20.1.x86_64.rpm

  rm $RPM_BUILD_ROOT/opt/pipc/jdbc/lib/libRdsaWrapper-1.3.0a.so
  rm $RPM_BUILD_ROOT/opt/pipc/jdbc/lib/libRdsaWrapper64-1.3.0a.so

else


fi


export DISPLAY=:0
cd /opt/pipc/jdbc/Samples/getSnap/bin
java getSnap koernersnb FRADEV-T6-PI1 sin%


%post

rm -r tmp/openssl-0.9.8k-3.4_3.8.1.x86_64.delta.rpm
rm -r tmp/openssl-1.0.0k-34.20.1.x86_64.rpm



sudo sed -i '/PIJDBCDriver/d' /etc/profile
sudo sed -i '/PI_RDSA_LIB/d' /etc/profile


if [ openssslVersionIs_1_0 > 0 ]
then

  echo "export PI_RDSA_LIB=/opt/pipc/jdbc/lib/libRdsaWrapper-1.3.0b.so" >> etc/profile
  echo "export PI_RDSA_LIB64=/opt/pipc/jdbc/lib/libRdsaWrapper64-1.3.0b.so" >> /etc/profile
  echo "export PI_RDSA_LIB=/opt/pipc/jdbc/lib/libRdsaWrapper-1.3.0b.so" >> $HOME/.bashrc
  echo "export PI_RDSA_LIB64=/opt/pipc/jdbc/lib/libRdsaWrapper64-1.3.0b.so" >> $HOME/.bashrc

elif [ openssslVersionIs_0_9_8 > 0 ]
then
  echo "export PI_RDSA_LIB=/opt/pipc/jdbc/lib/libRdsaWrapper-1.3.0a.so" >> /etc/profile
  echo "export PI_RDSA_LIB64=/opt/pipc/jdbc/lib/libRdsaWrapper64-1.3.0a.so" >> /etc/profile
  echo "export PI_RDSA_LIB=/opt/pipc/jdbc/lib/libRdsaWrapper-1.3.0a.so" >> **$HOME**/.bashrc
  echo "export PI_RDSA_LIB64=/opt/pipc/jdbc/lib/libRdsaWrapper64-1.3.0a.so" >> **$HOME**/.bashrc

    else
  echo "export PI_RDSA_LIB=/opt/pipc/jdbc/lib/libRdsaWrapper-1.3.0b.so" >> /etc/profile
  echo "export PI_RDSA_LIB64=/opt/pipc/jdbc/lib/libRdsaWrapper64-1.3.0b.so" >> /etc/profile
  echo "export PI_RDSA_LIB=/opt/pipc/jdbc/lib/libRdsaWrapper-1.3.0b.so" >> $HOME/.bashrc
  echo "export PI_RDSA_LIB64=/opt/pipc/jdbc/lib/libRdsaWrapper64-1.3.0b.so" >>      $HOME/.bashrc

fi

echo "export CLASSPATH=$CLASSPATH:/opt/pipc/jdbc/PIJDBCDriver.jar:." >> /etc/profile



**%files**

/opt/pipc
/tmp/openssl-0.9.8k-3.4_3.8.1.x86_64.delta.rpm
/tmp/openssl-1.0.0k-34.20.1.x86_64.rpm
/usr/lib
/test.sh

1 个答案:

答案 0 :(得分:2)

  1. 不,您无法在RPM内拨打rpm
  2. 如果您需要OpenSSL,则将RPM标记为需要它 - 我知道我确定不希望在我的计算机上安装您的版本;我想要供应商的。
  3. 检查OpenSSL版本的%install中的所有内容都是在构建计算机上完成的,而不是目标计算机。
  4. 不要将内容放在人.bashrc/etc/profile中 - 这就是/etc/profile.d/和其他人的内容;你将文件放在那里,然后在卸载时将其删除。