0

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

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

%post 部分中也没有解析 $HOME 变量。如何写入对应的文件?

我也对改进的想法持开放态度。这是我的第一个 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
4

1 回答 1

2
  1. 不,您不能rpm从 RPM 中调用。
  2. 如果您需要 OpenSSL,则将 RPM 标记为需要它 - 我知道我肯定不希望在我的机器上安装您的版本;我要卖家的。
  3. %install检查 OpenSSL 版本的所有工作都在构建机器上完成,而不是在您的目标机器上完成。
  4. 不要把东西放在人的.bashrc/etc/profile- 这就是/etc/profile.d/和其他人的目的;您将文件放在那里,然后在卸载时将其删除。
于 2013-08-28T09:15:42.137 回答