在 Ubuntu 14.04(64 位)中安装 .deb 期间复制目标计算机上的目录

在 Ubuntu 14.04(64 位)中安装 .deb 期间复制目标计算机上的目录

我只想在 .deb 安装期间/opt/myProjectName在 Ubuntu 14.04(64 位)的路径中复制目标计算机上的目录(其中包含一些文件)。

.deb我在安装过程中使用文件成功地在目标计算机上安装文件CMakeLists.txt,如下所示。

INSTALL(FILES myShFile.sh   DESTINATION /opt/myProjectName)

如何在目标计算机上的 path 处复制目录(其中包含一些文件)/opt/myProjectName

答案1

Ubuntu 14.04 中的 CMake 2.8 支持DIRECTORY签名安装命令,所以你可以简单地写install(DIRECTORY test/ DESTINATION /opt/myProjectName/test)

CMake 还具有独立的 Debian 包生成器(CPackDeb)。这是创建要分发的 deb 软件包的非常方便的方法(您甚至没有要构建的 Debian 主机),但它们根本不符合 Debian 官方发行版打包政策。

具有以下内容CMakeLists.txt

cmake_minimum_required(VERSION 2.8)
project(myProjectName)
install(FILES myShFile.sh DESTINATION /opt/myProjectName)
install(DIRECTORY test/ DESTINATION /opt/myProjectName/test)

set(CPACK_GENERATOR DEB)
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "you [email protected]")
include(CPack)

你可以myProjectName-0.1.1-Linux.deb像这样生成。

$ touch myShFile.sh
$ mkdir test
$ touch test/myTest
$ cmake .
-- The C compiler identification is GNU 4.8.2
-- The CXX compiler identification is GNU 4.8.2
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/yaegashi/cmake

$ make package
Run CPack packaging tool...
CPack: Create package using DEB
CPack: Install projects
CPack: - Run preinstall target for: myProjectName
CPack: - Install project: myProjectName
CPack: Create package
CPack: - package: /home/yaegashi/cmake/myProjectName-0.1.1-Linux.deb generated.

$ dpkg --contents myProjectName-0.1.1-Linux.deb 
drwxrwxr-x root/root         0 2015-07-04 03:43 ./opt/
drwxrwxr-x root/root         0 2015-07-04 03:43 ./opt/myProjectName/
-rw-r--r-- root/root         0 2015-07-04 03:36 ./opt/myProjectName/myShFile.sh
drwxr-xr-x root/root         0 2015-07-04 03:43 ./opt/myProjectName/test/
-rw-r--r-- root/root         0 2015-07-04 03:36 ./opt/myProjectName/test/myTest

$ dpkg --info myProjectName-0.1.1-Linux.deb 
 new debian package, version 2.0.
 size 728 bytes: control archive=328 bytes.
     190 bytes,     9 lines      control              
     128 bytes,     2 lines      md5sums              
 Package: myprojectname
 Version: 0.1.1
 Section: devel
 Priority: optional
 Architecture: amd64
 Installed-Size: 0
 Maintainer: you <[email protected]>
 Description: myProjectName built using CMake

相关内容