diff options
Diffstat (limited to 'hipis/packages/source')
-rw-r--r-- | hipis/packages/source/hwp/hwp.scm | 21 | ||||
-rw-r--r-- | hipis/packages/source/hwp/hwp/download.scm | 20 |
2 files changed, 34 insertions, 7 deletions
diff --git a/hipis/packages/source/hwp/hwp.scm b/hipis/packages/source/hwp/hwp.scm index 6770b5b..c497538 100644 --- a/hipis/packages/source/hwp/hwp.scm +++ b/hipis/packages/source/hwp/hwp.scm | |||
@@ -1,13 +1,20 @@ | |||
1 | (define-module (hwp) | 1 | (define-module (hwp) |
2 | #:use-module (hwp site) | 2 | #:use-module (hwp site) |
3 | #:use-module (hwp download) | ||
3 | #:use-module (hwp ui) | 4 | #:use-module (hwp ui) |
4 | #:use-module (ice-9 match) | 5 | #:use-module (ice-9 match) |
5 | #:export (hwp-run)) | 6 | #:export (hwp-build |
7 | hwp-run)) | ||
8 | |||
9 | |||
10 | (define (hwp-build url dest) | ||
11 | (define website-source-dir (download-curl url "/tmp")) | ||
12 | (hipis-site website-source-dir dest)) | ||
6 | 13 | ||
7 | (define (hwp-run args) | 14 | (define (hwp-run args) |
8 | (match args | 15 | (match args |
9 | ((cmd) | 16 | ((cmd) |
10 | (display "To create site: hwp-build [input-path] [output-path]") | 17 | (display "To create site: hwp-build [input-path] [output-path]") |
11 | (newline)) | 18 | (newline)) |
12 | ((cmd in out) | 19 | ((cmd in out) |
13 | (hipis-site in out)))) | 20 | (hipis-site in out)))) |
diff --git a/hipis/packages/source/hwp/hwp/download.scm b/hipis/packages/source/hwp/hwp/download.scm new file mode 100644 index 0000000..be4f292 --- /dev/null +++ b/hipis/packages/source/hwp/hwp/download.scm | |||
@@ -0,0 +1,20 @@ | |||
1 | (define-module (hwp download) | ||
2 | #:export (download-curl)) | ||
3 | |||
4 | |||
5 | (define (download-curl url dest) | ||
6 | (define file-name (basename url)) | ||
7 | (define compressed-file (string-append "/tmp/" file-name)) | ||
8 | |||
9 | (when (not (= (system* "curl" url "-o" compressed-file) 0)) | ||
10 | (error (string-append "Error: cannot download file: " url))) | ||
11 | |||
12 | (cond | ||
13 | ((or (string-suffix? "tar.gz" file-name) | ||
14 | (string-suffix? "tar.xz" file-name)) | ||
15 | (if (not (= (system* "tar" "-C" dest "-x" "-f" compressed-file) 0)) | ||
16 | (error (format #f "Error: when trying to decompress file: ~a in destination: ~a" | ||
17 | compressed-file dest)) | ||
18 | (string-append dest "/" (string-drop-right file-name 7)))) | ||
19 | (#t (error (string-append "Error: file with unspuported format: " dest))))) | ||
20 | |||