[cmake-developers] [CPackDeb][libarchive] removing use of fakeroot and supporting UID/GID/UNAME etc in libarchive

Raffi Enficiaud raffi.enficiaud at mines-paris.org
Mon Sep 14 08:53:41 EDT 2015


Le 14/09/15 11:51, Raffi Enficiaud a écrit :
> Hi Brad and Domen and others,
>
> I just realized that the permissions for the extra control files should
> be set in a different way than for the md5sum checksum file.
>
> Please find attached the patch correcting this and the corresponding
> test that fires the problem.
>
> Best,
> Raffi
>
>
It's better with the attachment, sorry.

Raffi

-------------- next part --------------
>From 45fa572012ae2140a8b81d56c8d4b0b10e30c19f Mon Sep 17 00:00:00 2001
From: Raffi Enficiaud <raffi.enficiaud at mines-paris.org>
Date: Mon, 14 Sep 2015 11:42:33 +0200
Subject: [PATCH] cpackdeb: reset extra file permissions to their original

Adding a note about the file permissions on the extra files.
---
 Modules/CPackDeb.cmake                  |  7 ++++++-
 Source/CPack/cmCPackDebGenerator.cxx    |  4 +++-
 Tests/CPackComponentsDEB/CMakeLists.txt | 14 ++++++++++++++
 3 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/Modules/CPackDeb.cmake b/Modules/CPackDeb.cmake
index 970a7d0..0ccfee4 100644
--- a/Modules/CPackDeb.cmake
+++ b/Modules/CPackDeb.cmake
@@ -326,7 +326,12 @@
 #
 #   set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
 #       "${CMAKE_CURRENT_SOURCE_DIR/prerm;${CMAKE_CURRENT_SOURCE_DIR}/postrm")
-
+#
+#  .. note::
+#
+#    The original permissions of the files will be used in the final
+#    package. In particular, the scripts should have the proper executable
+#    flag prior to the generation of the package.
 
 #=============================================================================
 # Copyright 2007-2009 Kitware, Inc.
diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx
index dc9fca3..981d86d 100644
--- a/Source/CPack/cmCPackDebGenerator.cxx
+++ b/Source/CPack/cmCPackDebGenerator.cxx
@@ -576,7 +576,7 @@ int cmCPackDebGenerator::createDeb()
     control_tar.SetUNAME("root");
     control_tar.SetGNAME("root");
 
-    // set md5sum file permissins to RW-R--R-- so that deb lintian
+    // set md5sum file permissions to RW-R--R-- so that deb lintian
     // doesn't warn about it
     control_tar.SetPermissions(S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
 
@@ -597,6 +597,8 @@ int cmCPackDebGenerator::createDeb()
       this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA");
     if( controlExtra )
       {
+      // permissions are now controlled by the original file permissions
+      control_tar.SetPermissions(-1);
       std::vector<std::string> controlExtraList;
       cmSystemTools::ExpandListArgument(controlExtra, controlExtraList);
       for(std::vector<std::string>::iterator i = controlExtraList.begin();
diff --git a/Tests/CPackComponentsDEB/CMakeLists.txt b/Tests/CPackComponentsDEB/CMakeLists.txt
index 5c4eeab..c25e33a 100644
--- a/Tests/CPackComponentsDEB/CMakeLists.txt
+++ b/Tests/CPackComponentsDEB/CMakeLists.txt
@@ -80,6 +80,20 @@ set(CPACK_COMPONENT_HEADERS_DESCRIPTION
 # depend on the libraries component.
 set(CPACK_COMPONENT_HEADERS_DEPENDS libraries)
 
+# creates preinst/prerm scripts with specific permissions. Those permissions
+# (especially executable) should be in the final archive
+find_program(CHMOD_PROG chmod)
+if(CHMOD_PROG)
+  file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/preinst "echo default_preinst")
+  file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/prerm "echo default_prerm")
+  execute_process(COMMAND ${CHMOD_PROG} a+x ${CMAKE_CURRENT_BINARY_DIR}/preinst)
+  execute_process(COMMAND ${CHMOD_PROG} a+x ${CMAKE_CURRENT_BINARY_DIR}/prerm)
+
+  set(CPACK_DEBIAN_APPLICATIONS_PACKAGE_CONTROL_EXTRA
+      "${CMAKE_CURRENT_BINARY_DIR}/preinst;${CMAKE_CURRENT_BINARY_DIR}/prerm")
+endif()
+
+
 # We may use the CPack specific config file in order
 # to tailor CPack behavior on a CPack generator specific way
 # (Behavior would be different for RPM or TGZ or DEB ...)
-- 
1.9.1



More information about the cmake-developers mailing list