Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: iliana destroyer of worlds <iweller@amazon.com>
- Loading branch information
Showing
8 changed files
with
610 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
/target | ||
**/*.rs.bk | ||
Cargo.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,9 @@ members = [ | |
"olpc-cjson", | ||
"tough", | ||
"tough_schema", | ||
"tuftool", | ||
] | ||
|
||
[profile.release] | ||
debug = 1 | ||
lto = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[package] | ||
name = "tuftool" | ||
version = "0.1.0" | ||
description = "Utility for creating and signing The Update Framework (TUF) repositories" | ||
authors = ["iliana destroyer of worlds <iweller@amazon.com>"] | ||
license = "MIT OR Apache-2.0" | ||
repository = "https://github.com/awslabs/tough" | ||
keywords = ["tuf", "update", "repository"] | ||
edition = "2018" | ||
|
||
[dependencies] | ||
chrono = "0.4.6" | ||
digest = "0.8.1" | ||
hex = "0.3.2" | ||
maplit = "1.0.1" | ||
pem = "0.6.0" | ||
rayon = "1.1" | ||
ring = { version = "0.16.7", features = ["std"] } | ||
serde = "1.0.99" | ||
serde_json = "1.0.39" | ||
sha2 = "0.8.0" | ||
snafu = { version = "0.5.0", features = ["backtrace-crate"] } | ||
structopt = "0.2.18" | ||
tough_schema = { version = "0.1.0", path = "../tough_schema" } | ||
olpc-cjson = { version = "0.1.0", path = "../olpc-cjson" } | ||
walkdir = "2.2.9" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: MIT OR Apache-2.0 | ||
|
||
use std::fmt::{self, Display}; | ||
use std::fs::{self}; | ||
use std::path::Path; | ||
|
||
#[derive(Debug, Clone, Copy)] | ||
pub(crate) enum Copylike { | ||
Copy, | ||
Hardlink, | ||
Symlink, | ||
} | ||
|
||
impl Copylike { | ||
pub(crate) fn run<P: AsRef<Path>, Q: AsRef<Path>>(self, src: P, dst: Q) -> std::io::Result<()> { | ||
if let Some(parent) = dst.as_ref().parent() { | ||
fs::create_dir_all(parent)?; | ||
} | ||
match self { | ||
Copylike::Copy => fs::copy(src, dst).map(|_| ()), | ||
Copylike::Hardlink => fs::hard_link(src, dst), | ||
Copylike::Symlink => { | ||
#[cfg(unix)] | ||
{ | ||
std::os::unix::fs::symlink(src, dst) | ||
} | ||
|
||
#[cfg(windows)] | ||
{ | ||
std::os::windows::fs::symlink_file(src, dst) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
impl Display for Copylike { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
write!( | ||
f, | ||
"{}", | ||
match self { | ||
Copylike::Copy => "copy", | ||
Copylike::Hardlink => "hardlink", | ||
Copylike::Symlink => "symlink", | ||
} | ||
) | ||
} | ||
} |
Oops, something went wrong.