aaxtomp3: use resholve not PATH

Instead of wrapping out binary, we can patch the script to point
directly into /nix/store/. While doing this, we added a few dependencies
we missed and found an osh parsing bug that has been reported upstream.

See oilshell/oil#1446
This commit is contained in:
Colin Arnott 2023-01-08 03:39:10 +00:00
parent 71a885bf3b
commit 3cff1da834
No known key found for this signature in database
GPG Key ID: 0447A663F7F3E236
2 changed files with 64 additions and 23 deletions

View File

@ -1,31 +1,22 @@
{ coreutils
{ bash
, bc
, coreutils
, fetchFromGitHub
, ffmpeg
, findutils
, gawk
, gnugrep
, gnused
, jq
, lame
, lib
, makeWrapper
, mediainfo
, mp4v2
, stdenv
, ncurses
, resholve
}:
let
runtimeInputs = [
coreutils
ffmpeg
findutils
gnugrep
gnused
jq
lame
mediainfo
mp4v2
];
in
stdenv.mkDerivation rec {
resholve.mkDerivation rec {
pname = "aaxtomp3";
version = "1.3";
@ -36,17 +27,52 @@ stdenv.mkDerivation rec {
hash = "sha256-7a9ZVvobWH/gPxa3cFiPL+vlu8h1Dxtcq0trm3HzlQg=";
};
dontBuild = false;
# use whitespace to show osh arithmetic is not file redirection
# see: https://github.com/oilshell/oil/issues/1446
patches = [./osh.patch];
nativeBuildInputs = [ makeWrapper ];
postPatch = ''
substituteInPlace AAXtoMP3 \
--replace 'AAXtoMP3' 'aaxtomp3'
substituteInPlace interactiveAAXtoMP3 \
--replace 'AAXtoMP3' 'aaxtomp3' \
--replace 'call="./aaxtomp3"' 'call="$AAXTOMP3"'
'';
installPhase = ''
install -Dm755 AAXtoMP3 $out/bin/aaxtomp3
wrapProgram $out/bin/aaxtomp3 --prefix PATH : ${lib.makeBinPath runtimeInputs}
install -Dm755 interactiveAAXtoMP3 $out/bin/interactiveaaxtomp3
wrapProgram $out/bin/interactiveaaxtomp3 --prefix PATH : ${lib.makeBinPath runtimeInputs}
install -Dm 755 AAXtoMP3 $out/bin/aaxtomp3
install -Dm 755 interactiveAAXtoMP3 $out/bin/interactiveaaxtomp3
'';
solutions.default = {
scripts = [
"bin/aaxtomp3"
"bin/interactiveaaxtomp3"
];
interpreter = "${bash}/bin/bash";
inputs = [
bc
coreutils
ffmpeg
findutils
gawk
gnugrep
gnused
jq
lame
mediainfo
mp4v2
ncurses
];
keep."$call" = true;
fix = {
"$AAXTOMP3" = [ "${placeholder "out"}/bin/aaxtomp3" ];
"$FIND" = [ "find" ];
"$GREP" = [ "grep" ];
"$SED" = [ "sed" ];
};
};
meta = with lib; {
description = "Convert Audible's .aax filetype to MP3, FLAC, M4A, or OPUS";
homepage = "https://krumpetpirate.github.io/AAXtoMP3";

View File

@ -0,0 +1,15 @@
diff --git a/AAXtoMP3 b/AAXtoMP3
index 90566ad..71e94da 100755
--- a/AAXtoMP3
+++ b/AAXtoMP3
@@ -200,8 +200,8 @@ progressbar() {
#draw progressbar with one # for every 5% and blank spaces for the missing part.
progressbar=""
- for (( n=0; n<(percentage/5); n++ )) ; do progressbar="$progressbar#"; done
- for (( n=0; n<(20-(percentage/5)); n++ )) ; do progressbar="$progressbar "; done
+ for (( n=0; n< (percentage/5); n++ )) ; do progressbar="$progressbar#"; done
+ for (( n=0; n< (20-(percentage/5)); n++ )) ; do progressbar="$progressbar "; done
#print progressbar
echo -ne "Chapter splitting: |$progressbar| $print_percentage% ($part/$total chapters)\r"