2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2007-07-25 18:57:33 +04:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2007-07-25 18:57:33 +04:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
2016-04-29 16:40:20 +03:00
|
|
|
|
2007-07-25 18:57:33 +04:00
|
|
|
#include "cmCPackDebGenerator.h"
|
|
|
|
|
2015-09-11 21:58:18 +03:00
|
|
|
#include "cmArchiveWrite.h"
|
2016-09-07 01:21:35 +03:00
|
|
|
#include "cmCPackComponentGroup.h"
|
|
|
|
#include "cmCPackGenerator.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmCPackLog.h"
|
|
|
|
#include "cmGeneratedFileStream.h"
|
|
|
|
#include "cmSystemTools.h"
|
2007-07-25 18:57:33 +04:00
|
|
|
|
|
|
|
#include <cmsys/Glob.hxx>
|
2016-09-07 01:21:35 +03:00
|
|
|
#include <limits.h>
|
|
|
|
#include <map>
|
|
|
|
#include <ostream>
|
|
|
|
#include <set>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2015-04-21 18:19:57 +03:00
|
|
|
#include <sys/stat.h>
|
2016-09-07 01:21:35 +03:00
|
|
|
#include <utility>
|
2008-01-24 15:31:59 +03:00
|
|
|
|
2007-08-14 18:25:23 +04:00
|
|
|
// NOTE:
|
|
|
|
// A debian package .deb is simply an 'ar' archive. The only subtle difference
|
|
|
|
// is that debian uses the BSD ar style archive whereas most Linux distro have
|
|
|
|
// a GNU ar.
|
|
|
|
// See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=161593 for more info
|
|
|
|
// Therefore we provide our own implementation of a BSD-ar:
|
2016-05-16 17:34:04 +03:00
|
|
|
static int ar_append(const char* archive,
|
|
|
|
const std::vector<std::string>& files);
|
2007-08-14 16:40:40 +04:00
|
|
|
|
2007-07-25 18:57:33 +04:00
|
|
|
cmCPackDebGenerator::cmCPackDebGenerator()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
cmCPackDebGenerator::~cmCPackDebGenerator()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-10-31 15:50:17 +03:00
|
|
|
int cmCPackDebGenerator::InitializeInternal()
|
|
|
|
{
|
|
|
|
this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/usr");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::IsOff(this->GetOption("CPACK_SET_DESTDIR"))) {
|
2010-08-23 18:14:40 +04:00
|
|
|
this->SetOption("CPACK_SET_DESTDIR", "I_ON");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-10-31 15:50:17 +03:00
|
|
|
return this->Superclass::InitializeInternal();
|
|
|
|
}
|
|
|
|
|
2016-05-26 22:58:51 +03:00
|
|
|
int cmCPackDebGenerator::PackageOnePack(std::string const& initialTopLevel,
|
|
|
|
std::string const& packageName)
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
2011-03-23 20:28:05 +03:00
|
|
|
int retval = 1;
|
|
|
|
// Begin the archive for this pack
|
|
|
|
std::string localToplevel(initialTopLevel);
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string packageFileName(cmSystemTools::GetParentDirectory(toplevel));
|
2016-06-07 15:39:45 +03:00
|
|
|
std::string outputFileName(
|
|
|
|
std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) + "-" +
|
|
|
|
packageName + this->GetOutputExtension());
|
2016-05-16 17:34:04 +03:00
|
|
|
|
|
|
|
localToplevel += "/" + packageName;
|
2011-03-23 20:28:05 +03:00
|
|
|
/* replace the TEMP DIRECTORY with the component one */
|
2016-05-16 17:34:04 +03:00
|
|
|
this->SetOption("CPACK_TEMPORARY_DIRECTORY", localToplevel.c_str());
|
|
|
|
packageFileName += "/" + outputFileName;
|
2011-03-23 20:28:05 +03:00
|
|
|
/* replace proposed CPACK_OUTPUT_FILE_NAME */
|
2016-05-16 17:34:04 +03:00
|
|
|
this->SetOption("CPACK_OUTPUT_FILE_NAME", outputFileName.c_str());
|
2011-03-23 20:28:05 +03:00
|
|
|
/* replace the TEMPORARY package file name */
|
|
|
|
this->SetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME",
|
2016-05-16 17:34:04 +03:00
|
|
|
packageFileName.c_str());
|
2011-03-23 20:28:05 +03:00
|
|
|
// Tell CPackDeb.cmake the name of the component GROUP.
|
2016-05-16 17:34:04 +03:00
|
|
|
this->SetOption("CPACK_DEB_PACKAGE_COMPONENT", packageName.c_str());
|
2012-10-24 23:37:18 +04:00
|
|
|
// Tell CPackDeb.cmake the path where the component is.
|
|
|
|
std::string component_path = "/";
|
|
|
|
component_path += packageName;
|
|
|
|
this->SetOption("CPACK_DEB_PACKAGE_COMPONENT_PART_PATH",
|
|
|
|
component_path.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->ReadListFile("CPackDeb.cmake")) {
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR, "Error while execution CPackDeb.cmake"
|
|
|
|
<< std::endl);
|
2011-03-23 20:28:05 +03:00
|
|
|
retval = 0;
|
|
|
|
return retval;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-03-23 20:28:05 +03:00
|
|
|
|
|
|
|
cmsys::Glob gl;
|
2015-04-20 21:48:24 +03:00
|
|
|
std::string findExpr(this->GetOption("GEN_WDIR"));
|
2011-03-23 20:28:05 +03:00
|
|
|
findExpr += "/*";
|
|
|
|
gl.RecurseOn();
|
2015-09-29 00:23:05 +03:00
|
|
|
gl.SetRecurseListDirs(true);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!gl.FindFiles(findExpr)) {
|
2011-03-23 20:28:05 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
2016-05-16 17:34:04 +03:00
|
|
|
"Cannot find any files in the installed directory"
|
|
|
|
<< std::endl);
|
2011-03-23 20:28:05 +03:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-03-23 20:28:05 +03:00
|
|
|
packageFiles = gl.GetFiles();
|
|
|
|
|
|
|
|
int res = createDeb();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (res != 1) {
|
2011-03-23 20:28:05 +03:00
|
|
|
retval = 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-03-23 20:28:05 +03:00
|
|
|
// add the generated package to package file names list
|
2016-05-10 15:53:19 +03:00
|
|
|
packageFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
|
|
|
|
packageFileName += "/";
|
|
|
|
packageFileName += this->GetOption("GEN_CPACK_OUTPUT_FILE_NAME");
|
2011-03-23 20:28:05 +03:00
|
|
|
packageFileNames.push_back(packageFileName);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2011-03-11 10:47:15 +03:00
|
|
|
int cmCPackDebGenerator::PackageComponents(bool ignoreGroup)
|
|
|
|
{
|
|
|
|
int retval = 1;
|
|
|
|
/* Reset package file name list it will be populated during the
|
|
|
|
* component packaging run*/
|
|
|
|
packageFileNames.clear();
|
|
|
|
std::string initialTopLevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY"));
|
|
|
|
|
|
|
|
// The default behavior is to have one package by component group
|
|
|
|
// unless CPACK_COMPONENTS_IGNORE_GROUP is specified.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!ignoreGroup) {
|
2011-03-11 10:47:15 +03:00
|
|
|
std::map<std::string, cmCPackComponentGroup>::iterator compGIt;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (compGIt = this->ComponentGroups.begin();
|
|
|
|
compGIt != this->ComponentGroups.end(); ++compGIt) {
|
2011-03-11 10:47:15 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging component group: "
|
2016-05-16 17:34:04 +03:00
|
|
|
<< compGIt->first << std::endl);
|
2011-03-11 10:47:15 +03:00
|
|
|
// Begin the archive for this group
|
2016-05-16 17:34:04 +03:00
|
|
|
retval &= PackageOnePack(initialTopLevel, compGIt->first);
|
|
|
|
}
|
2011-03-23 20:28:05 +03:00
|
|
|
// Handle Orphan components (components not belonging to any groups)
|
|
|
|
std::map<std::string, cmCPackComponent>::iterator compIt;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (compIt = this->Components.begin(); compIt != this->Components.end();
|
|
|
|
++compIt) {
|
2011-03-23 20:28:05 +03:00
|
|
|
// Does the component belong to a group?
|
2016-06-27 23:44:16 +03:00
|
|
|
if (compIt->second.Group == CM_NULLPTR) {
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCPackLogger(
|
|
|
|
cmCPackLog::LOG_VERBOSE, "Component <"
|
2011-03-23 20:28:05 +03:00
|
|
|
<< compIt->second.Name
|
|
|
|
<< "> does not belong to any group, package it separately."
|
|
|
|
<< std::endl);
|
|
|
|
// Begin the archive for this orphan component
|
2016-05-16 17:34:04 +03:00
|
|
|
retval &= PackageOnePack(initialTopLevel, compIt->first);
|
2011-03-11 10:47:15 +03:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-03-11 10:47:15 +03:00
|
|
|
// CPACK_COMPONENTS_IGNORE_GROUPS is set
|
|
|
|
// We build 1 package per component
|
2016-05-16 17:34:04 +03:00
|
|
|
else {
|
2011-03-11 10:47:15 +03:00
|
|
|
std::map<std::string, cmCPackComponent>::iterator compIt;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (compIt = this->Components.begin(); compIt != this->Components.end();
|
|
|
|
++compIt) {
|
|
|
|
retval &= PackageOnePack(initialTopLevel, compIt->first);
|
2011-03-11 10:47:15 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-03-11 10:47:15 +03:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2016-05-10 19:31:05 +03:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
int cmCPackDebGenerator::PackageComponentsAllInOne(
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& compInstDirName)
|
2011-03-11 10:47:15 +03:00
|
|
|
{
|
|
|
|
int retval = 1;
|
|
|
|
/* Reset package file name list it will be populated during the
|
|
|
|
* component packaging run*/
|
|
|
|
packageFileNames.clear();
|
|
|
|
std::string initialTopLevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY"));
|
|
|
|
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
|
|
|
|
"Packaging all groups in one package..."
|
|
|
|
"(CPACK_COMPONENTS_ALL_[GROUPS_]IN_ONE_PACKAGE is set)"
|
2016-05-16 17:34:04 +03:00
|
|
|
<< std::endl);
|
2011-03-11 10:47:15 +03:00
|
|
|
|
|
|
|
// The ALL GROUPS in ONE package case
|
|
|
|
std::string localToplevel(initialTopLevel);
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string packageFileName(cmSystemTools::GetParentDirectory(toplevel));
|
2016-06-07 15:39:45 +03:00
|
|
|
std::string outputFileName(
|
|
|
|
std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) +
|
|
|
|
this->GetOutputExtension());
|
2011-03-11 10:47:15 +03:00
|
|
|
// all GROUP in one vs all COMPONENT in one
|
2016-05-16 17:34:04 +03:00
|
|
|
localToplevel += "/" + compInstDirName;
|
2011-03-11 10:47:15 +03:00
|
|
|
|
|
|
|
/* replace the TEMP DIRECTORY with the component one */
|
2016-05-16 17:34:04 +03:00
|
|
|
this->SetOption("CPACK_TEMPORARY_DIRECTORY", localToplevel.c_str());
|
|
|
|
packageFileName += "/" + outputFileName;
|
2011-03-11 10:47:15 +03:00
|
|
|
/* replace proposed CPACK_OUTPUT_FILE_NAME */
|
2016-05-16 17:34:04 +03:00
|
|
|
this->SetOption("CPACK_OUTPUT_FILE_NAME", outputFileName.c_str());
|
2011-03-11 10:47:15 +03:00
|
|
|
/* replace the TEMPORARY package file name */
|
|
|
|
this->SetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME",
|
2016-05-16 17:34:04 +03:00
|
|
|
packageFileName.c_str());
|
2016-05-10 19:31:05 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!compInstDirName.empty()) {
|
2016-05-10 19:31:05 +03:00
|
|
|
// Tell CPackDeb.cmake the path where the component is.
|
|
|
|
std::string component_path = "/";
|
|
|
|
component_path += compInstDirName;
|
|
|
|
this->SetOption("CPACK_DEB_PACKAGE_COMPONENT_PART_PATH",
|
|
|
|
component_path.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!this->ReadListFile("CPackDeb.cmake")) {
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR, "Error while execution CPackDeb.cmake"
|
|
|
|
<< std::endl);
|
2011-03-11 10:47:15 +03:00
|
|
|
retval = 0;
|
2011-03-19 13:12:31 +03:00
|
|
|
return retval;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-03-11 10:47:15 +03:00
|
|
|
|
|
|
|
cmsys::Glob gl;
|
2015-04-20 21:48:24 +03:00
|
|
|
std::string findExpr(this->GetOption("GEN_WDIR"));
|
2011-03-11 10:47:15 +03:00
|
|
|
findExpr += "/*";
|
|
|
|
gl.RecurseOn();
|
2015-09-29 00:23:05 +03:00
|
|
|
gl.SetRecurseListDirs(true);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!gl.FindFiles(findExpr)) {
|
2011-03-11 10:47:15 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
2016-05-16 17:34:04 +03:00
|
|
|
"Cannot find any files in the installed directory"
|
|
|
|
<< std::endl);
|
2011-03-11 10:47:15 +03:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-03-11 10:47:15 +03:00
|
|
|
packageFiles = gl.GetFiles();
|
|
|
|
|
|
|
|
int res = createDeb();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (res != 1) {
|
2011-03-11 10:47:15 +03:00
|
|
|
retval = 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-03-11 10:47:15 +03:00
|
|
|
// add the generated package to package file names list
|
2016-05-10 15:53:19 +03:00
|
|
|
packageFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
|
|
|
|
packageFileName += "/";
|
|
|
|
packageFileName += this->GetOption("GEN_CPACK_OUTPUT_FILE_NAME");
|
2011-03-11 10:47:15 +03:00
|
|
|
packageFileNames.push_back(packageFileName);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2010-08-11 21:48:39 +04:00
|
|
|
int cmCPackDebGenerator::PackageFiles()
|
2007-07-25 18:57:33 +04:00
|
|
|
{
|
2011-03-11 10:47:15 +03:00
|
|
|
/* Are we in the component packaging case */
|
2012-03-18 23:21:35 +04:00
|
|
|
if (WantsComponentInstallation()) {
|
2011-03-11 10:47:15 +03:00
|
|
|
// CASE 1 : COMPONENT ALL-IN-ONE package
|
|
|
|
// If ALL GROUPS or ALL COMPONENTS in ONE package has been requested
|
|
|
|
// then the package file is unique and should be open here.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (componentPackageMethod == ONE_PACKAGE) {
|
2016-05-10 19:31:05 +03:00
|
|
|
return PackageComponentsAllInOne("ALL_COMPONENTS_IN_ONE");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-03-11 10:47:15 +03:00
|
|
|
// CASE 2 : COMPONENT CLASSICAL package(s) (i.e. not all-in-one)
|
|
|
|
// There will be 1 package for each component group
|
|
|
|
// however one may require to ignore component group and
|
|
|
|
// in this case you'll get 1 package for each component.
|
2016-08-18 20:47:32 +03:00
|
|
|
return PackageComponents(componentPackageMethod ==
|
|
|
|
ONE_PACKAGE_PER_COMPONENT);
|
2011-03-11 10:47:15 +03:00
|
|
|
}
|
|
|
|
// CASE 3 : NON COMPONENT package.
|
2016-08-18 20:47:32 +03:00
|
|
|
return PackageComponentsAllInOne("");
|
2011-03-11 10:47:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int cmCPackDebGenerator::createDeb()
|
|
|
|
{
|
2007-07-25 21:08:17 +04:00
|
|
|
// debian-binary file
|
2016-05-10 15:17:40 +03:00
|
|
|
const std::string strGenWDIR(this->GetOption("GEN_WDIR"));
|
|
|
|
const std::string dbfilename = strGenWDIR + "/debian-binary";
|
2016-05-16 17:34:04 +03:00
|
|
|
{ // the scope is needed for cmGeneratedFileStream
|
2007-07-25 21:08:17 +04:00
|
|
|
cmGeneratedFileStream out(dbfilename.c_str());
|
|
|
|
out << "2.0";
|
|
|
|
out << std::endl; // required for valid debian package
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-07-25 21:08:17 +04:00
|
|
|
|
|
|
|
// control file
|
2016-05-10 15:17:40 +03:00
|
|
|
std::string ctlfilename = strGenWDIR + "/control";
|
2007-07-27 16:59:59 +04:00
|
|
|
|
|
|
|
// debian policy enforce lower case for package name
|
2007-08-08 22:18:13 +04:00
|
|
|
// mandatory entries:
|
2012-08-13 21:42:58 +04:00
|
|
|
std::string debian_pkg_name = cmsys::SystemTools::LowerCase(
|
2016-05-16 17:34:04 +03:00
|
|
|
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_NAME"));
|
2012-08-13 21:42:58 +04:00
|
|
|
const char* debian_pkg_version =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_VERSION");
|
2012-08-13 21:42:58 +04:00
|
|
|
const char* debian_pkg_section =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SECTION");
|
2012-08-13 21:42:58 +04:00
|
|
|
const char* debian_pkg_priority =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_PRIORITY");
|
2012-08-13 21:42:58 +04:00
|
|
|
const char* debian_pkg_arch =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_ARCHITECTURE");
|
2015-04-20 21:48:24 +03:00
|
|
|
const char* maintainer =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_MAINTAINER");
|
|
|
|
const char* desc = this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_DESCRIPTION");
|
2007-07-27 16:59:59 +04:00
|
|
|
|
2007-08-08 22:18:13 +04:00
|
|
|
// optional entries
|
2015-04-20 21:48:24 +03:00
|
|
|
const char* debian_pkg_dep =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_DEPENDS");
|
2010-07-28 20:24:20 +04:00
|
|
|
const char* debian_pkg_rec =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_RECOMMENDS");
|
2010-07-28 20:24:20 +04:00
|
|
|
const char* debian_pkg_sug =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SUGGESTS");
|
2010-07-28 20:24:20 +04:00
|
|
|
const char* debian_pkg_url =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_HOMEPAGE");
|
2010-10-25 22:40:45 +04:00
|
|
|
const char* debian_pkg_predep =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_PREDEPENDS");
|
2010-10-25 22:40:45 +04:00
|
|
|
const char* debian_pkg_enhances =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_ENHANCES");
|
2010-10-25 22:40:45 +04:00
|
|
|
const char* debian_pkg_breaks =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_BREAKS");
|
2010-10-25 22:40:45 +04:00
|
|
|
const char* debian_pkg_conflicts =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_CONFLICTS");
|
2010-10-25 22:40:45 +04:00
|
|
|
const char* debian_pkg_provides =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_PROVIDES");
|
2010-10-25 22:40:45 +04:00
|
|
|
const char* debian_pkg_replaces =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_REPLACES");
|
2015-11-04 02:19:58 +03:00
|
|
|
const char* debian_pkg_source =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SOURCE");
|
2007-08-08 22:18:13 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
{ // the scope is needed for cmGeneratedFileStream
|
2007-07-25 21:08:17 +04:00
|
|
|
cmGeneratedFileStream out(ctlfilename.c_str());
|
2007-07-27 16:59:59 +04:00
|
|
|
out << "Package: " << debian_pkg_name << "\n";
|
|
|
|
out << "Version: " << debian_pkg_version << "\n";
|
2007-08-08 22:18:13 +04:00
|
|
|
out << "Section: " << debian_pkg_section << "\n";
|
|
|
|
out << "Priority: " << debian_pkg_priority << "\n";
|
2007-07-27 16:59:59 +04:00
|
|
|
out << "Architecture: " << debian_pkg_arch << "\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (debian_pkg_source && *debian_pkg_source) {
|
2015-11-04 02:19:58 +03:00
|
|
|
out << "Source: " << debian_pkg_source << "\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (debian_pkg_dep && *debian_pkg_dep) {
|
2007-08-08 22:18:13 +04:00
|
|
|
out << "Depends: " << debian_pkg_dep << "\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (debian_pkg_rec && *debian_pkg_rec) {
|
2007-08-08 22:18:13 +04:00
|
|
|
out << "Recommends: " << debian_pkg_rec << "\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (debian_pkg_sug && *debian_pkg_sug) {
|
2007-08-08 22:18:13 +04:00
|
|
|
out << "Suggests: " << debian_pkg_sug << "\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (debian_pkg_url && *debian_pkg_url) {
|
2010-07-28 20:24:20 +04:00
|
|
|
out << "Homepage: " << debian_pkg_url << "\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (debian_pkg_predep && *debian_pkg_predep) {
|
2010-10-25 22:40:45 +04:00
|
|
|
out << "Pre-Depends: " << debian_pkg_predep << "\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (debian_pkg_enhances && *debian_pkg_enhances) {
|
2010-10-25 22:40:45 +04:00
|
|
|
out << "Enhances: " << debian_pkg_enhances << "\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (debian_pkg_breaks && *debian_pkg_breaks) {
|
2010-10-25 22:40:45 +04:00
|
|
|
out << "Breaks: " << debian_pkg_breaks << "\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (debian_pkg_conflicts && *debian_pkg_conflicts) {
|
2010-10-25 22:40:45 +04:00
|
|
|
out << "Conflicts: " << debian_pkg_conflicts << "\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (debian_pkg_provides && *debian_pkg_provides) {
|
2010-10-25 22:40:45 +04:00
|
|
|
out << "Provides: " << debian_pkg_provides << "\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (debian_pkg_replaces && *debian_pkg_replaces) {
|
2010-10-25 22:40:45 +04:00
|
|
|
out << "Replaces: " << debian_pkg_replaces << "\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-09-11 18:48:49 +04:00
|
|
|
unsigned long totalSize = 0;
|
|
|
|
{
|
|
|
|
std::string dirName = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
|
|
|
|
dirName += '/';
|
2015-09-11 21:58:18 +03:00
|
|
|
for (std::vector<std::string>::const_iterator fileIt =
|
2016-05-16 17:34:04 +03:00
|
|
|
packageFiles.begin();
|
|
|
|
fileIt != packageFiles.end(); ++fileIt) {
|
2014-11-23 13:05:50 +03:00
|
|
|
totalSize += cmSystemTools::FileLength(*fileIt);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-09-11 18:48:49 +04:00
|
|
|
}
|
2010-07-28 19:03:14 +04:00
|
|
|
out << "Installed-Size: " << (totalSize + 1023) / 1024 << "\n";
|
2007-07-27 16:59:59 +04:00
|
|
|
out << "Maintainer: " << maintainer << "\n";
|
|
|
|
out << "Description: " << desc << "\n";
|
2007-07-25 21:08:17 +04:00
|
|
|
out << std::endl;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-07-25 21:08:17 +04:00
|
|
|
|
2016-05-10 15:17:40 +03:00
|
|
|
const std::string shlibsfilename = strGenWDIR + "/shlibs";
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* debian_pkg_shlibs =
|
|
|
|
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SHLIBS");
|
|
|
|
const bool gen_shibs = this->IsOn("CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS") &&
|
|
|
|
debian_pkg_shlibs && *debian_pkg_shlibs;
|
|
|
|
if (gen_shibs) {
|
2016-05-10 15:17:40 +03:00
|
|
|
cmGeneratedFileStream out(shlibsfilename.c_str());
|
|
|
|
out << debian_pkg_shlibs;
|
|
|
|
out << std::endl;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-03-10 09:37:26 +04:00
|
|
|
|
2016-05-10 15:25:25 +03:00
|
|
|
const std::string postinst = strGenWDIR + "/postinst";
|
|
|
|
const std::string postrm = strGenWDIR + "/postrm";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTINST")) {
|
2016-05-10 15:25:25 +03:00
|
|
|
cmGeneratedFileStream out(postinst.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
out << "#!/bin/sh\n\n"
|
|
|
|
"set -e\n\n"
|
|
|
|
"if [ \"$1\" = \"configure\" ]; then\n"
|
|
|
|
"\tldconfig\n"
|
|
|
|
"fi\n";
|
|
|
|
}
|
|
|
|
if (this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTRM")) {
|
2016-05-10 15:25:25 +03:00
|
|
|
cmGeneratedFileStream out(postrm.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
out << "#!/bin/sh\n\n"
|
|
|
|
"set -e\n\n"
|
|
|
|
"if [ \"$1\" = \"remove\" ]; then\n"
|
|
|
|
"\tldconfig\n"
|
|
|
|
"fi\n";
|
|
|
|
}
|
2016-05-10 15:25:25 +03:00
|
|
|
|
2015-09-11 21:58:18 +03:00
|
|
|
cmArchiveWrite::Compress tar_compression_type = cmArchiveWrite::CompressGZip;
|
2014-03-10 09:37:26 +04:00
|
|
|
const char* debian_compression_type =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->GetOption("GEN_CPACK_DEBIAN_COMPRESSION_TYPE");
|
|
|
|
if (!debian_compression_type) {
|
2014-03-10 09:37:26 +04:00
|
|
|
debian_compression_type = "gzip";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-03-10 09:37:26 +04:00
|
|
|
|
2015-09-11 21:58:18 +03:00
|
|
|
std::string compression_suffix;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!strcmp(debian_compression_type, "lzma")) {
|
|
|
|
compression_suffix = ".lzma";
|
|
|
|
tar_compression_type = cmArchiveWrite::CompressLZMA;
|
|
|
|
} else if (!strcmp(debian_compression_type, "xz")) {
|
|
|
|
compression_suffix = ".xz";
|
|
|
|
tar_compression_type = cmArchiveWrite::CompressXZ;
|
|
|
|
} else if (!strcmp(debian_compression_type, "bzip2")) {
|
|
|
|
compression_suffix = ".bz2";
|
|
|
|
tar_compression_type = cmArchiveWrite::CompressBZip2;
|
|
|
|
} else if (!strcmp(debian_compression_type, "gzip")) {
|
|
|
|
compression_suffix = ".gz";
|
|
|
|
tar_compression_type = cmArchiveWrite::CompressGZip;
|
|
|
|
} else if (!strcmp(debian_compression_type, "none")) {
|
|
|
|
compression_suffix = "";
|
|
|
|
tar_compression_type = cmArchiveWrite::CompressNone;
|
2014-03-10 09:37:26 +04:00
|
|
|
} else {
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
|
|
|
"Error unrecognized compression type: "
|
2014-03-10 09:37:26 +04:00
|
|
|
<< debian_compression_type << std::endl);
|
|
|
|
}
|
|
|
|
|
2016-09-04 22:13:24 +03:00
|
|
|
const char* debian_archive_type =
|
|
|
|
this->GetOption("GEN_CPACK_DEBIAN_ARCHIVE_TYPE");
|
|
|
|
if (!debian_archive_type) {
|
|
|
|
debian_archive_type = "paxr";
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string filename_data_tar =
|
|
|
|
strGenWDIR + "/data.tar" + compression_suffix;
|
2015-09-11 21:58:18 +03:00
|
|
|
|
|
|
|
// atomic file generation for data.tar
|
|
|
|
{
|
|
|
|
cmGeneratedFileStream fileStream_data_tar;
|
|
|
|
fileStream_data_tar.Open(filename_data_tar.c_str(), false, true);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!fileStream_data_tar) {
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR, "Error opening the file \""
|
|
|
|
<< filename_data_tar << "\" for writing" << std::endl);
|
2015-09-11 21:58:18 +03:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2016-09-04 22:13:24 +03:00
|
|
|
cmArchiveWrite data_tar(fileStream_data_tar, tar_compression_type,
|
|
|
|
debian_archive_type);
|
2015-09-11 21:58:18 +03:00
|
|
|
|
|
|
|
// uid/gid should be the one of the root user, and this root user has
|
|
|
|
// always uid/gid equal to 0.
|
|
|
|
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
|
|
|
|
// e.g. /opt/bin/foo, /usr/bin/bar and /usr/bin/baz would
|
|
|
|
// give /usr and /opt
|
|
|
|
size_t topLevelLength = strGenWDIR.length();
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_DEBUG, "WDIR: \""
|
2016-05-16 17:34:04 +03:00
|
|
|
<< strGenWDIR << "\", length = " << topLevelLength
|
|
|
|
<< std::endl);
|
2015-09-11 21:58:18 +03:00
|
|
|
std::set<std::string> orderedFiles;
|
|
|
|
|
|
|
|
// we have to reconstruct the parent folders as well
|
|
|
|
|
2011-03-11 10:47:15 +03:00
|
|
|
for (std::vector<std::string>::const_iterator fileIt =
|
2016-05-16 17:34:04 +03:00
|
|
|
packageFiles.begin();
|
|
|
|
fileIt != packageFiles.end(); ++fileIt) {
|
2015-09-11 21:58:18 +03:00
|
|
|
std::string currentPath = *fileIt;
|
2016-05-16 17:34:04 +03:00
|
|
|
while (currentPath != strGenWDIR) {
|
2015-09-11 21:58:18 +03:00
|
|
|
// the last one IS strGenWDIR, but we do not want this one:
|
|
|
|
// XXX/application/usr/bin/myprogram with GEN_WDIR=XXX/application
|
|
|
|
// should not add XXX/application
|
|
|
|
orderedFiles.insert(currentPath);
|
|
|
|
currentPath = cmSystemTools::CollapseCombinedPath(currentPath, "..");
|
2008-03-29 03:23:01 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-03-29 03:23:01 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::set<std::string>::const_iterator fileIt = orderedFiles.begin();
|
|
|
|
fileIt != orderedFiles.end(); ++fileIt) {
|
2015-09-11 21:58:18 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_DEBUG, "FILEIT: \"" << *fileIt << "\""
|
2016-05-16 17:34:04 +03:00
|
|
|
<< std::endl);
|
|
|
|
std::string::size_type slashPos = fileIt->find('/', topLevelLength + 1);
|
|
|
|
std::string relativeDir =
|
|
|
|
fileIt->substr(topLevelLength, slashPos - topLevelLength);
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_DEBUG, "RELATIVEDIR: \""
|
|
|
|
<< relativeDir << "\"" << std::endl);
|
2015-09-11 21:58:18 +03:00
|
|
|
|
|
|
|
// do not recurse because the loop will do it
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!data_tar.Add(*fileIt, topLevelLength, ".", false)) {
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem adding file to tar:"
|
|
|
|
<< std::endl
|
|
|
|
<< "#top level directory: " << strGenWDIR << std::endl
|
|
|
|
<< "#file: " << *fileIt << std::endl
|
|
|
|
<< "#error:" << data_tar.GetError() << std::endl);
|
2015-09-11 21:58:18 +03:00
|
|
|
return 0;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-09-11 21:58:18 +03:00
|
|
|
} // scope for file generation
|
2007-07-25 21:08:17 +04:00
|
|
|
|
2015-09-11 21:58:18 +03:00
|
|
|
std::string md5filename = strGenWDIR + "/md5sums";
|
|
|
|
{
|
|
|
|
// the scope is needed for cmGeneratedFileStream
|
2007-07-25 21:08:17 +04:00
|
|
|
cmGeneratedFileStream out(md5filename.c_str());
|
2015-09-11 21:58:18 +03:00
|
|
|
|
2011-03-11 10:47:15 +03:00
|
|
|
std::string topLevelWithTrailingSlash =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->GetOption("CPACK_TEMPORARY_DIRECTORY");
|
2007-08-06 17:03:10 +04:00
|
|
|
topLevelWithTrailingSlash += '/';
|
2015-09-11 21:58:18 +03:00
|
|
|
for (std::vector<std::string>::const_iterator fileIt =
|
|
|
|
packageFiles.begin();
|
2016-05-16 17:34:04 +03:00
|
|
|
fileIt != packageFiles.end(); ++fileIt) {
|
2015-09-18 23:20:42 +03:00
|
|
|
// hash only regular files
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::FileIsDirectory(*fileIt) ||
|
|
|
|
cmSystemTools::FileIsSymlink(*fileIt)) {
|
2015-09-18 23:20:42 +03:00
|
|
|
continue;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-09-18 23:20:42 +03:00
|
|
|
|
|
|
|
char md5sum[33];
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmSystemTools::ComputeFileMD5(*fileIt, md5sum)) {
|
2015-09-18 23:20:42 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem computing the md5 of "
|
2016-05-16 17:34:04 +03:00
|
|
|
<< *fileIt << std::endl);
|
|
|
|
}
|
2015-09-18 23:20:42 +03:00
|
|
|
|
|
|
|
md5sum[32] = 0;
|
|
|
|
|
|
|
|
std::string output(md5sum);
|
|
|
|
output += " " + *fileIt + "\n";
|
2007-08-06 17:03:10 +04:00
|
|
|
// debian md5sums entries are like this:
|
|
|
|
// 014f3604694729f3bf19263bac599765 usr/bin/ccmake
|
|
|
|
// thus strip the full path (with the trailing slash)
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::ReplaceString(output, topLevelWithTrailingSlash.c_str(),
|
|
|
|
"");
|
2007-07-25 21:08:17 +04:00
|
|
|
out << output;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-03-11 10:47:15 +03:00
|
|
|
// each line contains a eol.
|
2007-08-06 21:31:37 +04:00
|
|
|
// Do not end the md5sum file with yet another (invalid)
|
2015-09-11 21:58:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string filename_control_tar = strGenWDIR + "/control.tar.gz";
|
|
|
|
// atomic file generation for control.tar
|
|
|
|
{
|
|
|
|
cmGeneratedFileStream fileStream_control_tar;
|
|
|
|
fileStream_control_tar.Open(filename_control_tar.c_str(), false, true);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!fileStream_control_tar) {
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR, "Error opening the file \""
|
|
|
|
<< filename_control_tar << "\" for writing"
|
|
|
|
<< std::endl);
|
2015-09-11 21:58:18 +03:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-09-11 21:58:18 +03:00
|
|
|
cmArchiveWrite control_tar(fileStream_control_tar,
|
2016-09-04 22:13:24 +03:00
|
|
|
cmArchiveWrite::CompressGZip,
|
|
|
|
debian_archive_type);
|
2015-09-11 21:58:18 +03:00
|
|
|
|
|
|
|
// sets permissions and uid/gid for the files
|
|
|
|
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
|
|
|
|
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 permission755 = permission644 | permissionExecute;
|
|
|
|
|
|
|
|
// for md5sum and control (that we have generated here), we use 644
|
|
|
|
// (RW-R--R--)
|
|
|
|
// so that deb lintian doesn't warn about it
|
|
|
|
control_tar.SetPermissions(permission644);
|
|
|
|
|
|
|
|
// adds control and md5sums
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!control_tar.Add(md5filename, strGenWDIR.length(), ".") ||
|
|
|
|
!control_tar.Add(strGenWDIR + "/control", strGenWDIR.length(), ".")) {
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR, "Error adding file to tar:"
|
|
|
|
<< std::endl
|
|
|
|
<< "#top level directory: " << strGenWDIR << std::endl
|
|
|
|
<< "#file: \"control\" or \"md5sums\"" << std::endl
|
|
|
|
<< "#error:" << control_tar.GetError() << std::endl);
|
|
|
|
return 0;
|
|
|
|
}
|
2015-04-21 18:19:57 +03:00
|
|
|
|
2016-05-10 15:17:40 +03:00
|
|
|
// adds generated shlibs file
|
2016-05-16 17:34:04 +03:00
|
|
|
if (gen_shibs) {
|
|
|
|
if (!control_tar.Add(shlibsfilename, strGenWDIR.length(), ".")) {
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR, "Error adding file to tar:"
|
|
|
|
<< std::endl
|
|
|
|
<< "#top level directory: " << strGenWDIR << std::endl
|
|
|
|
<< "#file: \"shlibs\"" << std::endl
|
|
|
|
<< "#error:" << control_tar.GetError() << std::endl);
|
|
|
|
return 0;
|
2016-05-10 15:17:40 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2016-05-10 15:17:40 +03:00
|
|
|
|
2016-05-10 15:25:25 +03:00
|
|
|
// adds LDCONFIG related files
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTINST")) {
|
2016-05-10 15:25:25 +03:00
|
|
|
control_tar.SetPermissions(permission755);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!control_tar.Add(postinst, strGenWDIR.length(), ".")) {
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR, "Error adding file to tar:"
|
|
|
|
<< std::endl
|
|
|
|
<< "#top level directory: " << strGenWDIR << std::endl
|
|
|
|
<< "#file: \"postinst\"" << std::endl
|
|
|
|
<< "#error:" << control_tar.GetError() << std::endl);
|
|
|
|
return 0;
|
2016-05-10 15:25:25 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
control_tar.SetPermissions(permission644);
|
|
|
|
}
|
2016-05-10 15:25:25 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTRM")) {
|
2016-05-10 15:25:25 +03:00
|
|
|
control_tar.SetPermissions(permission755);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!control_tar.Add(postrm, strGenWDIR.length(), ".")) {
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR, "Error adding file to tar:"
|
|
|
|
<< std::endl
|
|
|
|
<< "#top level directory: " << strGenWDIR << std::endl
|
|
|
|
<< "#file: \"postinst\"" << std::endl
|
|
|
|
<< "#error:" << control_tar.GetError() << std::endl);
|
|
|
|
return 0;
|
2016-05-10 15:25:25 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
control_tar.SetPermissions(permission644);
|
|
|
|
}
|
2016-05-10 15:25:25 +03:00
|
|
|
|
2015-09-11 21:58:18 +03:00
|
|
|
// for the other files, we use
|
|
|
|
// -either the original permission on the files
|
|
|
|
// -either a permission strictly defined by the Debian policies
|
2012-04-17 11:22:07 +04:00
|
|
|
const char* controlExtra =
|
2015-04-20 21:48:24 +03:00
|
|
|
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (controlExtra) {
|
2015-09-11 21:58:18 +03:00
|
|
|
// permissions are now controlled by the original file permissions
|
|
|
|
|
|
|
|
const bool permissionStrictPolicy =
|
|
|
|
this->IsSet("GEN_CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION");
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
static const char* strictFiles[] = { "config", "postinst", "postrm",
|
|
|
|
"preinst", "prerm" };
|
2015-09-11 21:58:18 +03:00
|
|
|
std::set<std::string> setStrictFiles(
|
|
|
|
strictFiles,
|
2016-05-16 17:34:04 +03:00
|
|
|
strictFiles + sizeof(strictFiles) / sizeof(strictFiles[0]));
|
2015-09-11 21:58:18 +03:00
|
|
|
|
|
|
|
// default
|
|
|
|
control_tar.ClearPermissions();
|
|
|
|
|
|
|
|
std::vector<std::string> controlExtraList;
|
|
|
|
cmSystemTools::ExpandListArgument(controlExtra, controlExtraList);
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::iterator i = controlExtraList.begin();
|
|
|
|
i != controlExtraList.end(); ++i) {
|
|
|
|
std::string filenamename = cmsys::SystemTools::GetFilenameName(*i);
|
2015-09-11 21:58:18 +03:00
|
|
|
std::string localcopy = strGenWDIR + "/" + filenamename;
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (permissionStrictPolicy) {
|
|
|
|
control_tar.SetPermissions(setStrictFiles.count(filenamename)
|
|
|
|
? permission755
|
|
|
|
: permission644);
|
|
|
|
}
|
2015-09-11 21:58:18 +03:00
|
|
|
|
|
|
|
// if we can copy the file, it means it does exist, let's add it:
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmsys::SystemTools::CopyFileIfDifferent(*i, localcopy)) {
|
2015-09-11 21:58:18 +03:00
|
|
|
control_tar.Add(localcopy, strGenWDIR.length(), ".");
|
2008-04-02 01:51:10 +04:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-09-11 21:58:18 +03:00
|
|
|
}
|
2007-07-25 21:08:17 +04:00
|
|
|
|
2014-03-10 09:37:26 +04:00
|
|
|
// ar -r your-package-name.deb debian-binary control.tar.* data.tar.*
|
2007-08-14 16:40:40 +04:00
|
|
|
// since debian packages require BSD ar (most Linux distros and even
|
|
|
|
// FreeBSD and NetBSD ship GNU ar) we use a copy of OpenBSD ar here.
|
|
|
|
std::vector<std::string> arFiles;
|
2015-09-11 21:58:18 +03:00
|
|
|
std::string topLevelString = strGenWDIR + "/";
|
2007-08-14 16:40:40 +04:00
|
|
|
arFiles.push_back(topLevelString + "debian-binary");
|
|
|
|
arFiles.push_back(topLevelString + "control.tar.gz");
|
2014-03-10 09:37:26 +04:00
|
|
|
arFiles.push_back(topLevelString + "data.tar" + compression_suffix);
|
2015-09-11 21:58:18 +03:00
|
|
|
std::string outputFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
|
|
|
|
outputFileName += "/";
|
2016-05-10 15:53:19 +03:00
|
|
|
outputFileName += this->GetOption("GEN_CPACK_OUTPUT_FILE_NAME");
|
2015-09-11 21:58:18 +03:00
|
|
|
int res = ar_append(outputFileName.c_str(), arFiles);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (res != 0) {
|
|
|
|
std::string tmpFile =
|
|
|
|
this->GetOption("GEN_CPACK_TEMPORARY_PACKAGE_FILE_NAME");
|
2007-08-06 21:31:37 +04:00
|
|
|
tmpFile += "/Deb.log";
|
|
|
|
cmGeneratedFileStream ofs(tmpFile.c_str());
|
2007-08-14 16:40:40 +04:00
|
|
|
ofs << "# Problem creating archive using: " << res << std::endl;
|
2007-08-06 21:31:37 +04:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-07-25 18:57:33 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2011-03-11 10:47:15 +03:00
|
|
|
bool cmCPackDebGenerator::SupportsComponentInstallation() const
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
2016-06-02 00:29:53 +03:00
|
|
|
return IsOn("CPACK_DEB_COMPONENT_INSTALL");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-03-11 10:47:15 +03:00
|
|
|
|
|
|
|
std::string cmCPackDebGenerator::GetComponentInstallDirNameSuffix(
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& componentName)
|
|
|
|
{
|
2011-03-25 19:18:59 +03:00
|
|
|
if (componentPackageMethod == ONE_PACKAGE_PER_COMPONENT) {
|
2011-03-11 10:47:15 +03:00
|
|
|
return componentName;
|
|
|
|
}
|
|
|
|
|
2011-03-25 19:18:59 +03:00
|
|
|
if (componentPackageMethod == ONE_PACKAGE) {
|
2011-03-11 10:47:15 +03:00
|
|
|
return std::string("ALL_COMPONENTS_IN_ONE");
|
|
|
|
}
|
|
|
|
// We have to find the name of the COMPONENT GROUP
|
|
|
|
// the current COMPONENT belongs to.
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string groupVar =
|
|
|
|
"CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP";
|
2016-06-27 23:44:16 +03:00
|
|
|
if (CM_NULLPTR != GetOption(groupVar)) {
|
2016-05-16 17:34:04 +03:00
|
|
|
return std::string(GetOption(groupVar));
|
2011-03-11 10:47:15 +03:00
|
|
|
}
|
2016-08-18 20:47:32 +03:00
|
|
|
return componentName;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-03-11 10:47:15 +03:00
|
|
|
|
2007-08-14 16:40:40 +04:00
|
|
|
// The following code is taken from OpenBSD ar:
|
|
|
|
// http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ar/
|
|
|
|
// It has been slightly modified:
|
|
|
|
// -return error codes instead exit() in functions
|
|
|
|
// -use the stdio file I/O functions instead the file descriptor based ones
|
|
|
|
// -merged into one cxx file
|
|
|
|
// -no additional options supported
|
|
|
|
// The coding style hasn't been modified.
|
|
|
|
|
|
|
|
/*-
|
|
|
|
* Copyright (c) 1990, 1993, 1994
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* Hugh Smith at The University of Guelph.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
#define ARMAG "!<arch>\n" /* ar "magic number" */
|
|
|
|
#define SARMAG 8 /* strlen(ARMAG); */
|
2007-08-14 16:40:40 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
#define AR_EFMT1 "#1/" /* extended format #1 */
|
|
|
|
#define ARFMAG "`\n"
|
2007-08-14 16:40:40 +04:00
|
|
|
|
|
|
|
/* Header format strings. */
|
2016-05-16 17:34:04 +03:00
|
|
|
#define HDR1 "%s%-13d%-12ld%-6u%-6u%-8o%-10lld%2s"
|
|
|
|
#define HDR2 "%-16.16s%-12ld%-6u%-6u%-8o%-10lld%2s"
|
|
|
|
|
|
|
|
struct ar_hdr
|
|
|
|
{
|
|
|
|
char ar_name[16]; /* name */
|
|
|
|
char ar_date[12]; /* modification time */
|
|
|
|
char ar_uid[6]; /* user id */
|
|
|
|
char ar_gid[6]; /* group id */
|
|
|
|
char ar_mode[8]; /* octal file permissions */
|
|
|
|
char ar_size[10]; /* size in bytes */
|
|
|
|
char ar_fmag[2]; /* consistency check */
|
2007-08-14 16:40:40 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Set up file copy. */
|
2016-05-16 17:34:04 +03:00
|
|
|
#define SETCF(from, fromname, to, toname, pad) \
|
|
|
|
{ \
|
|
|
|
cf.rFile = from; \
|
|
|
|
cf.rname = fromname; \
|
|
|
|
cf.wFile = to; \
|
|
|
|
cf.wname = toname; \
|
|
|
|
cf.flags = pad; \
|
|
|
|
}
|
2007-08-14 16:40:40 +04:00
|
|
|
|
|
|
|
/* File copy structure. */
|
2016-05-16 17:34:04 +03:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
FILE* rFile; /* read file descriptor */
|
|
|
|
const char* rname; /* read name */
|
|
|
|
FILE* wFile; /* write file descriptor */
|
|
|
|
const char* wname; /* write name */
|
|
|
|
#define NOPAD 0x00 /* don't pad */
|
|
|
|
#define WPAD 0x02 /* pad on writes */
|
|
|
|
unsigned int flags; /* pad flags */
|
2007-08-14 16:40:40 +04:00
|
|
|
} CF;
|
|
|
|
|
|
|
|
/* misc.c */
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
static const char* ar_rname(const char* path)
|
2007-07-25 18:57:33 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* ind = strrchr(path, '/');
|
|
|
|
return (ind) ? ind + 1 : path;
|
2007-08-14 16:40:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* archive.c */
|
|
|
|
|
|
|
|
typedef struct ar_hdr HDR;
|
2016-05-16 17:34:04 +03:00
|
|
|
static char ar_hb[sizeof(HDR) + 1]; /* real header */
|
2007-08-14 16:40:40 +04:00
|
|
|
|
2010-06-30 17:57:07 +04:00
|
|
|
static size_t ar_already_written;
|
2007-08-14 16:40:40 +04:00
|
|
|
|
|
|
|
/* copy_ar --
|
|
|
|
* Copy size bytes from one file to another - taking care to handle the
|
|
|
|
* extra byte (for odd size files) when reading archives and writing an
|
|
|
|
* extra byte if necessary when adding files to archive. The length of
|
|
|
|
* the object is the long name plus the object itself; the variable
|
|
|
|
* already_written gets set if a long name was written.
|
|
|
|
*
|
|
|
|
* The padding is really unnecessary, and is almost certainly a remnant
|
|
|
|
* of early archive formats where the header included binary data which
|
|
|
|
* a PDP-11 required to start on an even byte boundary. (Or, perhaps,
|
|
|
|
* because 16-bit word addressed copies were faster?) Anyhow, it should
|
|
|
|
* have been ripped out long ago.
|
|
|
|
*/
|
2016-05-16 17:34:04 +03:00
|
|
|
static int copy_ar(CF* cfp, off_t size)
|
2007-08-14 16:40:40 +04:00
|
|
|
{
|
|
|
|
static char pad = '\n';
|
|
|
|
off_t sz = size;
|
2007-11-05 22:34:36 +03:00
|
|
|
size_t nr, nw;
|
2016-05-16 17:34:04 +03:00
|
|
|
char buf[8 * 1024];
|
2007-08-14 16:40:40 +04:00
|
|
|
|
2016-06-10 19:36:24 +03:00
|
|
|
if (sz == 0) {
|
2007-07-25 18:57:33 +04:00
|
|
|
return 0;
|
2016-06-10 19:36:24 +03:00
|
|
|
}
|
2007-08-14 16:40:40 +04:00
|
|
|
|
|
|
|
FILE* from = cfp->rFile;
|
|
|
|
FILE* to = cfp->wFile;
|
2012-08-13 21:42:58 +04:00
|
|
|
while (sz &&
|
2016-05-16 17:34:04 +03:00
|
|
|
(nr = fread(buf, 1, sz < static_cast<off_t>(sizeof(buf))
|
|
|
|
? static_cast<size_t>(sz)
|
|
|
|
: sizeof(buf),
|
|
|
|
from)) > 0) {
|
2007-08-14 16:40:40 +04:00
|
|
|
sz -= nr;
|
2016-06-10 19:36:24 +03:00
|
|
|
for (size_t off = 0; off < nr; nr -= off, off += nw) {
|
|
|
|
if ((nw = fwrite(buf + off, 1, nr, to)) < nr) {
|
2007-08-14 16:40:40 +04:00
|
|
|
return -1;
|
2016-06-10 19:36:24 +03:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2016-06-10 19:36:24 +03:00
|
|
|
if (sz) {
|
2007-08-14 16:40:40 +04:00
|
|
|
return -2;
|
2016-06-10 19:36:24 +03:00
|
|
|
}
|
2007-08-14 16:40:40 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cfp->flags & WPAD && (size + ar_already_written) & 1 &&
|
2016-06-10 19:36:24 +03:00
|
|
|
fwrite(&pad, 1, 1, to) != 1) {
|
2007-08-14 16:40:40 +04:00
|
|
|
return -4;
|
2016-06-10 19:36:24 +03:00
|
|
|
}
|
2007-08-14 16:40:40 +04:00
|
|
|
|
|
|
|
return 0;
|
2007-07-25 18:57:33 +04:00
|
|
|
}
|
|
|
|
|
2007-08-14 16:40:40 +04:00
|
|
|
/* put_arobj -- Write an archive member to a file. */
|
2016-05-16 17:34:04 +03:00
|
|
|
static int put_arobj(CF* cfp, struct stat* sb)
|
2007-08-14 16:40:40 +04:00
|
|
|
{
|
|
|
|
int result = 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
struct ar_hdr* hdr;
|
2007-08-14 16:40:40 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
/* If passed an sb structure, reading a file from disk. Get stat(2)
|
|
|
|
* information, build a name and construct a header. (Files are named
|
|
|
|
* by their last component in the archive.) */
|
2007-08-14 16:40:40 +04:00
|
|
|
const char* name = ar_rname(cfp->rname);
|
|
|
|
(void)stat(cfp->rname, sb);
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
/* If not truncating names and the name is too long or contains
|
|
|
|
* a space, use extended format 1. */
|
2010-06-30 17:57:07 +04:00
|
|
|
size_t lname = strlen(name);
|
2007-08-14 16:40:40 +04:00
|
|
|
uid_t uid = sb->st_uid;
|
|
|
|
gid_t gid = sb->st_gid;
|
|
|
|
if (uid > USHRT_MAX) {
|
|
|
|
uid = USHRT_MAX;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-08-14 16:40:40 +04:00
|
|
|
if (gid > USHRT_MAX) {
|
|
|
|
gid = USHRT_MAX;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2016-06-10 19:36:24 +03:00
|
|
|
if (lname > sizeof(hdr->ar_name) || strchr(name, ' ')) {
|
2016-05-16 17:34:04 +03:00
|
|
|
(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);
|
2016-06-10 19:36:24 +03:00
|
|
|
} else {
|
2016-05-16 17:34:04 +03:00
|
|
|
lname = 0;
|
|
|
|
(void)sprintf(ar_hb, HDR2, name, (long int)sb->st_mtime, (unsigned)uid,
|
|
|
|
(unsigned)gid, (unsigned)sb->st_mode, (long long)sb->st_size,
|
2015-03-31 23:28:28 +03:00
|
|
|
ARFMAG);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
off_t size = sb->st_size;
|
2007-08-14 16:40:40 +04:00
|
|
|
|
2016-06-10 19:36:24 +03:00
|
|
|
if (fwrite(ar_hb, 1, sizeof(HDR), cfp->wFile) != sizeof(HDR)) {
|
2007-08-14 16:40:40 +04:00
|
|
|
return -1;
|
2016-06-10 19:36:24 +03:00
|
|
|
}
|
2007-08-14 16:40:40 +04:00
|
|
|
|
|
|
|
if (lname) {
|
2016-06-10 19:36:24 +03:00
|
|
|
if (fwrite(name, 1, lname, cfp->wFile) != lname) {
|
2007-08-14 16:40:40 +04:00
|
|
|
return -2;
|
2016-06-10 19:36:24 +03:00
|
|
|
}
|
2007-08-14 16:40:40 +04:00
|
|
|
ar_already_written = lname;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-08-14 16:40:40 +04:00
|
|
|
result = copy_ar(cfp, size);
|
|
|
|
ar_already_written = 0;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* append.c */
|
|
|
|
|
|
|
|
/* append --
|
|
|
|
* Append files to the archive - modifies original archive or creates
|
2012-08-13 21:42:58 +04:00
|
|
|
* a new archive if named archive does not exist.
|
2007-08-14 16:40:40 +04:00
|
|
|
*/
|
2016-05-16 17:34:04 +03:00
|
|
|
static int ar_append(const char* archive,
|
|
|
|
const std::vector<std::string>& files)
|
2007-08-14 16:40:40 +04:00
|
|
|
{
|
|
|
|
int eval = 0;
|
2014-01-04 09:47:13 +04:00
|
|
|
FILE* aFile = cmSystemTools::Fopen(archive, "wb+");
|
2016-06-27 23:44:16 +03:00
|
|
|
if (aFile != CM_NULLPTR) {
|
2007-08-14 16:40:40 +04:00
|
|
|
fwrite(ARMAG, SARMAG, 1, aFile);
|
2007-11-05 22:34:36 +03:00
|
|
|
if (fseek(aFile, 0, SEEK_END) != -1) {
|
2007-08-14 16:40:40 +04:00
|
|
|
CF cf;
|
|
|
|
struct stat sb;
|
|
|
|
/* Read from disk, write to an archive; pad on write. */
|
2016-06-27 23:44:16 +03:00
|
|
|
SETCF(CM_NULLPTR, CM_NULLPTR, aFile, archive, WPAD);
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator fileIt = files.begin();
|
|
|
|
fileIt != files.end(); ++fileIt) {
|
2007-08-14 16:40:40 +04:00
|
|
|
const char* filename = fileIt->c_str();
|
2014-01-04 09:47:13 +04:00
|
|
|
FILE* file = cmSystemTools::Fopen(filename, "rb");
|
2016-06-27 23:44:16 +03:00
|
|
|
if (file == CM_NULLPTR) {
|
2007-08-14 16:40:40 +04:00
|
|
|
eval = -1;
|
|
|
|
continue;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-08-14 16:40:40 +04:00
|
|
|
cf.rFile = file;
|
|
|
|
cf.rname = filename;
|
|
|
|
int result = put_arobj(&cf, &sb);
|
|
|
|
(void)fclose(file);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (result != 0) {
|
2007-08-14 16:40:40 +04:00
|
|
|
eval = -2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
|
|
|
eval = -3;
|
2007-08-14 16:40:40 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
fclose(aFile);
|
|
|
|
} else {
|
2007-08-14 16:40:40 +04:00
|
|
|
eval = -4;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-08-14 16:40:40 +04:00
|
|
|
return eval;
|
|
|
|
}
|