0

I just want to copy directory (which contains some files) on destination machine during .deb installation at path /opt/myProjectName in Ubuntu 14.04, 64 bit.

I am successfully able to install files on destination machine during .deb installation using CMakeLists.txt file as per below.

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

How can I copy a directory (which contains some files) on destination machine at path /opt/myProjectName.

  • I have created a file in debian directory named "mypackagename.install" and write test opt/myProjectName into it. Here "test" is the directory which I want to install with deb installation at destination machine at /opt/myProjectName path and it fixed my issue. – User2546 Jul 3 '15 at 11:51
1

CMake 2.8 in Ubuntu 14.04 supports DIRECTORY signature in the install command, so you could simply write install(DIRECTORY test/ DESTINATION /opt/myProjectName/test).

CMake also has standalone Debian package generator (CPackDeb). It's very handy way to create deb packages to distribute (you don't even have a Debian host to build), but they don't at all conform to the Debian policy for packaging for the official distribution.

With the following 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 you@your.domain")
include(CPack)

You can generate myProjectName-0.1.1-Linux.deb like this.

$ 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 <you@your.domain>
 Description: myProjectName built using CMake

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.