diff --git a/Makefile b/Makefile index 38635582..e782b5a4 100644 --- a/Makefile +++ b/Makefile @@ -270,7 +270,8 @@ install: all $(INSTALL) -m0755 chibi-scheme$(EXE) $(DESTDIR)$(BINDIR)/ $(INSTALL) -m0755 tools/chibi-ffi $(DESTDIR)$(BINDIR)/ $(INSTALL) -m0755 tools/chibi-doc $(DESTDIR)$(BINDIR)/ - $(MKDIR) $(DESTDIR)$(MODDIR)/chibi/char-set $(DESTDIR)$(MODDIR)/chibi/crypto $(DESTDIR)$(MODDIR)/chibi/io $(DESTDIR)$(MODDIR)/chibi/iset $(DESTDIR)$(MODDIR)/chibi/loop $(DESTDIR)$(MODDIR)/chibi/match $(DESTDIR)$(MODDIR)/chibi/math $(DESTDIR)$(MODDIR)/chibi/monad $(DESTDIR)$(MODDIR)/chibi/net $(DESTDIR)$(MODDIR)/chibi/optimize $(DESTDIR)$(MODDIR)/chibi/parse $(DESTDIR)$(MODDIR)/chibi/show $(DESTDIR)$(MODDIR)/chibi/term + $(INSTALL) -m0755 tools/snow-chibi $(DESTDIR)$(BINDIR)/ + $(MKDIR) $(DESTDIR)$(MODDIR)/chibi/char-set $(DESTDIR)$(MODDIR)/chibi/crypto $(DESTDIR)$(MODDIR)/chibi/io $(DESTDIR)$(MODDIR)/chibi/iset $(DESTDIR)$(MODDIR)/chibi/loop $(DESTDIR)$(MODDIR)/chibi/match $(DESTDIR)$(MODDIR)/chibi/math $(DESTDIR)$(MODDIR)/chibi/monad $(DESTDIR)$(MODDIR)/chibi/net $(DESTDIR)$(MODDIR)/chibi/optimize $(DESTDIR)$(MODDIR)/chibi/parse $(DESTDIR)$(MODDIR)/chibi/show $(DESTDIR)$(MODDIR)/chibi/snow $(DESTDIR)$(MODDIR)/chibi/term $(MKDIR) $(DESTDIR)$(MODDIR)/scheme/char $(MKDIR) $(DESTDIR)$(MODDIR)/scheme/time $(MKDIR) $(DESTDIR)$(MODDIR)/srfi/1 $(DESTDIR)$(MODDIR)/srfi/18 $(DESTDIR)$(MODDIR)/srfi/27 $(DESTDIR)$(MODDIR)/srfi/33 $(DESTDIR)$(MODDIR)/srfi/39 $(DESTDIR)$(MODDIR)/srfi/69 $(DESTDIR)$(MODDIR)/srfi/95 $(DESTDIR)$(MODDIR)/srfi/99 $(DESTDIR)$(MODDIR)/srfi/99/records @@ -288,6 +289,7 @@ install: all $(INSTALL) -m0644 lib/chibi/optimize/*.sld lib/chibi/optimize/*.scm $(DESTDIR)$(MODDIR)/chibi/optimize/ $(INSTALL) -m0644 lib/chibi/parse/*.sld lib/chibi/parse/*.scm $(DESTDIR)$(MODDIR)/chibi/parse/ $(INSTALL) -m0644 lib/chibi/show/*.sld lib/chibi/show/*.scm $(DESTDIR)$(MODDIR)/chibi/show/ + $(INSTALL) -m0644 lib/chibi/snow/*.sld lib/chibi/snow/*.scm $(DESTDIR)$(MODDIR)/chibi/snow/ $(INSTALL) -m0644 lib/chibi/term/*.sld lib/chibi/term/*.scm $(DESTDIR)$(MODDIR)/chibi/term/ $(INSTALL) -m0644 lib/scheme/*.sld lib/scheme/*.scm $(DESTDIR)$(MODDIR)/scheme/ $(INSTALL) -m0644 lib/scheme/char/*.sld lib/scheme/char/*.scm $(DESTDIR)$(MODDIR)/scheme/char/ @@ -338,6 +340,7 @@ uninstall: -$(RM) $(DESTDIR)$(BINDIR)/chibi-scheme-static$(EXE) -$(RM) $(DESTDIR)$(BINDIR)/chibi-ffi -$(RM) $(DESTDIR)$(BINDIR)/chibi-doc + -$(RM) $(DESTDIR)$(BINDIR)/snow-chibi -$(RM) $(DESTDIR)$(SOLIBDIR)/libchibi-scheme$(SO) -$(RM) $(DESTDIR)$(SOLIBDIR)/libchibi-scheme$(SO).$(SOVERSION) -$(RM) $(DESTDIR)$(SOLIBDIR)/libchibi-scheme$(SO).$(SOVERSION_MAJOR) diff --git a/lib/snow/commands.scm b/lib/chibi/snow/commands.scm similarity index 100% rename from lib/snow/commands.scm rename to lib/chibi/snow/commands.scm diff --git a/lib/snow/commands.sld b/lib/chibi/snow/commands.sld similarity index 56% rename from lib/snow/commands.sld rename to lib/chibi/snow/commands.sld index b4d07d1f..6496a3eb 100644 --- a/lib/snow/commands.sld +++ b/lib/chibi/snow/commands.sld @@ -1,35 +1,31 @@ -(define-library (snow commands) - (export - command/package - command/gen-key - command/reg-key - command/sign - command/verify - command/upload - command/install - command/remove - command/search - command/show - command/status - command/update - command/upgrade - die - installed-libraries) - (import (except (chibi) equal? write display) - (scheme base) +(define-library (chibi snow commands) + (export command/package + command/gen-key + command/reg-key + command/sign + command/verify + command/upload + command/install + command/remove + command/search + command/show + command/status + command/update + command/upgrade) + (import (scheme base) (scheme eval) - (scheme write) (scheme file) + (scheme process-context) (scheme time) + (scheme write) (srfi 1) (srfi 27) (srfi 33) (srfi 95) - (srfi 98) - (snow interface) - (snow package) - (snow utils) + (chibi snow interface) + (chibi snow package) + (chibi snow utils) (chibi bytevector) (chibi config) (chibi crypto md5) diff --git a/lib/snow/interface.scm b/lib/chibi/snow/interface.scm similarity index 100% rename from lib/snow/interface.scm rename to lib/chibi/snow/interface.scm diff --git a/lib/snow/interface.sld b/lib/chibi/snow/interface.sld similarity index 89% rename from lib/snow/interface.sld rename to lib/chibi/snow/interface.sld index a64128fb..23d6819d 100644 --- a/lib/snow/interface.sld +++ b/lib/chibi/snow/interface.sld @@ -1,5 +1,5 @@ -(define-library (snow interface) +(define-library (chibi snow interface) (export warn info message die input input-number yes-or-no? restore-history save-history) (import (scheme base) (scheme char) (scheme read) (scheme write) diff --git a/lib/snow/package.scm b/lib/chibi/snow/package.scm similarity index 100% rename from lib/snow/package.scm rename to lib/chibi/snow/package.scm diff --git a/lib/snow/package.sld b/lib/chibi/snow/package.sld similarity index 93% rename from lib/snow/package.sld rename to lib/chibi/snow/package.sld index 0921273d..4ec95bca 100644 --- a/lib/snow/package.sld +++ b/lib/chibi/snow/package.sld @@ -1,5 +1,5 @@ -(define-library (snow package) +(define-library (chibi snow package) (export package? library? package-name package-email package-url package-version package-libraries package-provides? package-dependencies @@ -16,7 +16,7 @@ extract-rsa-private-key extract-rsa-public-key) (import (chibi) (srfi 1) - (snow interface) + (chibi snow interface) (chibi config) (chibi crypto md5) (chibi crypto rsa) diff --git a/lib/snow/utils.scm b/lib/chibi/snow/utils.scm similarity index 72% rename from lib/snow/utils.scm rename to lib/chibi/snow/utils.scm index 8f53c31b..c0d2edc3 100644 --- a/lib/snow/utils.scm +++ b/lib/chibi/snow/utils.scm @@ -1,17 +1,13 @@ -(define (file-sha256 file) - ;; openssl dgst -sha256 file - (let ((ls (string-split (process->string `("shasum" "-a" "256" ,file))))) - (and (pair? ls) (car ls)))) +;;> Copies the file \var{from} to \var{to}. -(define (copy-file src dst) - (system "cp" src dst)) - -(define (move-file src dst) - (system "mv" src dst)) - -;; TODO: check if the upstream has been modified -(define http-get-to-file/cached http-get-to-file) +(define (copy-file from to) + (let ((in (open-binary-input-file from)) + (out (open-binary-output-file to))) + (let lp () + (let ((n (read-u8 in))) + (cond ((eof-object? n) (close-input-port in) (close-output-port out)) + (else (write-u8 n out) (lp))))))) (define (call-with-temp-file template proc) (let ((base (string-append @@ -53,15 +49,5 @@ (lp (+ i 1))) ((create-directory path #o700) (let ((res (proc path))) - ;;(delete-file-hierarchy path) + (delete-file-hierarchy path) res))))))) - -(define (system-from-dir dir . cmd) - ;; alternately fork+cd+exec, or run a subshell with cd - (with-directory dir (lambda () (apply system cmd)))) - -(define (gzip-file src) - (system "gzip" "-c" src)) - -(define (gunzip-file src) - (system "gzip" "-d" "-c" src)) diff --git a/lib/chibi/snow/utils.sld b/lib/chibi/snow/utils.sld new file mode 100644 index 00000000..d0d1a262 --- /dev/null +++ b/lib/chibi/snow/utils.sld @@ -0,0 +1,12 @@ + +(define-library (chibi snow utils) + (export copy-file call-with-temp-file call-with-temp-dir) + (import (scheme base) + (scheme file) + (scheme time) + (srfi 33) + (chibi filesystem) + (chibi pathname) + (chibi process) + (chibi snow interface)) + (include "utils.scm")) diff --git a/lib/snow/utils.sld b/lib/snow/utils.sld deleted file mode 100644 index 5f52f0b3..00000000 --- a/lib/snow/utils.sld +++ /dev/null @@ -1,12 +0,0 @@ - -(define-library (snow utils) - (export copy-file move-file http-get-to-file/cached - call-with-temp-file call-with-temp-dir create-directory* - path-strip-leading-parents - file-sha256) - (import (scheme base) (scheme char) (scheme write) (scheme time) - (snow interface) - (srfi 1) (srfi 33) - (chibi string) (chibi pathname) (chibi uri) - (chibi filesystem) (chibi process) (chibi net http)) - (include "utils.scm")) diff --git a/lib/snow/snow b/tools/snow-chibi similarity index 94% rename from lib/snow/snow rename to tools/snow-chibi index a847ac9d..4b63db04 100755 --- a/lib/snow/snow +++ b/tools/snow-chibi @@ -3,11 +3,14 @@ ;; This code was written by Alex Shinn in 2013 and placed in the ;; Public Domain. All warranties are disclaimed. -(import (scheme base) (scheme char) (scheme read) (scheme write) - (scheme file) (scheme process-context) (srfi 1) - (snow commands) (snow library) (snow utils) (snow interface) - (chibi app) (chibi config) (chibi match) (chibi string) - (chibi pathname) (chibi filesystem) (chibi process)) +(import (scheme base) + (scheme process-context) + (chibi snow commands) + (chibi snow interface) + (chibi app) + (chibi config) + (chibi pathname) + (chibi process)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;