diff --git a/install.pl b/install.pl index 3a2c09c..5e0fcab 100644 --- a/install.pl +++ b/install.pl @@ -24,19 +24,23 @@ my $scripts = "$repo_dir/scripts"; chdir $scripts or die "Unable to change into $scripts: $!"; -print "Installing scripts"; +print "Installing scripts\n"; opendir(my $repo_scripts, $scripts) or die "Unable to open directory: $!"; my @script_files = grep { -f "$scripts/$_" } readdir($repo_scripts); closedir($repo_scripts); foreach my $file (@script_files) { - my $repo_file_path = "$repo_scripts/$file"; + my $repo_file_path = "$scripts/$file"; my $install_file_path = "$install_dir/$file"; + print "Repo file: $repo_file_path\n"; + print "Dest: $install_file_path\n"; + if (!-e $install_file_path || !compare_checksums($repo_file_path, $install_file_path)) { print "Copying $file...\n"; copy($repo_file_path, $install_file_path) or die "Copy failed: $!"; + chmod(0755, $install_file_path) or die "Failed to set execute permission: $!"; } else { print "Skipping $file (Checksum matched)\n"; } @@ -47,7 +51,15 @@ print "Ensure that $install_dir is in your PATH\n"; sub compare_checksums { my ($file1, $file2) = @_; - my $digest1 = Digest::MD5->new->addfile($file1)->hexdigest; - my $digest2 = Digest::MD5->new->addfile($file2)->hexdigest; + + open my $fh1, '<', $file1 or die "Could not open file $file1: $!"; + open my $fh2, '<', $file2 or die "Could not open file $file2: $!"; + + my $digest1 = Digest::MD5->new->addfile($fh1)->hexdigest; + my $digest2 = Digest::MD5->new->addfile($fh2)->hexdigest; + + close $fh1; + close $fh2; + return $digest1 eq $digest2; } \ No newline at end of file diff --git a/scripts/ds b/scripts/ds index 02e5796..5974432 100755 --- a/scripts/ds +++ b/scripts/ds @@ -1,5 +1,6 @@ #!/usr/bin/perl + # ds - calculate and display the size of a given directory in a human readable format # Copyright Frederick Boniface 2023 - fredboniface.co.uk # diff --git a/scripts/regain b/scripts/regain index bef2247..d3c1b10 100755 --- a/scripts/regain +++ b/scripts/regain @@ -1,5 +1,6 @@ #!/usr/bin/env python3 + # regain - search folders below working directory and call regainer on each album found # Copyright Frederick Boniface 2023 - fredboniface.co.uk # diff --git a/scripts/regainer.py b/scripts/regainer.py index 4bec33c..8aa6152 100644 --- a/scripts/regainer.py +++ b/scripts/regainer.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 + # regainer - advanced ReplayGain tagging # Copyright 2016 Calvin Walton #