Patchwork [3/3] gnu: Add kicad.

login
register
mail settings
Submitter Theodoros Foradis
Date Oct. 24, 2016, 9:16 p.m.
Message ID <20161024211658.13087-4-theodoros.for@openmailbox.org>
Download mbox | patch
Permalink /patch/16772/
State New
Headers show

Comments

Theodoros Foradis - Oct. 24, 2016, 9:16 p.m.
* gnu/packages/engineering.scm (kicad): New variable.
---
 gnu/packages/engineering.scm | 89 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 89 insertions(+)
Leo Famulari - Oct. 25, 2016, 12:36 a.m.
On Tue, Oct 25, 2016 at 12:16:58AM +0300, Theodoros Foradis wrote:
> * gnu/packages/engineering.scm (kicad): New variable.

Cool!

> +;; We use kicad from a git commit, because support for boost 1.61.0
> +;; has been recently added.
> +(define-public kicad
> +  (let ((commit "4ee344e150bfaf3a6f3f7bf935fb96ae07c423fa")
> +        (hash "0kf6r92nps0658i9n3p9vp5dzbssmc22lvjv5flyvnlf83l63s4n"))
> +    (package
> +      (name "kicad")
> +      (version (string-append "4.0-" (string-take commit 7)))
> +      (source
> +       (origin
> +         (method git-fetch)
> +         (uri (git-reference
> +               (url "https://git.launchpad.net/kicad.git")
> +               (commit commit)))

It fails to download the source:

@ build-started /gnu/store/z0771x4jjkcwd1qpak7c5z8n576mifi6-kicad-4.0-4ee344e-checkout.drv - x86_64-linux /var/log/guix/drvs/z0//771x4jjkcwd1qpak7c5z8n576mifi6-kicad-4.0-4ee344e-checkout.drv.bz2
Cloning into '/gnu/store/dr3kdxp4x9k1s7b40h18xr9lwg320n18-kicad-4.0-4ee344e-checkout'...
fatal: could not read Username for 'https://git.launchpad.net': No such device or address
environment variable `PATH' unset
builder for `/gnu/store/z0771x4jjkcwd1qpak7c5z8n576mifi6-kicad-4.0-4ee344e-checkout.drv' failed to produce output path `/gnu/store/dr3kdxp4x9k1s7b40h18xr9lwg320n18-kicad-4.0-4ee344e-checkout'
@ build-failed /gnu/store/z0771x4jjkcwd1qpak7c5z8n576mifi6-kicad-4.0-4ee344e-checkout.drv - 1 builder for `/gnu/store/z0771x4jjkcwd1qpak7c5z8n576mifi6-kicad-4.0-4ee344e-checkout.drv' failed to produce output path `/gnu/store/dr3kdxp4x9k1s7b40h18xr9lwg320n18-kicad-4.0-4ee344e-checkout'
cannot build derivation `/gnu/store/4903qvi3iaywzyxdlw5rky7s8ydva6bb-kicad-4.0-4ee344e.drv': 1 dependencies couldn't be built
guix build: error: build failed: build of `/gnu/store/4903qvi3iaywzyxdlw5rky7s8ydva6bb-kicad-4.0-4ee344e.drv' failed
Leo Famulari - Oct. 25, 2016, 12:41 a.m.
On Mon, Oct 24, 2016 at 08:36:10PM -0400, Leo Famulari wrote:
> On Tue, Oct 25, 2016 at 12:16:58AM +0300, Theodoros Foradis wrote:
> > * gnu/packages/engineering.scm (kicad): New variable.

> > +         (uri (git-reference
> > +               (url "https://git.launchpad.net/kicad.git")
> > +               (commit commit)))
> 
> It fails to download the source:
> 
> @ build-started /gnu/store/z0771x4jjkcwd1qpak7c5z8n576mifi6-kicad-4.0-4ee344e-checkout.drv - x86_64-linux /var/log/guix/drvs/z0//771x4jjkcwd1qpak7c5z8n576mifi6-kicad-4.0-4ee344e-checkout.drv.bz2
> Cloning into '/gnu/store/dr3kdxp4x9k1s7b40h18xr9lwg320n18-kicad-4.0-4ee344e-checkout'...
> fatal: could not read Username for 'https://git.launchpad.net': No such device or address

If looks like the correct URL is <https://git.launchpad.net/kicad>,
without the '.git' suffix. The source is downloading with that change.
Theodoros Foradis - Oct. 25, 2016, 8:11 a.m.
Leo Famulari writes:

> On Mon, Oct 24, 2016 at 08:36:10PM -0400, Leo Famulari wrote:
>> On Tue, Oct 25, 2016 at 12:16:58AM +0300, Theodoros Foradis wrote:
>> > * gnu/packages/engineering.scm (kicad): New variable.
>
>> > +         (uri (git-reference
>> > +               (url "https://git.launchpad.net/kicad.git")
>> > +               (commit commit)))
>> 
>> It fails to download the source:
>> 
>> @ build-started /gnu/store/z0771x4jjkcwd1qpak7c5z8n576mifi6-kicad-4.0-4ee344e-checkout.drv - x86_64-linux /var/log/guix/drvs/z0//771x4jjkcwd1qpak7c5z8n576mifi6-kicad-4.0-4ee344e-checkout.drv.bz2
>> Cloning into '/gnu/store/dr3kdxp4x9k1s7b40h18xr9lwg320n18-kicad-4.0-4ee344e-checkout'...
>> fatal: could not read Username for 'https://git.launchpad.net': No such device or address
>
> If looks like the correct URL is <https://git.launchpad.net/kicad>,
> without the '.git' suffix. The source is downloading with that change.

Thanks for the correction. I added the suffix after I had already
downloaded the source derivation, and it did not output any error in
subsequent builds.
Leo Famulari - Oct. 25, 2016, 12:48 p.m.
On Tue, Oct 25, 2016 at 12:16:58AM +0300, Theodoros Foradis wrote:
> * gnu/packages/engineering.scm (kicad): New variable.

I'm very happy to see this package almost there!

> +;; We use kicad from a git commit, because support for boost 1.61.0
> +;; has been recently added.
> +(define-public kicad
> +  (let ((commit "4ee344e150bfaf3a6f3f7bf935fb96ae07c423fa")
> +        (hash "0kf6r92nps0658i9n3p9vp5dzbssmc22lvjv5flyvnlf83l63s4n"))

I'd put the source hash in the "normal" place unless it's used later in
the package.

> +    (package
> +      (name "kicad")
> +      (version (string-append "4.0-" (string-take commit 7)))

Please make the version string with a revision number, as shown in the
manual section 7.6.3 Version Numbers. Otherwise, if we update our 4.0
Git-based package, users might not be able to upgrade with `guix package
-u`, since the Git hash not does not increase or decrease reliably.

> +      (source
> +       (origin
> +         (method git-fetch)
> +         (uri (git-reference
> +               (url "https://git.launchpad.net/kicad.git")
> +               (commit commit)))
> +         (sha256
> +          (base32 hash))
> +         (file-name (string-append name "-" version "-checkout"))))
> +      (build-system cmake-build-system)
> +      (arguments
> +       `(#:out-of-source? #t
> +         #:tests? #f ; no tests
> +         #:configure-flags
> +           (list "-DKICAD_STABLE_VERSION=ON"
> +                 "-DKICAD_REPO_NAME=stable"
> +                 "-DKICAD_BUILD_VERSION=4.0"
> +                 "-DCMAKE_BUILD_TYPE=Release"
> +                 "-DKICAD_SKIP_BOOST=ON"

Can you add a comment explaining this flag?

> +                 "-DKICAD_SCRIPTING=ON"
> +                 "-DKICAD_SCRIPTING_MODULES=ON"
> +                 "-DKICAD_SCRIPTING_WXPYTHON=ON"
> +                 ;; Has to be set explicitely, as we don't have the wxPython
> +                 ;; headers in the wxwidgets store item, but in wxPython.
> +                 (string-append "-DCMAKE_CXX_FLAGS=-I"
> +                                (assoc-ref %build-inputs "wxpython")
> +                                "/include/wx-3.0")
> +                 "-DCMAKE_BUILD_WITH_INSTALL_RPATH=TRUE"
> +                 "-DBUILD_GITHUB_PLUGIN=OFF")
> +           #:phases
> +             (modify-phases %standard-phases
> +               (add-after 'install 'wrap-program ;;Ensure correct python at runtime
> +                          (lambda* (#:key inputs outputs #:allow-other-keys)
> +                            (let* ((out (assoc-ref outputs "out"))
> +                                   (python (assoc-ref inputs "python"))
> +                                   (file (string-append out "/bin/kicad"))
> +                                   (path (string-append
> +                                          out
> +                                          "/lib/python2.7/site-packages:"
> +                                          (getenv "PYTHONPATH"))))
> +                              (wrap-program file
> +                                `("PYTHONPATH" ":" prefix (,path))
> +                                `("PATH" ":" prefix
> +                                  (,(string-append python "/bin:")))))
> +                            #t)))))
> +      (native-inputs
> +       `(("boost" ,boost)
> +         ("gettext" ,gnu-gettext)
> +         ("pkg-config" ,pkg-config)
> +         ("swig" ,swig)
> +         ("zlib" ,zlib)))
> +      (inputs
> +       `(("cairo" ,cairo)
> +         ("curl" ,curl)
> +         ("desktop-file-utils" ,desktop-file-utils)
> +         ("glew" ,glew)
> +         ("glm" ,glm)
> +         ("hicolor-icon-theme" ,hicolor-icon-theme)
> +         ("libsm" ,libsm)
> +         ("mesa" ,mesa)
> +         ("openssl" ,openssl)
> +         ("python" ,python-2)
> +         ("wxwidgets" ,wxwidgets-gtk2)
> +         ("wxpython" ,python2-wxpython)))

Can you check what packages the output refers to, using `guix gc
--references $(./pre-inst-env guix build kicad)`?

Some of the 'inputs' are not referenced, and so they will be garbage
collected when the user does `guix gc`, breaking the installed package.
I'm not sure exactly how to fix that here. Does anyone have advice?
Theodoros Foradis - Oct. 25, 2016, 4:09 p.m.
Leo Famulari writes:

> On Tue, Oct 25, 2016 at 12:16:58AM +0300, Theodoros Foradis wrote:
>> * gnu/packages/engineering.scm (kicad): New variable.
>
> I'm very happy to see this package almost there!
>
>> +;; We use kicad from a git commit, because support for boost 1.61.0
>> +;; has been recently added.
>> +(define-public kicad
>> +  (let ((commit "4ee344e150bfaf3a6f3f7bf935fb96ae07c423fa")
>> +        (hash "0kf6r92nps0658i9n3p9vp5dzbssmc22lvjv5flyvnlf83l63s4n"))
>
> I'd put the source hash in the "normal" place unless it's used later in
> the package.

>

fixed

>> +    (package
>> +      (name "kicad")
>> +      (version (string-append "4.0-" (string-take commit 7)))
>

fixed

> Please make the version string with a revision number, as shown in the
> manual section 7.6.3 Version Numbers. Otherwise, if we update our 4.0
> Git-based package, users might not be able to upgrade with `guix package
> -u`, since the Git hash not does not increase or decrease reliably.
>
>> +      (source
>> +       (origin
>> +         (method git-fetch)
>> +         (uri (git-reference
>> +               (url "https://git.launchpad.net/kicad.git")
>> +               (commit commit)))
>> +         (sha256
>> +          (base32 hash))
>> +         (file-name (string-append name "-" version "-checkout"))))
>> +      (build-system cmake-build-system)
>> +      (arguments
>> +       `(#:out-of-source? #t
>> +         #:tests? #f ; no tests
>> +         #:configure-flags
>> +           (list "-DKICAD_STABLE_VERSION=ON"
>> +                 "-DKICAD_REPO_NAME=stable"
>> +                 "-DKICAD_BUILD_VERSION=4.0"
>> +                 "-DCMAKE_BUILD_TYPE=Release"
>> +                 "-DKICAD_SKIP_BOOST=ON"
>
> Can you add a comment explaining this flag?
>

comment added

>> +                 "-DKICAD_SCRIPTING=ON"
>> +                 "-DKICAD_SCRIPTING_MODULES=ON"
>> +                 "-DKICAD_SCRIPTING_WXPYTHON=ON"
>> +                 ;; Has to be set explicitely, as we don't have the wxPython
>> +                 ;; headers in the wxwidgets store item, but in wxPython.
>> +                 (string-append "-DCMAKE_CXX_FLAGS=-I"
>> +                                (assoc-ref %build-inputs "wxpython")
>> +                                "/include/wx-3.0")
>> +                 "-DCMAKE_BUILD_WITH_INSTALL_RPATH=TRUE"
>> +                 "-DBUILD_GITHUB_PLUGIN=OFF")
>> +           #:phases
>> +             (modify-phases %standard-phases
>> +               (add-after 'install 'wrap-program ;;Ensure correct python at runtime
>> +                          (lambda* (#:key inputs outputs #:allow-other-keys)
>> +                            (let* ((out (assoc-ref outputs "out"))
>> +                                   (python (assoc-ref inputs "python"))
>> +                                   (file (string-append out "/bin/kicad"))
>> +                                   (path (string-append
>> +                                          out
>> +                                          "/lib/python2.7/site-packages:"
>> +                                          (getenv "PYTHONPATH"))))
>> +                              (wrap-program file
>> +                                `("PYTHONPATH" ":" prefix (,path))
>> +                                `("PATH" ":" prefix
>> +                                  (,(string-append python "/bin:")))))
>> +                            #t)))))
>> +      (native-inputs
>> +       `(("boost" ,boost)
>> +         ("gettext" ,gnu-gettext)
>> +         ("pkg-config" ,pkg-config)
>> +         ("swig" ,swig)
>> +         ("zlib" ,zlib)))
>> +      (inputs
>> +       `(("cairo" ,cairo)
>> +         ("curl" ,curl)
>> +         ("desktop-file-utils" ,desktop-file-utils)
>> +         ("glew" ,glew)
>> +         ("glm" ,glm)
>> +         ("hicolor-icon-theme" ,hicolor-icon-theme)
>> +         ("libsm" ,libsm)
>> +         ("mesa" ,mesa)
>> +         ("openssl" ,openssl)
>> +         ("python" ,python-2)
>> +         ("wxwidgets" ,wxwidgets-gtk2)
>> +         ("wxpython" ,python2-wxpython)))
>
> Can you check what packages the output refers to, using `guix gc
> --references $(./pre-inst-env guix build kicad)`?
>
> Some of the 'inputs' are not referenced, and so they will be garbage
> collected when the user does `guix gc`, breaking the installed package.
> I'm not sure exactly how to fix that here. Does anyone have advice?

Using `guix gc --references $(./pre-inst-env guix build kicad)` gives me:
/gnu/store/15108s447dw871hipsy4d5ymj8l4pg9s-wxwidgets-gtk2-3.0.2
/gnu/store/1xfc2pwr7qfjib9kfy3n2hjq56z7jyjx-python-2.7.11
/gnu/store/7nvkh8bb24nlw5ayyz5z292vxqsm38ci-glu-9.0.0
/gnu/store/9nifwk709wajpyfwa0jzaa3p6mf10vxs-gcc-4.9.3-lib
/gnu/store/fjqm9am7np8dkm30kcgf7d84w4walhv5-glew-2.0.0
/gnu/store/gzcf89jjza5m836sycvi8rvqrjx5dfgc-cairo-1.14.6
/gnu/store/lwa2zd7hcii3b870lp4qm44mzckqnrik-python2-wxpython-3.0.2.0
/gnu/store/m9vxvhdj691bq1f85lpflvnhcvrdilih-glibc-2.23
/gnu/store/mcnhg4zdfvp50xwlyiq7c1731bjnrjb8-kicad-4.0-1.4ee344e
/gnu/store/r837zajjc1q8z9hph4b6860a9c05blyy-openssl-1.0.2j
/gnu/store/wzbjwqgdl2cn7az984349x7pqh6pkw1y-boost-1.61.0
/gnu/store/x98d057wl2krpja1bvwpi9qbsxjf8n71-glm-0.9.6.3
/gnu/store/xzx126zvlvy3jaj020sdkq9jpxbf04ap-mesa-11.0.9
/gnu/store/ykzwykkvr2c80rw4l1qh3mvfdkl7jibi-bash-4.3.42

Maybe the other inputs are not runtime dependencies? Not sure of this one.

I also got rid of replacing the build phase, as Hartmut Goebel
suggested, for compatibility with the upcoming python build system.
Theodoros Foradis - Oct. 25, 2016, 4:59 p.m.
Patch v2 series was a mistake. This one can be applied on master. My comments on v2,
apply on this patch series. Also, I made the changes that Efraim Flashner proposed.

Excuse me for the spam.

Patch

diff --git a/gnu/packages/engineering.scm b/gnu/packages/engineering.scm
index 829ceb0..e5a48fc 100644
--- a/gnu/packages/engineering.scm
+++ b/gnu/packages/engineering.scm
@@ -4,6 +4,7 @@ 
 ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
 ;;; Copyright © 2016 David Thompson <davet@gnu.org>
 ;;; Copyright © 2016 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2016 Theodoros Foradis <theodoros.for@openmailbox.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -29,6 +30,7 @@ 
   #:use-module (guix store)
   #:use-module (guix utils)
   #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix build-system cmake)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system cmake)
   #:use-module (gnu packages)
@@ -39,6 +41,7 @@ 
   #:use-module (gnu packages boost)
   #:use-module (gnu packages check)
   #:use-module (gnu packages compression)
+  #:use-module (gnu packages curl)
   #:use-module (gnu packages flex)
   #:use-module (gnu packages fontutils)
   #:use-module (gnu packages gd)
@@ -55,9 +58,14 @@ 
   #:use-module (gnu packages maths)
   #:use-module (gnu packages perl)
   #:use-module (gnu packages pkg-config)
+  #:use-module (gnu packages python)
   #:use-module (gnu packages qt)
+  #:use-module (gnu packages swig)
   #:use-module (gnu packages tcl)
+  #:use-module (gnu packages tls)
   #:use-module (gnu packages tex)
+  #:use-module (gnu packages wxwidgets)
+  #:use-module (gnu packages xorg)
   #:use-module (srfi srfi-1))
 
 (define-public librecad
@@ -562,3 +570,84 @@  fundamental, primitive shapes are represented as code in the user-level
 language.")
       (license (list license:lgpl2.1+             ;library
                      license:gpl2+)))))           ;Guile bindings
+
+;; We use kicad from a git commit, because support for boost 1.61.0
+;; has been recently added.
+(define-public kicad
+  (let ((commit "4ee344e150bfaf3a6f3f7bf935fb96ae07c423fa")
+        (hash "0kf6r92nps0658i9n3p9vp5dzbssmc22lvjv5flyvnlf83l63s4n"))
+    (package
+      (name "kicad")
+      (version (string-append "4.0-" (string-take commit 7)))
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://git.launchpad.net/kicad.git")
+               (commit commit)))
+         (sha256
+          (base32 hash))
+         (file-name (string-append name "-" version "-checkout"))))
+      (build-system cmake-build-system)
+      (arguments
+       `(#:out-of-source? #t
+         #:tests? #f ; no tests
+         #:configure-flags
+           (list "-DKICAD_STABLE_VERSION=ON"
+                 "-DKICAD_REPO_NAME=stable"
+                 "-DKICAD_BUILD_VERSION=4.0"
+                 "-DCMAKE_BUILD_TYPE=Release"
+                 "-DKICAD_SKIP_BOOST=ON"
+                 "-DKICAD_SCRIPTING=ON"
+                 "-DKICAD_SCRIPTING_MODULES=ON"
+                 "-DKICAD_SCRIPTING_WXPYTHON=ON"
+                 ;; Has to be set explicitely, as we don't have the wxPython
+                 ;; headers in the wxwidgets store item, but in wxPython.
+                 (string-append "-DCMAKE_CXX_FLAGS=-I"
+                                (assoc-ref %build-inputs "wxpython")
+                                "/include/wx-3.0")
+                 "-DCMAKE_BUILD_WITH_INSTALL_RPATH=TRUE"
+                 "-DBUILD_GITHUB_PLUGIN=OFF")
+           #:phases
+             (modify-phases %standard-phases
+               (add-after 'install 'wrap-program ;;Ensure correct python at runtime
+                          (lambda* (#:key inputs outputs #:allow-other-keys)
+                            (let* ((out (assoc-ref outputs "out"))
+                                   (python (assoc-ref inputs "python"))
+                                   (file (string-append out "/bin/kicad"))
+                                   (path (string-append
+                                          out
+                                          "/lib/python2.7/site-packages:"
+                                          (getenv "PYTHONPATH"))))
+                              (wrap-program file
+                                `("PYTHONPATH" ":" prefix (,path))
+                                `("PATH" ":" prefix
+                                  (,(string-append python "/bin:")))))
+                            #t)))))
+      (native-inputs
+       `(("boost" ,boost)
+         ("gettext" ,gnu-gettext)
+         ("pkg-config" ,pkg-config)
+         ("swig" ,swig)
+         ("zlib" ,zlib)))
+      (inputs
+       `(("cairo" ,cairo)
+         ("curl" ,curl)
+         ("desktop-file-utils" ,desktop-file-utils)
+         ("glew" ,glew)
+         ("glm" ,glm)
+         ("hicolor-icon-theme" ,hicolor-icon-theme)
+         ("libsm" ,libsm)
+         ("mesa" ,mesa)
+         ("openssl" ,openssl)
+         ("python" ,python-2)
+         ("wxwidgets" ,wxwidgets-gtk2)
+         ("wxpython" ,python2-wxpython)))
+      (home-page "http://http://kicad-pcb.org/")
+      (synopsis "Electronics Design Automation Suite")
+      (description
+       "Kicad is created for the formation of printed circuit boards and electrical circuits.
+ The software has a number of programs that perform specific functions, for example,
+ pcbnew (Editing PCB), eeschema (editing electrical diagrams), gerbview (viewing Gerber
+ files) and others. ")
+      (license license:gpl3+))))