123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269 |
- /*++
- Copyright (c) 2017 Minoca Corp.
- This file is licensed under the terms of the GNU General Public License
- version 3. Alternative licensing terms are available. Contact
- info@minocacorp.com for details. See the LICENSE file at the root of this
- project for complete licensing information.
- Module Name:
- copy.ck
- Abstract:
- This module implements package presentation based on copying files from
- storage into their final destination.
- Author:
- Evan Green 25-May-2017
- Environment:
- Chalk
- --*/
- //
- // ------------------------------------------------------------------- Includes
- //
- from santa.config import config;
- from santa.file import cptree, exists, mkdir, isdir;
- from santa.presentation import Presentation, PresentationError;
- //
- // --------------------------------------------------------------------- Macros
- //
- //
- // ---------------------------------------------------------------- Definitions
- //
- //
- // ------------------------------------------------------ Data Type Definitions
- //
- //
- // ----------------------------------------------- Internal Function Prototypes
- //
- //
- // -------------------------------------------------------------------- Globals
- //
- //
- // ------------------------------------------------------------------ Functions
- //
- class CopyPresentation is Presentation {
- var _parameters;
- function
- create (
- parameters
- )
- /*++
- Routine Description:
- This routine creates a new presentation layer and initializes this
- instance's internal variables to represent it.
- Arguments:
- parameters - Supplies a dictionary of creation parameters.
- Return Value:
- None.
- --*/
- {
- _parameters = parameters.copy();
- this.type = "copy";
- return;
- }
- function
- destroy (
- )
- /*++
- Routine Description:
- This routine destroys the presentation layer represented by this
- instance.
- Arguments:
- None.
- Return Value:
- None.
- --*/
- {
- return;
- }
- function
- load (
- parameters
- )
- /*++
- Routine Description:
- This routine initializes this instance to reflect the presentation
- identified by the given parameters.
- Arguments:
- parameters - Supplies a dictionary of parameters.
- Return Value:
- None.
- --*/
- {
- _parameters = parameters;
- this.type = "copy";
- return;
- }
- function
- save (
- )
- /*++
- Routine Description:
- This routine returns the dictionary of state and identification needed
- to restore information about this presentation layer by other instances
- of this class.
- Arguments:
- None.
- Return Value:
- Returns a dictionary of parameters to save describing this instance.
- --*/
- {
- return _parameters;
- }
- function
- addFiles (
- controlDirectory,
- realm,
- files,
- conffiles,
- root
- )
- /*++
- Routine Description:
- This routine adds a set of files into the environment.
- Arguments:
- controlDirectory - Supplies the directory containing the control and
- initial data of the package.
- realm - Supplies the realm being operated on.
- files - Supplies the files to add.
- conffiles - Suppiles the dictionary of files not to clobber if they
- exist, or to copy directly if they do not.
- root - Supplies the root directory to install to.
- Return Value:
- None.
- --*/
- {
- var dest;
- var destdir = realm.containment.outerPath(root);
- var srcfile;
- var srcdir = controlDirectory + "/data";
- if (destdir.endsWith("/")) {
- destdir = destdir[0..-1];
- }
- //
- // First create all the directories.
- //
- for (file in files) {
- srcfile = "/".join([srcdir, file]);
- if (isdir(srcfile)) {
- mkdir("/".join([destdir, file]));
- }
- }
- //
- // Now copy all the files.
- //
- for (file in files) {
- srcfile = "/".join([srcdir, file]);
- if (isdir(srcfile)) {
- continue;
- }
- dest = "/".join([destdir, file]);
- if ((conffiles.get(dest) != null) && (exists(dest))) {
- if (config.getKey("core.verbose")) {
- Core.print("Skipping pre-existing configuration file: %s" %
- dest);
- }
- continue;
- }
- cptree(srcfile, dest);
- }
- return;
- }
- }
- //
- // Define the globals needed so the module loader can pick up this class.
- //
- var description = "Copy-based installation";
- var presentation = CopyPresentation;
- //
- // --------------------------------------------------------- Internal Functions
- //
|