diff mbox series

[bug#51903] gnu: Add cl-cmn.

Message ID 20211117015205.19233-1-jgart@dismail.de
State Accepted
Headers show
Series [bug#51903] gnu: Add cl-cmn. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

jgart Nov. 17, 2021, 1:52 a.m. UTC
Hi Guixers,

This is a WIP.

I could use some help with it.

There are no releases and no version control.

CMN was written in the 90s and is still used today atleast by slippery-chicken (see below).

It currently builds successfully.

https://en.wikipedia.org/wiki/Common_Music_Notation  
https://ccrma.stanford.edu/software/cmn/cmn/cmn.html  

cmn is a dependency of slippery-chicken: 

https://github.com/mdedwards/slippery-chicken
http://michael-edwards.org/sc/

* gnu/packages/music.scm (cl-cmn): New variable.
---
 gnu/packages/music.scm | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

Comments

Pierre Neidhardt Nov. 17, 2021, 7:49 a.m. UTC | #1
Hi,

1. I believe you should place the lib in lisp-xyz.scm.

2. License is llgpl.

3. Then use the asdf-build-system/sbcl.
See the other sbcl- packages for reference.

Then define the cl- package with

--8<---------------cut here---------------start------------->8---
(define-public cl-cmn
  (sbcl-package->cl-source-package sbcl-cmn))
--8<---------------cut here---------------end--------------->8---

4. Since there are no version numbers, maybe use the date of the last
HISTORY.cmn entry, that is, 2016.8.17.

Hope that helps!
jgart Nov. 17, 2021, 8:50 a.m. UTC | #2
On Wed, 17 Nov 2021 08:49:48 +0100 Pierre Neidhardt <mail@ambrevar.xyz> wrote:
> Hi,
> 
> 1. I believe you should place the lib in lisp-xyz.scm.
> 
> 2. License is llgpl.
> 
> 3. Then use the asdf-build-system/sbcl.
> See the other sbcl- packages for reference.
> 
> Then define the cl- package with
> 
> --8<---------------cut here---------------start------------->8---
> (define-public cl-cmn
>   (sbcl-package->cl-source-package sbcl-cmn))
> --8<---------------cut here---------------end--------------->8---
> 
> 4. Since there are no version numbers, maybe use the date of the last
> HISTORY.cmn entry, that is, 2016.8.17.
> 
> Hope that helps!

Hi Pierre,

Thanks for the suggestions. Much appreciated!

This is the error I currently get:

;   READ error during COMPILE-FILE:
;
;     Package CMN does not exist.
;
;       Line: 174, Column: 33, File-Position: 6136
;
;       Stream: #<SB-INT:FORM-TRACKING-STREAM for "file /gnu/store/wdsfha38v8mg638y6ilxar1qjkg57fbg-sbcl-cmn-2016.8.17/share/common-lisp/sbcl/cmn/cmn-all.lisp" {10057D4A03}>

; compilation aborted after 0:00:00.004
Unhandled UIOP/LISP-BUILD:COMPILE-FILE-ERROR in thread #<SB-THREAD:THREAD "main thread" RUNNING
                                                          {1001858103}>:
  COMPILE-FILE-ERROR while compiling #<CL-SOURCE-FILE "cmn" "cmn-all">

Backtrace for: #<SB-THREAD:THREAD "main thread" RUNNING {1001858103}>
0: (SB-DEBUG::DEBUGGER-DISABLED-HOOK #<UIOP/LISP-BUILD:COMPILE-FILE-ERROR {100586FF53}> #<unused argument> :QUIT T)
1: (SB-DEBUG::RUN-HOOK *INVOKE-DEBUGGER-HOOK* #<UIOP/LISP-BUILD:COMPILE-FILE-ERROR {100586FF53}>)
2: (INVOKE-DEBUGGER #<UIOP/LISP-BUILD:COMPILE-FILE-ERROR {100586FF53}>)
3: (ERROR UIOP/LISP-BUILD:COMPILE-FILE-ERROR :CONTEXT-FORMAT "~/asdf-action::format-action/" :CONTEXT-ARGUMENTS ((#<ASDF/LISP-ACTION:COMPILE-OP > . #<ASDF/LISP-ACTION:CL-SOURCE-FILE "cmn" "cmn-all">)))
4: (UIOP/LISP-BUILD:CHECK-LISP-COMPILE-RESULTS NIL T T "~/asdf-action::format-action/" ((#<ASDF/LISP-ACTION:COMPILE-OP > . #<ASDF/LISP-ACTION:CL-SOURCE-FILE "cmn" "cmn-all">)))
5: ((SB-PCL::EMF ASDF/ACTION:PERFORM) #<unused argument> #<unused argument> #<ASDF/LISP-ACTION:COMPILE-OP > #<ASDF/LISP-ACTION:CL-SOURCE-FILE "cmn" "cmn-all">)
6: ((LAMBDA NIL :IN ASDF/ACTION:CALL-WHILE-VISITING-ACTION))
7: ((:METHOD ASDF/ACTION:PERFORM-WITH-RESTARTS :AROUND (T T)) #<ASDF/LISP-ACTION:COMPILE-OP > #<ASDF/LISP-ACTION:CL-SOURCE-FILE "cmn" "cmn-all">) [fast-method]
8: ((:METHOD ASDF/PLAN:PERFORM-PLAN (T)) #<ASDF/PLAN:SEQUENTIAL-PLAN {1005608293}>) [fast-method]
9: ((FLET SB-C::WITH-IT :IN SB-C::%WITH-COMPILATION-UNIT))
10: ((:METHOD ASDF/PLAN:PERFORM-PLAN :AROUND (T)) #<ASDF/PLAN:SEQUENTIAL-PLAN {1005608293}>) [fast-method]
11: ((:METHOD ASDF/OPERATE:OPERATE (ASDF/OPERATION:OPERATION ASDF/COMPONENT:COMPONENT)) #<ASDF/LISP-ACTION:COMPILE-OP > #<ASDF/SYSTEM:SYSTEM "cmn"> :PLAN-CLASS NIL :PLAN-OPTIONS NIL) [fast-method]
12: ((SB-PCL::EMF ASDF/OPERATE:OPERATE) #<unused argument> #<unused argument> #<ASDF/LISP-ACTION:COMPILE-OP > #<ASDF/SYSTEM:SYSTEM "cmn">)
13: ((LAMBDA NIL :IN ASDF/OPERATE:OPERATE))
14: ((:METHOD ASDF/OPERATE:OPERATE :AROUND (T T)) #<ASDF/LISP-ACTION:COMPILE-OP > #<ASDF/SYSTEM:SYSTEM "cmn">) [fast-method]
15: ((SB-PCL::EMF ASDF/OPERATE:OPERATE) #<unused argument> #<unused argument> ASDF/LISP-ACTION:COMPILE-OP "cmn")
16: ((LAMBDA NIL :IN ASDF/OPERATE:OPERATE))
17: ((:METHOD ASDF/OPERATE:OPERATE :AROUND (T T)) ASDF/LISP-ACTION:COMPILE-OP "cmn") [fast-method]
18: (ASDF/SESSION:CALL-WITH-ASDF-SESSION #<FUNCTION (LAMBDA NIL :IN ASDF/OPERATE:OPERATE) {10055FFBCB}> :OVERRIDE T :KEY NIL :OVERRIDE-CACHE T :OVERRIDE-FORCING NIL)
19: ((LAMBDA NIL :IN ASDF/OPERATE:OPERATE))
20: (ASDF/SESSION:CALL-WITH-ASDF-SESSION #<FUNCTION (LAMBDA NIL :IN ASDF/OPERATE:OPERATE) {10055E0D2B}> :OVERRIDE NIL :KEY NIL :OVERRIDE-CACHE NIL :OVERRIDE-FORCING NIL)
21: ((:METHOD ASDF/OPERATE:OPERATE :AROUND (T T)) ASDF/LISP-ACTION:COMPILE-OP "cmn") [fast-method]
22: (ASDF/OPERATE:COMPILE-SYSTEM "cmn")
23: (SB-INT:SIMPLE-EVAL-IN-LEXENV (ASDF/OPERATE:COMPILE-SYSTEM "cmn") #<NULL-LEXENV>)
24: (EVAL (ASDF/OPERATE:COMPILE-SYSTEM "cmn"))
25: (SB-IMPL::PROCESS-EVAL/LOAD-OPTIONS ((:EVAL . "(require :asdf)") (:EVAL . "(asdf:load-asd (truename \"/gnu/store/wdsfha38v8mg638y6ilxar1qjkg57fbg-sbcl-cmn-2016.8.17/share/common-lisp/sbcl/cmn/cmn.asd\"))") (:EVAL . "(asdf:compile-system \"cmn\")") (:QUIT)))
26: (SB-IMPL::TOPLEVEL-INIT)
27: ((FLET SB-UNIX::BODY :IN SB-IMPL::START-LISP))
28: ((FLET "WITHOUT-INTERRUPTS-BODY-1" :IN SB-IMPL::START-LISP))
29: (SB-IMPL::START-LISP)

unhandled condition in --disable-debugger mode, quitting
;
; compilation unit aborted
;   caught 2 fatal ERROR conditions
;   caught 1 ERROR condition
command "/gnu/store/42vycgb0gcyhhqsncyc5ybp83xwgp2dk-sbcl-2.1.9/bin/sbcl" "--non-interactive" "--eval" "(require :asdf)" "--eval" "(asdf:load-asd (truename \"/gnu/store/wdsfha38v8mg638y6ilxar1qjkg57fbg-sbcl-cmn-2016.8.17/share/common-lisp/sbcl/cmn/cmn.asd\"))" "--eval" "(asdf:compile-system \"cmn\")" failed with status 1
builder for `/gnu/store/0bz3b26x201mx7x1c6xmhyc98p04rhrs-sbcl-cmn-2016.8.17.drv' failed with exit code 1
build of /gnu/store/0bz3b26x201mx7x1c6xmhyc98p04rhrs-sbcl-cmn-2016.8.17.drv failed
Could not find build log for '/gnu/store/0bz3b26x201mx7x1c6xmhyc98p04rhrs-sbcl-cmn-2016.8.17.drv'.
guix build: error: build of `/gnu/store/0bz3b26x201mx7x1c6xmhyc98p04rhrs-sbcl-cmn-2016.8.17.drv' failed

Here's the package definition updated with the changes you requested:

```
(define-public sbcl-cmn
  (package
    (name "sbcl-cmn")
    (version "2016.8.17")
    (source
     (origin
       (method url-fetch)
       (uri (string-append "https://ccrma.stanford.edu/software/cmn/cmn"
                           ".tar.gz"))
       (sha256
        (base32
         "1f4ivhg1vq2fwklmwjj30bj7ij1yab45rnjjwps3qpsh0lpd6yj3"))
       (file-name (string-append name "-" version))))
    (build-system asdf-build-system/sbcl)
    (arguments
     `(#:asd-systems '("cmn")
       #:asd-files '("cmn.asd")))
    (home-page "https://ccrma.stanford.edu/software/cmn/")
    (synopsis "Western music notation package written in Common Lisp")
    (description
"CMN provides a package of functions to hierarchically describe a musical
score. When evaluated, the musical score is rendered to an image.")
    (license license:llgpl)))

(define-public cl-cmn
  (sbcl-package->cl-source-package sbcl-cmn))
```

Anything that might be wrong in the above?
Pierre Neidhardt Nov. 17, 2021, 9:24 a.m. UTC | #3
The build file "cmn-all.lisp" is broken.
I've managed to patch it, the following builds but I haven't tested if
the result works properly.

--8<---------------cut here---------------start------------->8---
(define-public sbcl-cmn
  (package
    (name "sbcl-cmn")
    (version "2016.8.17")
    (source
     (origin
       (method url-fetch)
       (uri (string-append "https://ccrma.stanford.edu/software/cmn/cmn"
                           ".tar.gz"))
       (sha256
        (base32
         "1f4ivhg1vq2fwklmwjj30bj7ij1yab45rnjjwps3qpsh0lpd6yj3"))
       (file-name (string-append name "-" version))))
    (build-system asdf-build-system/sbcl)
    (arguments
     `(#:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'fix-build
           (lambda _
             (substitute* "cmn-all.lisp"
               (("\\(setf cmn::\\*cmn-binary-directory\\* \\(namestring \\(truename cmn-bin-directory\\)\\)\\)")
                "")
               (("\\(setf cmn::\\*cmn-source-directory\\* \\(namestring \\(truename cmn-directory\\)\\)\\)")
                "")
               (("\\(cmn-compile-and-load file\\)")
                "(load (asdf:system-relative-pathname :cmn file :type \"lisp\"))")))))))
    (home-page "https://ccrma.stanford.edu/software/cmn/")
    (synopsis "Western music notation package written in Common Lisp")
    (description
     "CMN provides a package of functions to hierarchically describe a musical
	score. When evaluated, the musical score is rendered to an image.")
    (license license:llgpl)))
--8<---------------cut here---------------end--------------->8---
bil@ccrma.Stanford.EDU Nov. 17, 2021, 10:39 a.m. UTC | #4
The license entry in cmn.asd is incorrect -- I never
noticed that Rick Taube specified GPL.  The BSD
or MIT licenses are ok.  I wrote all of cmn; Rick was
just helping by adding the asd file, and I paid no
attention to it.  We weren't so concerned with licenses
in those days.  (I'll update the ccrma tarball).

cmn-all.lisp builds cmn fine for me -- is the problem
the directory?  Also to run it you need to be in
the cmn package.

Thanks for your interest in this software!
Guillaume Le Vaillant Nov. 21, 2021, 12:51 p.m. UTC | #5
bil@ccrma.Stanford.EDU skribis:

> The license entry in cmn.asd is incorrect -- I never
> noticed that Rick Taube specified GPL.  The BSD
> or MIT licenses are ok.  I wrote all of cmn; Rick was
> just helping by adding the asd file, and I paid no
> attention to it.  We weren't so concerned with licenses
> in those days.  (I'll update the ccrma tarball).
>
> cmn-all.lisp builds cmn fine for me -- is the problem
> the directory?  Also to run it you need to be in
> the cmn package.
>
> Thanks for your interest in this software!

Hi,

I took a look at this package and I noticed that the tarball doesn't
contain an asd file anymore. Instead of removing it, wouldn't it be
possible to just put the correct license in the asdf system definition?
bil@ccrma.Stanford.EDU Nov. 21, 2021, 2:16 p.m. UTC | #6
I did not remove it; for some reason it wasn't in the
directory I used to make the tarball.
Guillaume Le Vaillant Nov. 21, 2021, 4:20 p.m. UTC | #7
bil@ccrma.Stanford.EDU skribis:

> I did not remove it; for some reason it wasn't in the
> directory I used to make the tarball.

In order for the compilation of cmn to put the files in the standard
locations used in GNU Guix, I changed the asd file to replace

  :components ((:file "cmn-all\" ))

by

  :serial t
  :components ((:file "cmn-init")
               (:file "cmn-utils")
               (:file "cmn-objects")
               (:file "cmn0")
               (:file "cmn-grfx")
               (:file "cmn-glyphs")
               (:file "cmn1")
               (:file "cmn2")
               (:file "cmn3")
               (:file "cmn4")
               (:file "rqq")
               (:file "wedge")
               (:file "accent")
               (:file "pedal")
               (:file "percussion")
               (:file "ring")
               (:file "rests")
               (:file "lyrics")
               (:file "transpose")
               (:file "pmn")
               (:file "quarter"))

and it almost works.
The only issue making the compilation fail is a type error warning by
sbcl, which I think is due to a bug in the program.

In the IDENTIFY-SCORE function of the "cmn2.lisp" file, the TIED-TAG
variable is defined by a "(find :tied-to (store-data object))" form,
which means that TIED-TAG will be either :TIED-TO or NIL.
However a few lines lower, the "(setf (second tied-tag) ...)" form
indicates that TIED-TAG must be a non-empty list.

From the surrounding code, I got the impression that
"(store-data object)" probably contains lists, and that the definition
of TIED-TAG should be something like

  (find :tied-to (store-data object) :key #'car)

With this, the compilation succeeds with sbcl and ecl, and the little
"(cmn treble c4 q)" example from the README file works.

I don't know if you're interested in the modified asd file, we can keep
it as a Guix-only thing anyway. However the TIED-TAG thing looks like an
actual bug.
What do you think?
bil@ccrma.Stanford.EDU Nov. 21, 2021, 5:45 p.m. UTC | #8
Please do not repair code you don't understand.  First,
sbcl issues a warning, not an error.  The warning is
asinine -- find (in the original form) returns a list;
I check whether it is nil before setting a portion of it.
If you change the find statement to add :key #'car, you've
changed it from memq to assq (in Scheme nomenclature) --
these are not the same thing.  Your test of running
(cmn treble c4 q) did not hit the code in question, so
it tested nothing.  All you've done is add a bug to
my code.
Guillaume Le Vaillant Nov. 21, 2021, 5:54 p.m. UTC | #9
bil@ccrma.Stanford.EDU skribis:

> Please do not repair code you don't understand.  First,
> sbcl issues a warning, not an error.  The warning is
> asinine -- find (in the original form) returns a list;
> I check whether it is nil before setting a portion of it.
> If you change the find statement to add :key #'car, you've
> changed it from memq to assq (in Scheme nomenclature) --
> these are not the same thing.  Your test of running
> (cmn treble c4 q) did not hit the code in question, so
> it tested nothing.  All you've done is add a bug to
> my code.

If you take a look at the Common Lisp spec [1], you'll see that 'find'
returns an element, not a list. The function returning a list is
'member' [2].

[1] http://www.lispworks.com/documentation/HyperSpec/Body/f_find_.htm
[2] http://www.lispworks.com/documentation/HyperSpec/Body/f_mem_m.htm
bil@ccrma.Stanford.EDU Nov. 21, 2021, 7:22 p.m. UTC | #10
Oh hell.  I'm forgetting CL.  My apologies. Your fix
was probably correct.
jgart Nov. 22, 2021, 12:30 a.m. UTC | #11
On Sun, 21 Nov 2021 11:22:21 -0800 bil@ccrma.Stanford.EDU wrote:
> Oh hell.  I'm forgetting CL.  My apologies. Your fix
> was probably correct.
> 

Hi everyone,

It's great that this was able to be resolved.

I'm looking forward to having a cmn package for guix.

Guillaume would you be so kind to send your patch to Bill?

Bill, would that be helpful?

I can then update the guix package to use the newer version of cmn once it is released and avoid 
having to patch the asd file.

all the best,

jgart
bil@ccrma.Stanford.EDU Nov. 22, 2021, 2:13 p.m. UTC | #12
I have made those changes to my version of cmn, and updated
the tarball.
diff mbox series

Patch

diff --git a/gnu/packages/music.scm b/gnu/packages/music.scm
index 60cff2cc28..ee130d7b54 100644
--- a/gnu/packages/music.scm
+++ b/gnu/packages/music.scm
@@ -66,6 +66,7 @@  (define-module (gnu packages music)
   #:use-module (guix download)
   #:use-module (guix git-download)
   #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix build-system asdf)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system ant)
   #:use-module (guix build-system cmake)
@@ -6911,6 +6912,26 @@  (define-public shiru-lv2
       (home-page "http://shiru.untergrund.net/software.shtml")
       (license license:wtfpl2))))
 
+(define-public cl-cmn
+  (package
+    (name "cl-cmn")
+    (version "0")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "https://ccrma.stanford.edu/software/cmn/cmn"
+                           ".tar.gz"))
+       (sha256
+        (base32
+         "1f4ivhg1vq2fwklmwjj30bj7ij1yab45rnjjwps3qpsh0lpd6yj3"))))
+    (build-system asdf-build-system/source)
+    (home-page "https://ccrma.stanford.edu/software/cmn/")
+    (synopsis "Western music notation package written in Common Lisp")
+    (description
+"CMN provides a package of functions to hierarchically describe a musical
+score. When evaluated, the musical score is rendered to an image.")
+    (license license:expat)))
+
 (define-public a2jmidid
   (package
     (name "a2jmidid")