Reorganize for syndicate/rkt port

This commit is contained in:
Tony Garnock-Jones 2021-06-10 21:42:23 +02:00
parent 832d95afe4
commit 3906953dd9
30 changed files with 412 additions and 71 deletions

View File

@ -1,7 +1,7 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@ -645,7 +645,7 @@ the "copyright" line and a pointer to where the full notice is found.
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
@ -664,11 +664,11 @@ might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
<https://www.gnu.org/licenses/why-not-lgpl.html>.

165
COPYING.LESSER Normal file
View File

@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

View File

@ -1,5 +1,24 @@
all:
raco make new-server.rkt
__ignored__ := $(shell ./setup.sh)
PACKAGES=syndicate-ssh
COLLECTS=syndicate-ssh
all: setup
clean:
find . -name compiled -type d | xargs rm -rf
find . -name '*.rkte' | xargs rm -rf
setup:
raco setup --check-pkg-deps --unused-pkg-deps $(COLLECTS)
link:
raco pkg install --link $(PACKAGES)
unlink:
raco pkg remove $(PACKAGES)
test: setup testonly
testonly:
raco test -p $(PACKAGES)

View File

@ -2,60 +2,16 @@
This is a [Racket](http://racket-lang.org/) implementation of the SSH
v2 protocol. It's written to work with
[Marketplace](https://github.com/tonyg/marketplace), but could readily
be adapted to work with other I/O substrates. (It originally used
Racket's `sync` and events directly.)
[Syndicate](https://syndicate-lang.org/), but could readily be adapted
to work with other I/O substrates. (It originally used Racket's `sync`
and events directly.)
The code is not quite fully separated into a reusable library yet: at
present, it is a hard-coded Racket REPL server. Changing this is
straightforward, but low-priority right now. Patches welcome!
## Copyright and Licence
## How to compile and run the code
Copyright 2010-2021 Tony Garnock-Jones <tonyg@leastfixedpoint.com>
You will need the latest **prerelease** version of Racket. Any version
newer than or equal to Racket 5.3.4.10 should work. Nightly-build
installers for Racket can be downloaded
[here](http://pre.racket-lang.org/installers/).
This program is distributed under the terms of the [LGPLv3
license](https://opensource.org/licenses/lgpl-3.0.html) or any later version.
Once you have Racket installed,
raco pkg install marketplace bitsyntax
to install Marketplace (note: will take a long time) and
[bitsyntax](https://github.com/tonyg/racket-bitsyntax/), and then
make
(or the equivalent, `raco make new-server.rkt`) to compile the SSH
code. Once it has compiled successfully,
racket new-server.rkt
will start the server running on `localhost` port 2322. Log in to the
server with
ssh localhost -p 2322
To enable debug output, try
MATRIX_LOG=info racket new-server.rkt
## Copyright and License
Copyright 2010, 2011, 2012, 2013 Tony Garnock-Jones <tonyg@ccs.neu.edu>
This file is part of marketplace-ssh.
marketplace-ssh is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
marketplace-ssh is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with marketplace-ssh. If not, see
<http://www.gnu.org/licenses/>.
Documentation is distributed under the terms of the [CC BY 4.0
license](https://creativecommons.org/licenses/by/4.0/).

142
fixcopyright.rkt Executable file
View File

@ -0,0 +1,142 @@
#!/usr/bin/env racket
#lang racket
;;; SPDX-License-Identifier: LGPL-3.0-or-later
;;; SPDX-FileCopyrightText: Copyright © 2021 Tony Garnock-Jones <tonyg@leastfixedpoint.com>
(require file/glob)
(require racket/date)
(define ((re p) i) (regexp-match p i))
(define ((re? p) i) (regexp-match? p i))
(define ((s p ins) i) (regexp-replace p i ins))
(define this-year (number->string (date-year (current-date))))
(define (get-git-config key)
(string-trim (with-output-to-string
(lambda () (system* "/usr/bin/env" "git" "config" "--get" key)))))
(define (is-tracked? f)
(call-with-output-file "/dev/null" #:exists 'append
(lambda (sink)
(parameterize ((current-error-port sink)
(current-output-port sink))
(system* "/usr/bin/env" "git" "ls-files" "--error-unmatch" f)))))
(define user-name (get-git-config "user.name"))
(define user-email (get-git-config "user.email"))
(define user (format "~a <~a>" user-name user-email))
(define (make-copyright who low [hi #f])
(if (and hi (not (string=? low hi)))
(format "Copyright © ~a-~a ~a" low hi who)
(format "Copyright © ~a ~a" low who)))
(define total-file-count 0)
(define total-changed-files 0)
(define dry-run? #f)
(define modify-untracked? #f)
(define (fix-files #:file-type-name file-type-name
#:file-pattern file-pattern
#:front-matter-re [front-matter-re #f]
#:leading-comment-re leading-comment-re
#:comment-prefix comment-prefix
#:file-filter [file-filter (lambda (x) #t)])
(define matched-files (filter file-filter (glob file-pattern)))
(define file-count (length matched-files))
(define changed-files 0)
(for [(file-number (in-naturals))
(f (in-list matched-files))]
(printf "~a [~a/~a] ~a ..." file-type-name file-number file-count f)
(flush-output)
(define all-lines (file->lines f))
(define-values (front-matter head tail)
(let*-values (((lines) all-lines)
((front-matter lines) (if front-matter-re
(splitf-at lines (re? front-matter-re))
(values '() lines)))
((head tail) (splitf-at lines (re? leading-comment-re))))
(values front-matter head tail)))
(let* ((head (map (s leading-comment-re "") head))
(head (map (lambda (l)
(match (regexp-match "^([^:]+): (.*)$" l)
[(list _ k v) (list k v)]
[#f (list #f l)]))
head))
(head (if (assoc "SPDX-FileCopyrightText" head)
head
(cons (list "SPDX-FileCopyrightText" (make-copyright user this-year)) head)))
(head (if (assoc "SPDX-License-Identifier" head)
head
(cons (list "SPDX-License-Identifier" "LGPL-3.0-or-later") head)))
(head (map (lambda (l)
(match l
[(list "SPDX-FileCopyrightText"
(and (regexp (regexp-quote user-name))
(regexp #px"(\\d{4})-\\d{4}" (list _ low))))
(list "SPDX-FileCopyrightText"
(make-copyright user low this-year))]
[(list "SPDX-FileCopyrightText"
(and (regexp (regexp-quote user-name))
(regexp #px"\\d{4}" (list low))))
(list "SPDX-FileCopyrightText"
(make-copyright user low this-year))]
[_ l]))
head))
(head (map (lambda (l)
(if (string=? (cadr l) "")
(string-trim comment-prefix)
(string-append comment-prefix
(match l
[(list #f v) v]
[(list k v) (format "~a: ~a" k v)]))))
head))
(new-lines `(,@front-matter
,@head
""
,@(dropf tail (lambda (l) (string=? (string-trim l) "")))))
(would-change-if-written? (not (equal? all-lines new-lines)))
(write-needed? (and would-change-if-written? (or modify-untracked? (is-tracked? f)))))
(when (and write-needed? (not dry-run?))
(call-with-atomic-output-file
f
(lambda (port _tmp-path)
(for [(l front-matter)] (displayln l port))
(for [(l head)] (displayln l port))
(newline port)
(for [(l (dropf tail (lambda (l) (string=? (string-trim l) ""))))] (displayln l port)))))
(if write-needed?
(begin (set! changed-files (+ changed-files 1))
(printf "\e[41mchanged\e[0m\n"))
(printf "\r\e[K"))))
(when (positive? changed-files)
(printf "~a [~a total files, ~a changed]\n" file-type-name file-count changed-files))
(set! total-file-count (+ total-file-count file-count))
(set! total-changed-files (+ total-changed-files changed-files)))
(command-line #:once-each
[("-n" "--dry-run") "Do not write back changes to files"
(set! dry-run? #t)]
[("--modify-untracked") "Modify files not tracked by git as well as those that are"
(set! modify-untracked? #t)])
(void (fix-files #:file-type-name "Racket"
#:file-pattern "**.rkt"
#:front-matter-re #px"^#"
#:leading-comment-re #px"^;+ *"
#:comment-prefix ";;; "))
(printf "fixcopyright: ~a files examined, ~a ~a\n"
total-file-count
total-changed-files
(if dry-run?
(if (zero? total-changed-files)
"changes are needed"
"files need to be updated")
(if (zero? total-changed-files)
"changes were needed"
"files were updated")))
(exit (if (positive? total-changed-files) 1 0))

4
git-hooks/pre-commit Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh
set -e
exec 1>&2
./fixcopyright.rkt -n

18
setup.sh Executable file
View File

@ -0,0 +1,18 @@
#!/bin/sh
#
# Set up a git checkout of this repository for local dev use.
exec 2>/dev/tty 1>&2
set -e
[ -d .git ] || exit 0
for fullhook in ./git-hooks/*
do
hook=$(basename "$fullhook")
[ -L .git/hooks/$hook ] || (
echo "Installing $hook hook"
ln -s ../../git-hooks/$hook .git/hooks/$hook
)
done

19
syndicate-ssh/info.rkt Normal file
View File

@ -0,0 +1,19 @@
;;; SPDX-License-Identifier: LGPL-3.0-or-later
;;; SPDX-FileCopyrightText: Copyright © 2021 Tony Garnock-Jones <tonyg@leastfixedpoint.com>
#lang setup/infotab
(define collection "syndicate-ssh")
(define deps '(
"base"
"bitsyntax"
"syndicate"
"preserves"
))
;; (define build-deps '("rackunit-lib"))
(define pre-install-collection "private/install.rkt")

View File

@ -0,0 +1,30 @@
#lang racket/base
;;; SPDX-License-Identifier: LGPL-3.0-or-later
;;; SPDX-FileCopyrightText: Copyright © 2021 Tony Garnock-Jones <tonyg@leastfixedpoint.com>
(provide pre-installer)
(require racket/runtime-path)
(require preserves-schema/bin/preserves-schema-rkt)
(require (only-in racket/file delete-directory/files))
(require (only-in syndicate/schema-compiler
schema-compiler-plugin
schema-compiler-plugin-mode))
(define (pre-installer _collects-path package-path)
(define output-directory (build-path package-path "schemas/gen"))
(delete-directory/files output-directory #:must-exist? #f)
(parameterize ((schema-compiler-plugin-mode 'meta))
(batch-compile #:inputs (list (build-path package-path "schemas/**.prs"))
#:additional-modules (hash '(EntityRef) 'syndicate/entity-ref)
#:output-directory output-directory
#:plugins (list schema-compiler-plugin))))
(define-runtime-path package-path "..")
(define (regenerate!)
(void (pre-installer 'not-bothering-to-figure-this-out-since-we-do-not-need-it
package-path)))
(module+ main
(regenerate!))

View File

@ -1,12 +0,0 @@
-----BEGIN DSA PRIVATE KEY-----
MIIBuwIBAAKBgQCEQ1YvOR7/MQByCPJt/FSO7NN7YO1VLqy7A95M07q6AaG5FZ2A
m9s8KZPlNFPrNhG8pRxxHhWgfBczoIObZi2saXeXQyTCUtHUejQBk+Xl31I+0SYU
/m5fIP3Q9UY3cR8LucsIQkJIcuLVpoMmtFA/EtxYs+roxm+wtMlgk/8HkQIVAObN
DEIjvgKwW9MKzRz8VXms/aDDAoGAeMnKQxj/iBSfQ3Wsd4ipCi3PdoLJ0+TJuiFG
0tmbxLxwC0YCR24YMeobva/SpSu6y48+2rjv9Wc9ZKwISbrdO6xrNgDJtoCZLGK+
C2DHEC3rBYFicOgpoysk/HsS/to3GtMnPyA2NJDR/cjUdgWBRg+4eAx1ZsVPjaJT
A5Z60tECgYAkhzk5oi/b3zxPEPoFYki2apR4mciJso/1mYvb6fpd+rzlihNrkFAA
LL+6uOofkyf32FIQhEN+JXDNMfaHreJkLPxGXIJ4FyUbrrZcxbmgJdh9NHd0L/mI
yIHlo+SImp1DLCEtRP1GwKv8Lm0/rFNpY/z5Os3qeXKw1swDvEMfywIVANtH4mhn
F6JfX/4/cJ4cpGlcgrWe
-----END DSA PRIVATE KEY-----