我已经创建了一个 .deb 文件,安装后运行良好。但是当我要重新安装相同的 deb 文件时,以前的版本会被卸载,然后安装新的 deb 文件(使用 dpkg -i deb 文件)。如果以前的版本已经安装,我该如何限制安装?我有一个 deb 文件规范的 spec 文件。我正在使用 rpm build 创建一个 deb 文件。
脚本规范
%define name StudentData
%define release 2.4
%define version Linux
Summary: StudentData
License: MCS
Name: %{name}
Version: %{version}
Release: %{release}
Source0: StudentData.tar.gz
Group: Applications/System
Requires: jdk >= 8
BuildRoot: %{$RPM_BUILD_ROOT}/%{name}-%{version}
%description
StudentData
%prep
%setup -n StudentData
%build
%install
rm -rf $RPM_BUILD_ROOT
mkdir -p "$RPM_BUILD_ROOT/usr/local/StudentData/"
install -m 755 %{SOURCE0} $RPM_BUILD_ROOT/usr/local/StudentData/
cp -R * "$RPM_BUILD_ROOT/usr/local/StudentData/"
mkdir -p "$RPM_BUILD_ROOT/usr/local/bin/"
ln -sf /usr/local/StudentData/StudentData $RPM_BUILD_ROOT/usr/local/bin/
ln -sf /usr/local/StudentData/TMCAutoUpdate $RPM_BUILD_ROOT/usr/local/bin/
%post
chmod 777 -R /usr/local/StudentData/
ln -s /usr/local/StudentData/StudentDataConfiguration.desktop ~/Desktop/StudentDataConfiguration.desktop
echo 'StudentData installed on "/usr/local/StudentData"' > /dev/stderr
%preun
rm -rf ~/Desktop/StudentDataConfiguration.desktop
%files
%defattr(-,root,root,-)
/usr/local/StudentData/
/usr/local/bin/
%exclude /usr/local/StudentData/*.tar.gz
%doc
构建 deb 文件的命令
rpmbuild -ba <path to spec file>
alien --scripts -v /root/rpmbuild/RPMS/x86_64/<name>.rpm