diff options
author | Leah Rowe <info@minifree.org> | 2017-06-28 14:06:20 +0000 |
---|---|---|
committer | Gogs <gogitservice@gmail.com> | 2017-06-28 14:06:20 +0000 |
commit | 7c65a068985ea28099db1725e3f6a920acf2cb4b (patch) | |
tree | 0744ba4b023a6c70d132db584e36a3cb044af006 /libs/common | |
parent | 3f32c13d5ac9159978556bc3fcfd73f39b4e218d (diff) | |
parent | 9a67491b91bfc476d8c1c30dc2932d1967fb6720 (diff) | |
download | librebootfr-7c65a068985ea28099db1725e3f6a920acf2cb4b.tar.gz librebootfr-7c65a068985ea28099db1725e3f6a920acf2cb4b.zip |
Merge branch 'source-tarball-support' of kragle/libreboot into master
Diffstat (limited to 'libs/common')
-rwxr-xr-x | libs/common | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/libs/common b/libs/common index d0fd1203..7898f115 100755 --- a/libs/common +++ b/libs/common @@ -64,16 +64,35 @@ arguments_list() { done } +download_wrapper() { + local download_dir="$1" + shift + local uris=($@) + + # TODO: Add support for curl, in addition + # to wget, for compatibility reasons + wget_options=( + --config=/dev/null + --secure-protocol=PFS + --directory-prefix="${download_dir}" + --continue + -- + ) + + wget "${wget_options[@]}" "${uris[@]}" +} + diff_patch_file() { local repository_path="$1" local patch_file_path="$2" - local filename_in_diff="$(sed -rne 's/^-{3} {1}(.*)$/\1/p' <"${patch_file_path}")" + # TODO: Improve handling of filenames to avoid gotchas w/ \n, \t, etc. + local filename_in_diff="$(sed -rne 's/^-{3}\s+([^ \r\n]*).*/\1/p' "${patch_file_path}")" local source_file_path - if ! ( grep -E '^-{3}.*/' <"${patch_file_path}" >/dev/null 2>&1 ); then - source_file_path="${repository_path}/${filename_in_diff##\ }" + if ! ( grep -E '^-{3}.*/' "${patch_file_path}" >/dev/null 2>&1 ); then + source_file_path="${repository_path}/${filename_in_diff}" else source_file_path="${repository_path}/${filename_in_diff##*/}" fi |