From e19d40383241ea889224f96bc27b26aeeeb505ea Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Wed, 13 Sep 2017 18:21:49 +0200 Subject: [PATCH] Remove dependency on Path::Tiny So it's usable on el6 --- README.md | 1 - patrix.spec | 1 - scripts/patrix | 13 +++++++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3e7cd94..7eea137 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,6 @@ It requires the following perl modules * File::Basename * File::MimeInfo * File::Spec - * Path::Tiny * Getopt::Long * URI::Escape * JSON diff --git a/patrix.spec b/patrix.spec index 07905c0..78c0baa 100644 --- a/patrix.spec +++ b/patrix.spec @@ -19,7 +19,6 @@ Requires: perl(JSON) Requires: perl(File::Basename) Requires: perl(File::MimeInfo) Requires: perl(File::Spec) -Requires: perl(Path::Tiny) Requires: perl(URI::Escape) Requires: perl(Term::ReadKey) Requires: perl(Hash::Merge::Simple) diff --git a/scripts/patrix b/scripts/patrix index 9c393ae..0604cc6 100644 --- a/scripts/patrix +++ b/scripts/patrix @@ -12,7 +12,6 @@ use File::MimeInfo; use File::Basename; use File::Spec; use URI::Escape; -use Path::Tiny; use Term::ReadKey; use Hash::Merge::Simple qw(merge); use Scalar::Util qw(looks_like_number); @@ -155,6 +154,16 @@ sub send_request { return $resp; } +# Read the content of a file +sub slurp { + my $file = shift; + open my $f, '<', $file or die; + local $/ = undef; + my $bytes = <$f>; + close $f; + return $bytes; +} + # Load values from the config file if it exists sub read_conf { my $cfg = Config::Simple->new; @@ -256,7 +265,7 @@ sub send_file { my $resp = send_request({ uri => $uri, content_type => mimetype($file), - content => path($file)->slurp_raw + content => slurp($file) }); debug("File upload response is\n" . to_json(from_json($resp->decoded_content), { pretty => 1 })); die "Error uploading file\n" unless ($resp->is_success);