MatN work for versatile appimage creation for all types of os
[goodguy/cinelerra.git] / cinelerra-5.1 / tools / makeappimagetool / includes / appdir.h
1 // system includes
2 #include <memory>
3 #include <string>
4
5 // library includes
6 #include <boost/filesystem.hpp>
7
8 // local includes
9 #include "desktopfile.h"
10
11 #pragma once
12
13 namespace linuxdeploy {
14     namespace core {
15         namespace appdir {
16             /*
17              * Base class for AppDirs.
18              */
19             class AppDir {
20                 private:
21                     // private data class pattern
22                     class PrivateData;
23                     std::shared_ptr<PrivateData> d;
24
25                 public:
26                     // default constructor
27                     // construct AppDir from given path
28                     // the directory will be created if it doesn't exist
29                     explicit AppDir(const boost::filesystem::path& path);
30
31                     // we don't want any copy/move(-assignment) behavior, therefore we delete those operators/constructors
32                     AppDir(const AppDir&) = delete;
33                     AppDir(AppDir&&) = delete;
34                     void operator=(const AppDir&) = delete;
35                     void operator=(AppDir&&) = delete;
36
37                     // alternative constructor
38                     // shortcut for using a normal string instead of a path
39                     explicit AppDir(const std::string& path);
40
41                     // creates basic directory structure of an AppDir in "FHS" mode
42                     bool createBasicStructure() const;
43
44                     // deploy shared library
45                     //
46                     // if destination is specified, the library is copied to this location, and the rpath is adjusted accordingly
47                     // the dependencies are copied to the normal destination, though
48                     bool deployLibrary(const boost::filesystem::path& path, const boost::filesystem::path& destination = "");
49
50                     // force deploy shared library
51                     //
52                     // works like deployLibrary, except that it doesn't check the excludelist
53                     // this is useful to deploy libraries and their dependencies that are blacklisted and would otherwise not be deployed
54                     // the excludelist check is only disabled for the current library, and will be enabled for the dependencies again
55                     bool forceDeployLibrary(const boost::filesystem::path& path, const boost::filesystem::path& destination = "");
56
57                     // deploy executable
58                     bool deployExecutable(const boost::filesystem::path& path, const boost::filesystem::path& destination = "");
59
60                     // deploy dependencies for ELF file in AppDir, without copying it into the library dir
61                     //
62                     // the dependencies end up in the regular location
63                     bool deployDependenciesOnlyForElfFile(const boost::filesystem::path& elfFilePath, bool failSilentForNonElfFile = false);
64
65                     // deploy desktop file
66                     bool deployDesktopFile(const desktopfile::DesktopFile& desktopFile);
67
68                     // deploy icon
69                     bool deployIcon(const boost::filesystem::path& path);
70
71                     // deploy icon, changing its name to <target filename>.<ext>
72                     bool deployIcon(const boost::filesystem::path& path, const std::string& targetFilename);
73
74                     // deploy arbitrary file
75                     boost::filesystem::path deployFile(const boost::filesystem::path& from, const boost::filesystem::path& to);
76
77                     // copy arbitrary file (immediately)
78                     bool copyFile(const boost::filesystem::path& from, const boost::filesystem::path& to, bool overwrite = false) const;
79
80                     // create an <AppDir> relative symlink to <target> at <symlink>.
81                     bool createRelativeSymlink(const boost::filesystem::path& target, const boost::filesystem::path& symlink) const;
82
83                     // execute deferred copy operations
84                     bool executeDeferredOperations();
85
86                     // return path to AppDir
87                     boost::filesystem::path path() const;
88
89                     // create a list of all icon paths in the AppDir
90                     std::vector<boost::filesystem::path> deployedIconPaths() const;
91
92                     // create a list of all executable paths in the AppDir
93                     std::vector<boost::filesystem::path> deployedExecutablePaths() const;
94
95                     // create a list of all desktop file paths in the AppDir
96                     std::vector<desktopfile::DesktopFile> deployedDesktopFiles() const;
97
98                     // create symlinks for AppRun, desktop file and icon in the AppDir root directory
99                     bool setUpAppDirRoot(const desktopfile::DesktopFile& desktopFile, boost::filesystem::path customAppRunPath = "");
100
101                     // list all executables in <AppDir>/usr/bin
102                     // this function does not perform a recursive search, but only searches the bin directory
103                     std::vector<boost::filesystem::path> listExecutables() const;
104
105                     // list all shared libraries in <AppDir>/usr/lib
106                     // this function recursively searches the entire lib directory for shared libraries
107                     std::vector<boost::filesystem::path> listSharedLibraries() const;
108
109                     // search for executables and libraries and deploy their dependencies
110                     // calling this function can turn sure file trees created by make install commands into working
111                     // AppDirs
112                     bool deployDependenciesForExistingFiles() const;
113
114                     // disable deployment of copyright files for this instance
115                     void setDisableCopyrightFilesDeployment(bool disable);
116             };
117         }
118     }
119 }