This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  0cb936d7f3c97311dc1516c2eeb310d42aa3539b (commit)
       via  ec1e2920551647fd08407b26ef9fc5561061e238 (commit)
      from  35ee6832faf64aaadd78d4b7af47b5d949683a17 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0cb936d7f3c97311dc1516c2eeb310d42aa3539b
commit 0cb936d7f3c97311dc1516c2eeb310d42aa3539b
Merge: 35ee683 ec1e292
Author:     Domen Vrankar <domen.vran...@gmail.com>
AuthorDate: Wed Sep 16 11:47:15 2015 -0400
Commit:     CMake Topic Stage <kwro...@kitware.com>
CommitDate: Wed Sep 16 11:47:15 2015 -0400

    Merge topic 'cpack-deb-fakeroot-removal' into next
    
    ec1e2920 fixup! cmArchiveWrite: control user/group, permissions


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ec1e2920551647fd08407b26ef9fc5561061e238
commit ec1e2920551647fd08407b26ef9fc5561061e238
Author:     Domen Vrankar <domen.vran...@gmail.com>
AuthorDate: Wed Sep 16 07:57:36 2015 +0200
Commit:     Domen Vrankar <domen.vran...@gmail.com>
CommitDate: Wed Sep 16 07:57:36 2015 +0200

    fixup! cmArchiveWrite: control user/group, permissions
    
    Fix for variable naming convention and conversion between signed and 
unsigned values

diff --git a/Source/CPack/cmCPackDebGenerator.cxx 
b/Source/CPack/cmCPackDebGenerator.cxx
index 55eeec5..9402689 100644
--- a/Source/CPack/cmCPackDebGenerator.cxx
+++ b/Source/CPack/cmCPackDebGenerator.cxx
@@ -453,10 +453,8 @@ int cmCPackDebGenerator::createDeb()
 
     // uid/gid should be the one of the root user, and this root user has
     // always uid/gid equal to 0.
-    data_tar.SetUID(0);
-    data_tar.SetGID(0);
-    data_tar.SetUNAME("root");
-    data_tar.SetGNAME("root");
+    data_tar.SetUIDAndGID(0u, 0u);
+    data_tar.SetUNAMEAndGNAME("root", "root");
 
     // now add all directories which have to be compressed
     // collect all top level install dirs for that
@@ -571,10 +569,8 @@ int cmCPackDebGenerator::createDeb()
                                "paxr");
 
     // sets permissions and uid/gid for the files
-    control_tar.SetUID(0);
-    control_tar.SetGID(0);
-    control_tar.SetUNAME("root");
-    control_tar.SetGNAME("root");
+    control_tar.SetUIDAndGID(0u, 0u);
+    control_tar.SetUNAMEAndGNAME("root", "root");
 
     /* permissions are set according to
     https://www.debian.org/doc/debian-policy/ch-files.html#s-permissions-owners
@@ -623,7 +619,7 @@ int cmCPackDebGenerator::createDeb()
         strictFiles + sizeof(strictFiles)/sizeof(strictFiles[0]));
 
       // default
-      control_tar.SetPermissions(-1);
+      control_tar.ClearPermissions();
 
       std::vector<std::string> controlExtraList;
       cmSystemTools::ExpandListArgument(controlExtra, controlExtraList);
diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx
index f6a1b4f..7946950 100644
--- a/Source/cmArchiveWrite.cxx
+++ b/Source/cmArchiveWrite.cxx
@@ -84,11 +84,7 @@ cmArchiveWrite::cmArchiveWrite(
     Archive(archive_write_new()),
     Disk(archive_read_disk_new()),
     Verbose(false),
-    Format(format),
-    uid(-1),
-    gid(-1),
-    permissions(-1),
-    permissionsMask(-1)
+    Format(format)
 {
   switch (c)
     {
@@ -288,29 +284,29 @@ bool cmArchiveWrite::AddFile(const char* file,
     }
 
   // manages the uid/guid of the entry (if any)
-  if (this->uid > -1 && this->gid > -1)
+  if (this->Uid.IsSet() && this->Gid.IsSet())
     {
-    archive_entry_set_uid(e, this->uid);
-    archive_entry_set_gid(e, this->gid);
+    archive_entry_set_uid(e, this->Uid.Get());
+    archive_entry_set_gid(e, this->Gid.Get());
     }
 
-  if (this->uname.size() && this->gname.size())
+  if (this->Uname.size() && this->Gname.size())
     {
-    archive_entry_set_uname(e, this->uname.c_str());
-    archive_entry_set_gname(e, this->gname.c_str());
+    archive_entry_set_uname(e, this->Uname.c_str());
+    archive_entry_set_gname(e, this->Gname.c_str());
     }
 
 
   // manages the permissions
-  if (this->permissions > -1)
+  if (this->Permissions.IsSet())
     {
-    archive_entry_set_perm(e, this->permissions);
+    archive_entry_set_perm(e, this->Permissions.Get());
     }
 
-  if (this->permissionsMask > -1)
+  if (this->PermissionsMask.IsSet())
     {
     mode_t perm = archive_entry_perm(e);
-    archive_entry_set_perm(e, perm & this->permissionsMask );
+    archive_entry_set_perm(e, perm & this->PermissionsMask.Get());
     }
 
   // Clear acl and xattr fields not useful for distribution.
diff --git a/Source/cmArchiveWrite.h b/Source/cmArchiveWrite.h
index a42211c..8dbbb83 100644
--- a/Source/cmArchiveWrite.h
+++ b/Source/cmArchiveWrite.h
@@ -18,6 +18,22 @@
 # error "cmArchiveWrite not allowed during bootstrap build!"
 #endif
 
+template<typename T>
+class cmArchiveWriteOptional
+{
+public:
+  cmArchiveWriteOptional() {this->Clear();}
+  explicit cmArchiveWriteOptional(T val) {this->Set(val);}
+
+  void Set(T val) {this->IsValueSet = true; this->Value=val;}
+  void Clear() {this->IsValueSet = false;}
+  bool IsSet() const {return this->IsValueSet;}
+  T Get() const {return Value;}
+private:
+  T Value;
+  bool IsValueSet;
+};
+
 /** \class cmArchiveWrite
  * \brief Wrapper around libarchive for writing.
  *
@@ -74,51 +90,57 @@ public:
   void SetMTime(std::string const& t) { this->MTime = t; }
 
   //! Sets the permissions of the added files/folders
-  //! @note set to -1 to use the default permissions
-  long int SetPermissions(long int permissions_)
+  void SetPermissions(mode_t permissions_)
     {
-    std::swap(this->permissions, permissions_);
-    return permissions_;
+    this->Permissions.Set(permissions_);
     }
 
+  //! Clears permissions - default is used instead
+  void ClearPermissions() { this->Permissions.Clear(); }
+
   //! Sets the permissions mask of files/folders
   //!
   //! The permissions will be copied from the existing file
   //! or folder. The mask will then be applied to unset
   //! some of them
-  long int SetPermissionsMask(long int permissionsMask_)
+  void SetPermissionsMask(mode_t permissionsMask_)
+    {
+    this->PermissionsMask.Set(permissionsMask_);
+    }
+
+  //! Clears permissions mask - default is used instead
+  void ClearPermissionsMask()
     {
-    std::swap(this->permissionsMask, permissionsMask_);
-    return permissionsMask_;
+    this->PermissionsMask.Clear();
     }
 
-  //! Sets the UID to be used in the tar file
-  //! @return the previous UID
-  //! @note set to -1 to disable the UID overriding
-  long int SetUID( long int uid_ )
+  //! Sets UID and GID to be used in the tar file
+  void SetUIDAndGID(int uid_, int gid_)
     {
-    std::swap(this->uid, uid_);
-    return uid_;
+    this->Uid.Set(uid_);
+    this->Gid.Set(gid_);
     }
 
-  std::string SetUNAME(std::string uname_)
+  //! Clears UID and GID to be used in the tar file - default is used instead
+  void ClearUIDAndGID()
     {
-    std::swap(this->uname, uname_);
-    return uname_;
+    this->Uid.Clear();
+    this->Gid.Clear();
     }
 
-  //! Sets the UID to be used in the tar file
-  //! @return the previous UID
-  long int SetGID( long int gid_ )
+  //! Sets UNAME and GNAME to be used in the tar file
+  void SetUNAMEAndGNAME(const std::string& uname_, const std::string& gname_)
     {
-    std::swap(this->gid, gid_);
-    return gid_;
+    this->Uname = uname_;
+    this->Gname = gname_;
     }
 
-  std::string SetGNAME(std::string gname_)
+  //! Clears UNAME and GNAME to be used in the tar file
+  //! default is used instead
+  void ClearUNAMEAndGNAME()
     {
-    std::swap(this->gname, gname_);
-    return gname_;
+    this->Uname = "";
+    this->Gname = "";
     }
 
 private:
@@ -141,22 +163,21 @@ private:
   std::string Error;
   std::string MTime;
 
-  //! UID of the user in the tar file. Set to -1
-  //! to disable overriding
-  long int uid;
+  //! UID of the user in the tar file
+  cmArchiveWriteOptional<int> Uid;
 
   //! GUID of the user in the tar file
-  long int gid;
+  cmArchiveWriteOptional<int> Gid;
 
   //! UNAME/GNAME of the user (does not override UID/GID)
   //!@{
-  std::string uname;
-  std::string gname;
+  std::string Uname;
+  std::string Gname;
   //!@}
 
   //! Permissions on files/folders
-  long int permissions;
-  long int permissionsMask;
+  cmArchiveWriteOptional<mode_t> Permissions;
+  cmArchiveWriteOptional<mode_t> PermissionsMask;
 };
 
 #endif

-----------------------------------------------------------------------

Summary of changes:
 Source/CPack/cmCPackDebGenerator.cxx |   14 ++----
 Source/cmArchiveWrite.cxx            |   26 +++++------
 Source/cmArchiveWrite.h              |   85 +++++++++++++++++++++-------------
 3 files changed, 69 insertions(+), 56 deletions(-)


hooks/post-receive
-- 
CMake
_______________________________________________
Cmake-commits mailing list
Cmake-commits@cmake.org
http://public.kitware.com/mailman/listinfo/cmake-commits

Reply via email to