summaryrefslogtreecommitdiffstats
path: root/Source/CPack/cmCPackDebGenerator.cxx
diff options
context:
space:
mode:
authorNils Gladitz <nilsgladitz@gmail.com>2017-06-17 16:49:33 (GMT)
committerNils Gladitz <nilsgladitz@gmail.com>2017-06-28 17:55:12 (GMT)
commit5299141320c7be96e9357ebd457c9a279308248a (patch)
tree9c487cff7beef693f711f6bd92ea96f3b9d918c2 /Source/CPack/cmCPackDebGenerator.cxx
parent1363a0cbcef00cb9a49eba3b68283b5b6d1b95a5 (diff)
downloadCMake-5299141320c7be96e9357ebd457c9a279308248a.zip
CMake-5299141320c7be96e9357ebd457c9a279308248a.tar.gz
CMake-5299141320c7be96e9357ebd457c9a279308248a.tar.bz2
CPackDeb: Enable the DEB generator on Windows
While some features require external Unix tools the generator is mostly portable. By enabling it on Windows it can be used for cross platform packaging.
Diffstat (limited to 'Source/CPack/cmCPackDebGenerator.cxx')
-rw-r--r--Source/CPack/cmCPackDebGenerator.cxx28
1 files changed, 23 insertions, 5 deletions
diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx
index af54fce..00d017e 100644
--- a/Source/CPack/cmCPackDebGenerator.cxx
+++ b/Source/CPack/cmCPackDebGenerator.cxx
@@ -479,6 +479,25 @@ int cmCPackDebGenerator::createDeb()
cmCPackLogger(cmCPackLog::LOG_DEBUG, "RELATIVEDIR: \""
<< relativeDir << "\"" << std::endl);
+#ifdef WIN32
+ std::string mode_t_adt_filename = *fileIt + ":cmake_mode_t";
+ cmsys::ifstream permissionStream(mode_t_adt_filename.c_str());
+
+ mode_t permissions = 0;
+
+ if (permissionStream) {
+ permissionStream >> std::oct >> permissions;
+ }
+
+ if (permissions != 0) {
+ data_tar.SetPermissions(permissions);
+ } else if (cmSystemTools::FileIsDirectory(*fileIt)) {
+ data_tar.SetPermissions(0755);
+ } else {
+ data_tar.ClearPermissions();
+ }
+#endif
+
// do not recurse because the loop will do it
if (!data_tar.Add(*fileIt, topLevelLength, ".", false)) {
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem adding file to tar:"
@@ -553,8 +572,8 @@ int cmCPackDebGenerator::createDeb()
and
https://lintian.debian.org/tags/control-file-has-bad-permissions.html
*/
- const mode_t permission644 = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
- const mode_t permissionExecute = S_IXUSR | S_IXGRP | S_IXOTH;
+ const mode_t permission644 = 0644;
+ const mode_t permissionExecute = 0111;
const mode_t permission755 = permission644 | permissionExecute;
// for md5sum and control (that we have generated here), we use 644
@@ -831,7 +850,7 @@ static int copy_ar(CF* cfp, off_t size)
? static_cast<size_t>(sz)
: sizeof(buf),
from)) > 0) {
- sz -= nr;
+ sz -= static_cast<off_t>(nr);
for (size_t off = 0; off < nr; nr -= off, off += nw) {
if ((nw = fwrite(buf + off, 1, nr, to)) < nr) {
return -1;
@@ -854,7 +873,6 @@ static int copy_ar(CF* cfp, off_t size)
static int put_arobj(CF* cfp, struct stat* sb)
{
int result = 0;
- struct ar_hdr* hdr;
/* If passed an sb structure, reading a file from disk. Get stat(2)
* information, build a name and construct a header. (Files are named
@@ -873,7 +891,7 @@ static int put_arobj(CF* cfp, struct stat* sb)
if (gid > USHRT_MAX) {
gid = USHRT_MAX;
}
- if (lname > sizeof(hdr->ar_name) || strchr(name, ' ')) {
+ if (lname > sizeof(ar_hdr().ar_name) || strchr(name, ' ')) {
(void)sprintf(ar_hb, HDR1, AR_EFMT1, (int)lname, (long int)sb->st_mtime,
(unsigned)uid, (unsigned)gid, (unsigned)sb->st_mode,
(long long)sb->st_size + lname, ARFMAG);