summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/download/download.sty
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2013-05-27 01:18:37 +0000
committerNorbert Preining <preining@logic.at>2013-05-27 01:18:37 +0000
commita310e63ad62aa521c7903a0f499d8b9ca8124681 (patch)
tree54a54baa1e4fdd014deb68f29cd588cec1dc742c /Master/texmf-dist/tex/latex/download/download.sty
parent80af0e83ea533c7c67db7401adac8e12eaa5292e (diff)
download 5/27 (from tds)
git-svn-id: svn://tug.org/texlive/trunk@30695 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/download/download.sty')
-rw-r--r--Master/texmf-dist/tex/latex/download/download.sty116
1 files changed, 75 insertions, 41 deletions
diff --git a/Master/texmf-dist/tex/latex/download/download.sty b/Master/texmf-dist/tex/latex/download/download.sty
index c6b607fa522..c6f28829663 100644
--- a/Master/texmf-dist/tex/latex/download/download.sty
+++ b/Master/texmf-dist/tex/latex/download/download.sty
@@ -1,7 +1,7 @@
%% This is file `download.sty', generated from `download.tex' (key `package').
%% download - download files with LaTeX
%%
-%% Copyright (C) 2012 by Simon Sigurdhsson <sigurdhsson@gmail.com>
+%% Copyright (C) 2012-2013 by Simon Sigurdhsson <sigurdhsson@gmail.com>
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
@@ -20,15 +20,17 @@
\RequirePackage{expl3,l3keys2e,pdftexcmds,xparse}
\ProvidesExplPackage{download}
- {2012/12/31}{1.0}{download files with LaTeX}
+ {2013/04/08}{1.1}{download files with LaTeX}
\msg_new:nnnn{download}{no-write18}{Could~not~use~\string\write18!}
{Please~run~`latex`~with~the~`--shell-escape`~flag.}
-\msg_new:nnnn{download}{no-engine}{Could~not~find~cURL~or~wget!}
- {Please~make~sure~either~cURL~or~wget~is~installed~and~in~your~PATH.}
+\msg_new:nnnn{download}{no-engine}{Could~not~find~any~engine!}
+ {Please~make~sure~one~of~the~engines~is~installed~and~in~your~PATH.}
\msg_new:nnnn{download}{no-name}{Using~\string\download\space~with~no~filename!}
{This~means~I~will~download~the~file~even~if~it~already~exists.}
\msg_new:nnn{download}{use-curl}{Using~cURL.}
\msg_new:nnn{download}{use-wget}{Using~wget.}
+\msg_new:nnn{download}{use-ariaII}{Using~aria2.}
+\msg_new:nnn{download}{use-axel}{Using~axel.}
\prg_new_conditional:Nnn\__download_if_shellescape:{F}{
\if_cs_exist:N\pdf@shellescape
\if_int_compare:w\pdf@shellescape=\c_one
@@ -43,37 +45,20 @@
\cs_new:Npn\__download_rm:n#1{
\immediate\write18{rm~#1}
}
-\prg_new_conditional:Nnn\__download_if_curl_test:{TF,T,F,p}{
- \immediate\write18{which~curl~&&~touch~\jobname.aex}
- \bool_set:Nn\l_tmpa_bool{\c_false_bool}
+\prg_new_conditional:Npnn\__download_if_executable_test:n#1{TF,T,F,p}{
+ \immediate\write18{which~#1~&&~touch~\jobname.aex}
\file_if_exist:nTF{\jobname.aex}{
\__download_rm:n{\jobname.aex}
- \bool_set:Nn\l_tmpa_bool{\c_true_bool}
- }{}
- \if_bool:N\l_tmpa_bool
\prg_return_true:
- \else:
- \prg_return_false:
- \fi:
-}
-\prg_new_conditional:Nnn\__download_if_wget_test:{TF,T,F,p}{
- \immediate\write18{which~wget~&&~touch~\jobname.aex}
- \bool_set:Nn\l_tmpa_bool{\c_false_bool}
- \file_if_exist:nTF{\jobname.aex}{
- \__download_rm:n{\jobname.aex}
- \bool_set:Nn\l_tmpa_bool{\c_true_bool}
- }{}
- \if_bool:N\l_tmpa_bool
- \prg_return_true:
- \else:
+ }{
\prg_return_false:
- \fi:
+ }
}
\cs_new:Npn\__download_curl_do:nn#1#2{
\IfNoValueTF{#1}{
- \immediate\write18{curl~-s~#2}
+ \immediate\write18{curl~-L~-s~#2}
}{
- \immediate\write18{curl~-s~-o~#1~#2}
+ \immediate\write18{curl~-L~-s~-o~#1~#2}
}
}
\cs_new:Npn\__download_wget_do:nn#1#2{
@@ -83,36 +68,85 @@
\immediate\write18{wget~-q~-nc~-O~#1~#2}
}
}
-\prg_new_conditional:Nnn\__download_if_auto_test:{F}{
- \bool_set:Nn\l_tmpb_bool{\c_false_bool}
- \__download_if_curl_test:T{\bool_set:Nn\l_tmpb_bool{\c_true_bool}}
- \__download_if_wget_test:T{\bool_set:Nn\l_tmpb_bool{\c_true_bool}}
- \if_bool:N\l_tmpb_bool
+\cs_new:Npn\__download_ariaII_do:nn#1#2{
+ \IfNoValueTF{#1}{
+ \immediate\write18{aria2c~-q~--auto-file-renaming=false~#2}
+ }{
+ \immediate\write18{aria2c~-q~--auto-file-renaming=false~-o~#1~#2}
+ }
+}
+\cs_new:Npn\__download_axel_do:nn#1#2{
+ \IfNoValueTF{#1}{
+ \immediate\write18{axel~-q~#2}
+ }{
+ \immediate\write18{axel~-q~-o~#1~#2}
+ }
+}
+\prg_new_conditional:Nnn\__download_if_auto_test:{F,TF}{
+ \__download_if_executable_test:nTF{wget}{
\prg_return_true:
- \else:
- \prg_return_false:
- \fi:
+ }{
+ \__download_if_executable_test:nTF{curl}{
+ \prg_return_true:
+ }{
+ \__download_if_executable_test:nTF{aria2c}{
+ \prg_return_true:
+ }{
+ \__download_if_executable_test:nTF{axel}{
+ \prg_return_true:
+ }{
+ \prg_return_false:
+ }
+ }
+ }
+ }
}
\cs_new:Npn\__download_auto_do:nn#1#2{
- \__download_if_wget_test:TF{
+ \__download_if_executable_test:nTF{wget}{
\msg_info:nn{download}{use-wget}
\__download_wget_do:nn{#1}{#2}
}{
- \msg_info:nn{download}{use-curl}
- \__download_curl_do:nn{#1}{#2}
+ \__download_if_executable_test:nTF{curl}{
+ \msg_info:nn{download}{use-curl}
+ \__download_curl_do:nn{#1}{#2}
+ }{
+ \__download_if_executable_test:nTF{aria2c}{
+ \msg_info:nn{download}{use-ariaII}
+ \__download_ariaII_do:nn{#1}{#2}
+ }{
+ \msg_info:nn{download}{use-axel}
+ \__download_axel_do:nn{#1}{#2}
+ }
+ }
}
}
\keys_define:nn{download}{
engine .choice:,
engine / auto .code:n =
{\cs_gset_eq:NN\__download_do:nn\__download_auto_do:nn
- \prg_new_eq_conditional:NNn\__download_if_test:\__download_if_auto_test:{F}},
+ \prg_set_conditional:Nnn\__download_if_test:{F}{
+ \__download_if_auto_test:TF
+ {\prg_return_true:}{\prg_return_false:}}},
engine / curl .code:n =
{\cs_gset_eq:NN\__download_do:nn\__download_curl_do:nn
- \prg_new_eq_conditional:NNn\__download_if_test:\__download_if_curl_test:{F}},
+ \prg_set_conditional:Nnn\__download_if_test:{F}{
+ \__download_if_executable_test:nTF{curl}
+ {\prg_return_true:}{\prg_return_false:}}},
engine / wget .code:n =
{\cs_gset_eq:NN\__download_do:nn\__download_wget_do:nn
- \prg_new_eq_conditional:NNn\__download_if_test:\__download_if_wget_test:{F}},
+ \prg_set_conditional:Nnn\__download_if_test:{F}{
+ \__download_if_executable_test:nTF{wget}
+ {\prg_return_true:}{\prg_return_false:}}},
+ engine / aria2 .code:n =
+ {\cs_gset_eq:NN\__download_do:nn\__download_ariaII_do:nn
+ \prg_set_conditional:Nnn\__download_if_test:{F}{
+ \__download_if_executable_test:nTF{aria2c}
+ {\prg_return_true:}{\prg_return_false:}}},
+ engine / axel .code:n =
+ {\cs_gset_eq:NN\__download_do:nn\__download_axel_do:nn
+ \prg_set_conditional:Nnn\__download_if_test:{F}{
+ \__download_if_executable_test:nTF{axel}
+ {\prg_return_true:}{\prg_return_false:}}},
engine .initial:n = auto,
engine .default:n = auto,
}