Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
cookbook
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
redox-os
cookbook
Commits
62f438cb
Commit
62f438cb
authored
1 year ago
by
Kivimango
Browse files
Options
Downloads
Patches
Plain Diff
clippy: Fix needless_borrows
parent
33d361d4
No related branches found
No related tags found
1 merge request
!297
Silence compiler warnings and clippy fixes
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/bin/cook.rs
+16
-16
16 additions, 16 deletions
src/bin/cook.rs
with
16 additions
and
16 deletions
src/bin/cook.rs
+
16
−
16
View file @
62f438cb
...
@@ -27,7 +27,7 @@ fn remove_all(path: &Path) -> Result<(), String> {
...
@@ -27,7 +27,7 @@ fn remove_all(path: &Path) -> Result<(), String> {
}
}
fn
create_dir
(
dir
:
&
Path
)
->
Result
<
(),
String
>
{
fn
create_dir
(
dir
:
&
Path
)
->
Result
<
(),
String
>
{
fs
::
create_dir
(
&
dir
)
.map_err
(|
err
|
format!
(
fs
::
create_dir
(
dir
)
.map_err
(|
err
|
format!
(
"failed to create '{}': {}
\n
{:?}"
,
"failed to create '{}': {}
\n
{:?}"
,
dir
.display
(),
dir
.display
(),
err
,
err
,
...
@@ -70,7 +70,7 @@ fn modified_dir_inner<F: FnMut(&DirEntry) -> bool>(dir: &Path, filter: F) -> io:
...
@@ -70,7 +70,7 @@ fn modified_dir_inner<F: FnMut(&DirEntry) -> bool>(dir: &Path, filter: F) -> io:
}
}
fn
modified_dir
(
dir
:
&
Path
)
->
Result
<
SystemTime
,
String
>
{
fn
modified_dir
(
dir
:
&
Path
)
->
Result
<
SystemTime
,
String
>
{
modified_dir_inner
(
&
dir
,
|
_
|
true
)
.map_err
(|
err
|
format!
(
modified_dir_inner
(
dir
,
|
_
|
true
)
.map_err
(|
err
|
format!
(
"failed to get modified time of '{}': {}
\n
{:#?}"
,
"failed to get modified time of '{}': {}
\n
{:#?}"
,
dir
.display
(),
dir
.display
(),
err
,
err
,
...
@@ -79,7 +79,7 @@ fn modified_dir(dir: &Path) -> Result<SystemTime, String> {
...
@@ -79,7 +79,7 @@ fn modified_dir(dir: &Path) -> Result<SystemTime, String> {
}
}
fn
modified_dir_ignore_git
(
dir
:
&
Path
)
->
Result
<
SystemTime
,
String
>
{
fn
modified_dir_ignore_git
(
dir
:
&
Path
)
->
Result
<
SystemTime
,
String
>
{
modified_dir_inner
(
&
dir
,
|
entry
|
{
modified_dir_inner
(
dir
,
|
entry
|
{
entry
.file_name
()
.to_str
()
.map
(|
s
|
s
!=
".git"
)
.unwrap_or
(
true
)
entry
.file_name
()
.to_str
()
.map
(|
s
|
s
!=
".git"
)
.unwrap_or
(
true
)
})
.map_err
(|
err
|
format!
(
})
.map_err
(|
err
|
format!
(
"failed to get modified time of '{}': {}
\n
{:#?}"
,
"failed to get modified time of '{}': {}
\n
{:#?}"
,
...
@@ -172,9 +172,9 @@ fn fetch(recipe_dir: &Path, source: &Option<SourceRecipe>) -> Result<PathBuf, St
...
@@ -172,9 +172,9 @@ fn fetch(recipe_dir: &Path, source: &Option<SourceRecipe>) -> Result<PathBuf, St
// Clone the repository to source.tmp
// Clone the repository to source.tmp
let
mut
command
=
Command
::
new
(
"git"
);
let
mut
command
=
Command
::
new
(
"git"
);
command
.arg
(
"clone"
)
.arg
(
"--recursive"
)
.arg
(
&
git
);
command
.arg
(
"clone"
)
.arg
(
"--recursive"
)
.arg
(
git
);
if
let
Some
(
branch
)
=
branch
{
if
let
Some
(
branch
)
=
branch
{
command
.arg
(
"--branch"
)
.arg
(
&
branch
);
command
.arg
(
"--branch"
)
.arg
(
branch
);
}
}
command
.arg
(
&
source_dir_tmp
);
command
.arg
(
&
source_dir_tmp
);
run_command
(
command
)
?
;
run_command
(
command
)
?
;
...
@@ -194,7 +194,7 @@ fn fetch(recipe_dir: &Path, source: &Option<SourceRecipe>) -> Result<PathBuf, St
...
@@ -194,7 +194,7 @@ fn fetch(recipe_dir: &Path, source: &Option<SourceRecipe>) -> Result<PathBuf, St
// Reset origin
// Reset origin
let
mut
command
=
Command
::
new
(
"git"
);
let
mut
command
=
Command
::
new
(
"git"
);
command
.arg
(
"-C"
)
.arg
(
&
source_dir
);
command
.arg
(
"-C"
)
.arg
(
&
source_dir
);
command
.arg
(
"remote"
)
.arg
(
"set-url"
)
.arg
(
"origin"
)
.arg
(
&
git
);
command
.arg
(
"remote"
)
.arg
(
"set-url"
)
.arg
(
"origin"
)
.arg
(
git
);
run_command
(
command
)
?
;
run_command
(
command
)
?
;
// Fetch origin
// Fetch origin
...
@@ -215,7 +215,7 @@ fn fetch(recipe_dir: &Path, source: &Option<SourceRecipe>) -> Result<PathBuf, St
...
@@ -215,7 +215,7 @@ fn fetch(recipe_dir: &Path, source: &Option<SourceRecipe>) -> Result<PathBuf, St
// Check out specified revision
// Check out specified revision
let
mut
command
=
Command
::
new
(
"git"
);
let
mut
command
=
Command
::
new
(
"git"
);
command
.arg
(
"-C"
)
.arg
(
&
source_dir
);
command
.arg
(
"-C"
)
.arg
(
&
source_dir
);
command
.arg
(
"checkout"
)
.arg
(
&
rev
);
command
.arg
(
"checkout"
)
.arg
(
rev
);
run_command
(
command
)
?
;
run_command
(
command
)
?
;
}
else
{
}
else
{
//TODO: complicated stuff to check and reset branch to origin
//TODO: complicated stuff to check and reset branch to origin
...
@@ -259,7 +259,7 @@ fi"#);
...
@@ -259,7 +259,7 @@ fi"#);
let
source_tar_tmp
=
recipe_dir
.join
(
"source.tar.tmp"
);
let
source_tar_tmp
=
recipe_dir
.join
(
"source.tar.tmp"
);
let
mut
command
=
Command
::
new
(
"wget"
);
let
mut
command
=
Command
::
new
(
"wget"
);
command
.arg
(
&
tar
);
command
.arg
(
tar
);
command
.arg
(
"-O"
)
.arg
(
&
source_tar_tmp
);
command
.arg
(
"-O"
)
.arg
(
&
source_tar_tmp
);
run_command
(
command
)
?
;
run_command
(
command
)
?
;
...
@@ -328,7 +328,7 @@ fi"#);
...
@@ -328,7 +328,7 @@ fi"#);
// Apply patches
// Apply patches
for
patch_name
in
patches
{
for
patch_name
in
patches
{
let
patch_file
=
recipe_dir
.join
(
&
patch_name
);
let
patch_file
=
recipe_dir
.join
(
patch_name
);
if
!
patch_file
.is_file
()
{
if
!
patch_file
.is_file
()
{
return
Err
(
format!
(
return
Err
(
format!
(
"failed to find patch file '{}'"
,
"failed to find patch file '{}'"
,
...
@@ -376,7 +376,7 @@ fi"#);
...
@@ -376,7 +376,7 @@ fi"#);
}
}
fn
build
(
recipe_dir
:
&
Path
,
source_dir
:
&
Path
,
target_dir
:
&
Path
,
build
:
&
BuildRecipe
)
->
Result
<
PathBuf
,
String
>
{
fn
build
(
recipe_dir
:
&
Path
,
source_dir
:
&
Path
,
target_dir
:
&
Path
,
build
:
&
BuildRecipe
)
->
Result
<
PathBuf
,
String
>
{
let
source_modified
=
modified_dir_ignore_git
(
&
source_dir
)
?
;
let
source_modified
=
modified_dir_ignore_git
(
source_dir
)
?
;
let
sysroot_dir
=
target_dir
.join
(
"sysroot"
);
let
sysroot_dir
=
target_dir
.join
(
"sysroot"
);
// Rebuild sysroot if source is newer
// Rebuild sysroot if source is newer
...
@@ -603,11 +603,11 @@ fn package(_recipe_dir: &Path, stage_dir: &Path, target_dir: &Path, _package: &P
...
@@ -603,11 +603,11 @@ fn package(_recipe_dir: &Path, stage_dir: &Path, target_dir: &Path, _package: &P
create_dir
(
Path
::
new
(
"build"
))
?
;
create_dir
(
Path
::
new
(
"build"
))
?
;
}
}
let
(
public_key
,
secret_key
)
=
pkgar_keys
::
SecretKeyFile
::
new
();
let
(
public_key
,
secret_key
)
=
pkgar_keys
::
SecretKeyFile
::
new
();
public_key
.save
(
&
public_path
)
.map_err
(|
err
|
format!
(
public_key
.save
(
public_path
)
.map_err
(|
err
|
format!
(
"failed to save pkgar public key: {:?}"
,
"failed to save pkgar public key: {:?}"
,
err
err
))
?
;
))
?
;
secret_key
.save
(
&
secret_path
)
.map_err
(|
err
|
format!
(
secret_key
.save
(
secret_path
)
.map_err
(|
err
|
format!
(
"failed to save pkgar secret key: {:?}"
,
"failed to save pkgar secret key: {:?}"
,
err
err
))
?
;
))
?
;
...
@@ -617,7 +617,7 @@ fn package(_recipe_dir: &Path, stage_dir: &Path, target_dir: &Path, _package: &P
...
@@ -617,7 +617,7 @@ fn package(_recipe_dir: &Path, stage_dir: &Path, target_dir: &Path, _package: &P
// Rebuild package if stage is newer
// Rebuild package if stage is newer
//TODO: rebuild on recipe changes
//TODO: rebuild on recipe changes
if
package_file
.is_file
()
{
if
package_file
.is_file
()
{
let
stage_modified
=
modified_dir
(
&
stage_dir
)
?
;
let
stage_modified
=
modified_dir
(
stage_dir
)
?
;
if
modified
(
&
package_file
)
?
<
stage_modified
{
if
modified
(
&
package_file
)
?
<
stage_modified
{
eprintln!
(
"DEBUG: '{}' newer than '{}'"
,
stage_dir
.display
(),
package_file
.display
());
eprintln!
(
"DEBUG: '{}' newer than '{}'"
,
stage_dir
.display
(),
package_file
.display
());
remove_all
(
&
package_file
)
?
;
remove_all
(
&
package_file
)
?
;
...
@@ -638,7 +638,7 @@ fn package(_recipe_dir: &Path, stage_dir: &Path, target_dir: &Path, _package: &P
...
@@ -638,7 +638,7 @@ fn package(_recipe_dir: &Path, stage_dir: &Path, target_dir: &Path, _package: &P
}
}
fn
cook
(
recipe_dir
:
&
Path
,
recipe
:
&
Recipe
,
fetch_only
:
bool
)
->
Result
<
(),
String
>
{
fn
cook
(
recipe_dir
:
&
Path
,
recipe
:
&
Recipe
,
fetch_only
:
bool
)
->
Result
<
(),
String
>
{
let
source_dir
=
fetch
(
&
recipe_dir
,
&
recipe
.source
)
.map_err
(|
err
|
format!
(
let
source_dir
=
fetch
(
recipe_dir
,
&
recipe
.source
)
.map_err
(|
err
|
format!
(
"failed to fetch: {}"
,
"failed to fetch: {}"
,
err
err
))
?
;
))
?
;
...
@@ -654,12 +654,12 @@ fn cook(recipe_dir: &Path, recipe: &Recipe, fetch_only: bool) -> Result<(), Stri
...
@@ -654,12 +654,12 @@ fn cook(recipe_dir: &Path, recipe: &Recipe, fetch_only: bool) -> Result<(), Stri
create_dir
(
&
target_dir
)
?
;
create_dir
(
&
target_dir
)
?
;
}
}
let
stage_dir
=
build
(
&
recipe_dir
,
&
source_dir
,
&
target_dir
,
&
recipe
.build
)
.map_err
(|
err
|
format!
(
let
stage_dir
=
build
(
recipe_dir
,
&
source_dir
,
&
target_dir
,
&
recipe
.build
)
.map_err
(|
err
|
format!
(
"failed to build: {}"
,
"failed to build: {}"
,
err
err
))
?
;
))
?
;
let
_package_file
=
package
(
&
recipe_dir
,
&
stage_dir
,
&
target_dir
,
&
recipe
.package
)
.map_err
(|
err
|
format!
(
let
_package_file
=
package
(
recipe_dir
,
&
stage_dir
,
&
target_dir
,
&
recipe
.package
)
.map_err
(|
err
|
format!
(
"failed to package: {}"
,
"failed to package: {}"
,
err
err
))
?
;
))
?
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment