Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,067 changes: 725 additions & 342 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
[package]
name = "lal"
version = "3.8.1"
version = "4.0.0"
authors = ["Eirik Albrigtsen <[email protected]>"]
description = "A strict, language-agnostic build system and dependency manager"
documentation = "http://lalbuild.github.io/lal"
license = "MIT"
categories = ["command-line-utilities"]
keywords = ["package", "dependency", "build", "docker", "artifactory"]
readme = "README.md"
autotests = false
edition = "2018"

[badges]
travis-ci = { repository = "lalbuild/lal", branch = "master" }
Expand All @@ -17,6 +19,7 @@ coveralls = { repository = "lalbuild/lal", branch = "master" }
doc = false
name = "lal"
path = "src/main.rs"
edition = "2018"

[[test]]
harness = false
Expand All @@ -28,6 +31,7 @@ chrono = "0.2"
clap = "2.27.1"
filetime = "0.1"
flate2 = "0.2"
fs2 = "0.4.2"
hyper = "0.10.9"
hyper-native-tls = "0.2.2"
log = "0.3.5"
Expand All @@ -42,13 +46,15 @@ serde_json = "1.0.8"
sha1 = "0.3.0"
tar = "0.4.10"
walkdir = "1.0.7"
dirs = "1.0"
bitflags = "1.0.4"

[dependencies.indicatif]
optional = true
version = "0.3.3"

[features]
default = ["progress"]
default = ["progress", "upgrade"]
progress = ["indicatif"]
upgrade = []

Expand Down
1 change: 1 addition & 0 deletions docs.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
set -ex

# NB: requires the ghp-import pip module
cargo doc
echo "<meta http-equiv=refresh content=0;url=lal/index.html>" > target/doc/index.html
ghp-import -n target/doc
Expand Down
76 changes: 40 additions & 36 deletions src/build.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use std::path::Path;
use std::fs;
use std::path::Path;

use shell;
use verify::verify;
use super::{ensure_dir_exists_fresh, output, Lockfile, Manifest, Container, Config, LalResult,
CliError, DockerRunFlags, ShellModes};

use super::{
ensure_dir_exists_fresh, output, CliError, Config, Container, DockerRunFlags, LalResult,
Lockfile, Manifest, ShellModes,
};
use crate::shell;
use crate::verify::{verify, Flags};

fn find_valid_build_script() -> LalResult<String> {
use std::os::unix::fs::PermissionsExt;
Expand Down Expand Up @@ -37,7 +38,6 @@ fn find_valid_build_script() -> LalResult<String> {
Ok(build_string.into())
}


/// Configurable build flags for `lal build`
pub struct BuildOptions {
/// Component to build if specified
Expand All @@ -54,11 +54,10 @@ pub struct BuildOptions {
pub sha: Option<String>,
/// Ignore verify failures
pub force: bool,
/// Use the `simple` verify algorithm
pub simple_verify: bool,
/// Flags used to tweak the verification algorithm
pub verify_flags: Flags,
}


/// Runs the `./BUILD` script in a container and packages artifacts.
///
/// The function performs basic sanity checks, before shelling out to `docker run`
Expand All @@ -68,31 +67,30 @@ pub fn build(
cfg: &Config,
manifest: &Manifest,
opts: &BuildOptions,
envname: String,
_modes: ShellModes,
envname: &str,
mut modes: ShellModes,
) -> LalResult<()> {
let mut modes = _modes;

// have a better warning on first file-io operation
// if nfs mounts and stuff cause issues this usually catches it
ensure_dir_exists_fresh("./OUTPUT")
.map_err(|e| {
error!("Failed to clean out OUTPUT dir: {}", e);
e
})?;
ensure_dir_exists_fresh("./OUTPUT").map_err(|e| {
error!("Failed to clean out OUTPUT dir: {}", e);
e
})?;

debug!("Version flag is {:?}", opts.version);

// Verify INPUT
let mut verify_failed = false;
if let Some(e) = verify(manifest, &envname, opts.simple_verify).err() {
if !opts.force {
return Err(e);
let verify_failed = {
if let Some(e) = verify(manifest, &envname, opts.verify_flags).err() {
if !opts.force {
return Err(e);
}
warn!("Verify failed - build will fail on jenkins, but continuing");
true
} else {
false
}
verify_failed = true;
warn!("Verify failed - build will fail on jenkins, but continuing");
}

};

let component = opts.name.clone().unwrap_or_else(|| manifest.name.clone());
debug!("Getting configurations for {}", component);
Expand All @@ -110,18 +108,24 @@ pub fn build(
} else {
component_settings.defaultConfig.clone()
};
if !component_settings.configurations.contains(&configuration_name) {
if !component_settings
.configurations
.contains(&configuration_name)
{
let ename = format!("{} not found in configurations list", configuration_name);
return Err(CliError::InvalidBuildConfiguration(ename));
}
let lockfile = Lockfile::new(&component,
&opts.container,
&envname,
opts.version.clone(),
Some(&configuration_name))
.set_default_env(manifest.environment.clone())
.attach_revision_id(opts.sha.clone())
.populate_from_input()?;
let lockfile = Lockfile::new(
&component,
&opts.container,
&envname,
opts.version.clone(),
Some(&configuration_name),
)
.with_channel(manifest.channel.clone())
.set_default_env(manifest.environment.clone())
.attach_revision_id(opts.sha.clone())
.populate_from_input()?;

let lockpth = Path::new("./OUTPUT/lockfile.json");
lockfile.write(lockpth)?; // always put a lockfile in OUTPUT at the start of a build
Expand Down
Loading