<commit_before>#[cfg(unix)]
use crate::rootfs;
use crate::{accounts::{EtcGroupEntry,
                       EtcPasswdEntry},
            error::{Error,
                    Result},
            graph::Graph,
            util,
            BUSYBOX_IDENT,
            CACERTS_IDENT,
            VERSION};
use clap::{self,
           ArgMatches};
#[cfg(unix)]
use failure::SyncFailure;
use hab::license;
use habitat_common::{command::package::install::{InstallHookMode,
                                                 InstallMode,
                                                 InstallSource,
                                                 LocalPackageUsage},
                     ui::{Status,
                          UIWriter,
                          UI},
                     PROGRAM_NAME};
#[cfg(windows)]
use habitat_core::util::docker;
use habitat_core::{env,
                   fs::{cache_artifact_path,
                        CACHE_ARTIFACT_PATH,
                        CACHE_KEY_PATH,
                        CACHE_KEY_PATH_POSTFIX},
                   package::{FullyQualifiedPackageIdent,
                             PackageArchive,
                             PackageIdent,
                             PackageInstall},
                   url::default_bldr_url,
                   ChannelIdent};
#[cfg(unix)]
use std::os::unix::fs::symlink;
#[cfg(windows)]
use std::os::windows::fs::symlink_dir as symlink;
use std::{collections::HashMap,
          convert::TryFrom,
          fs as stdfs,
          path::{Path,
                 PathBuf},
          str::FromStr};
use tempfile::TempDir;

// Much of this functionality is duplicated (or slightly modified)
// in the tar exporter. This needs to be abstacted out in
// the future for use with further exporters.
// https://github.com/habitat-sh/habitat/issues/4522

#[cfg(unix)]
const DEFAULT_BASE_IMAGE: &str = "scratch";
#[cfg(windows)]
const DEFAULT_BASE_IMAGE: &str = "mcr.microsoft.com/windows/servercore";

const DEFAULT_HAB_IDENT: &str = "core/hab";
const DEFAULT_LAUNCHER_IDENT: &str = "core/hab-launcher";
const DEFAULT_SUP_IDENT: &str = "core/hab-sup";
const DEFAULT_USER_AND_GROUP_ID: u32 = 42;

const DEFAULT_HAB_UID: u32 = 84;
const DEFAULT_HAB_GID: u32 = 84;

fn default_base_image() -> Result<String> {
    #[cfg(unix)]
    {
        Ok(DEFAULT_BASE_IMAGE.to_string())
    }

    #[cfg(windows)]
    {
        Ok(format!("{}:{}",
                   DEFAULT_BASE_IMAGE,
                   docker::default_base_tag_for_host()?))
    }
}

/// The specification for creating a temporary file system build root, based on Habitat packages.
///
/// When a `BuildSpec` is created, a `BuildRoot` is returned which can be used to produce exported
/// images, archives, etc.
#[derive(Debug)]
pub struct BuildSpec {
    /// A string representation of a Habitat Package Identifer for the Habitat CLI package.
    pub hab:                String,<commit_msg>fixing another linux clippy error<commit_after>#[cfg(unix)]
use crate::rootfs;
use crate::{accounts::{EtcGroupEntry,
                       EtcPasswdEntry},
            error::{Error,
                    Result},
            graph::Graph,
            util,
            BUSYBOX_IDENT,
            CACERTS_IDENT,
            VERSION};
use clap::{self,
           ArgMatches};
#[cfg(unix)]
use failure::SyncFailure;
use hab::license;
use habitat_common::{command::package::install::{InstallHookMode,
                                                 InstallMode,
                                                 InstallSource,
                                                 LocalPackageUsage},
                     ui::{Status,
                          UIWriter,
                          UI},
                     PROGRAM_NAME};
#[cfg(windows)]
use habitat_core::util::docker;
use habitat_core::{env,
                   fs::{cache_artifact_path,
                        CACHE_ARTIFACT_PATH,
                        CACHE_KEY_PATH,
                        CACHE_KEY_PATH_POSTFIX},
                   package::{FullyQualifiedPackageIdent,
                             PackageArchive,
                             PackageIdent,
                             PackageInstall},
                   url::default_bldr_url,
                   ChannelIdent};
#[cfg(unix)]
use std::os::unix::fs::symlink;
#[cfg(windows)]
use std::os::windows::fs::symlink_dir as symlink;
use std::{collections::HashMap,
          convert::TryFrom,
          fs as stdfs,
          path::{Path,
                 PathBuf},
          str::FromStr};
use tempfile::TempDir;

// Much of this functionality is duplicated (or slightly modified)
// in the tar exporter. This needs to be abstacted out in
// the future for use with further exporters.
// https://github.com/habitat-sh/habitat/issues/4522

#[cfg(unix)]
const DEFAULT_BASE_IMAGE: &str = "scratch";
#[cfg(windows)]
const DEFAULT_BASE_IMAGE: &str = "mcr.microsoft.com/windows/servercore";

const DEFAULT_HAB_IDENT: &str = "core/hab";
const DEFAULT_LAUNCHER_IDENT: &str = "core/hab-launcher";
const DEFAULT_SUP_IDENT: &str = "core/hab-sup";
const DEFAULT_USER_AND_GROUP_ID: u32 = 42;

const DEFAULT_HAB_UID: u32 = 84;
const DEFAULT_HAB_GID: u32 = 84;

#[allow(clippy::unnecessary_wraps)]
fn default_base_image() -> Result<String> {
    #[cfg(unix)]
    {
        Ok(DEFAULT_BASE_IMAGE.to_string())
    }

    #[cfg(windows)]
    {
        Ok(format!("{}:{}",
                   DEFAULT_BASE_IMAGE,
                   docker::default_base_tag_for_host()?))
    }
}

/// The specification for creating a temporary file system build root, based on Habitat packages.
///
/// When a `BuildSpec` is created, a `BuildRoot` is returned which can be used to produce exported
/// images, archives, etc.
#[derive(Debug)]
pub struct BuildSpec {
    /// A string representation of a Habitat Package Identifer for the Habitat CLI package.
    pub hab:                String,
{'fraction_non_alphanumeric': 0.10954961056552659, 'fraction_numerical': 0.005418218760582459, 'mean_word_length': 1.870262390670554, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '923667', 'n_tokens_mistral': 1669, 'n_tokens_neox': 1627, 'n_words': 380}