all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Newbie tries to add a snippet to an origin
@ 2020-08-01 15:17 divoplade
  2020-08-01 15:26 ` John Soo
  2020-08-01 15:50 ` Julien Lepiller
  0 siblings, 2 replies; 7+ messages in thread
From: divoplade @ 2020-08-01 15:17 UTC (permalink / raw)
  To: help-guix

Hello,

I am trying to add a file named ".tarball-version" containing a fixed
string at the root of my source.

I tried several things, the most promising (I think) being this:

(define-public pomdappi-dist
  (dist-package
   pomdappi
   (origin
     (method git-fetch)
     (uri (git-reference
           (url "@REPO@")
           (commit "@COMMIT@")))
     (sha256
      (base32
       "@COMMIT_BASE32@"))
     (snippet
      #~(symlink #$(plain-file ".tarball-version" "@VERSION@")
                 ".tarball-version")))))

However, I get "guix build: error: invalid name: `.tarball-version'"
when running guix build.

My idea was to create a file in the store containing the fixed string
@VERSION@, and then symlink it withing the source as ".tarball-
version".

Could someone help me?

divoplade



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Newbie tries to add a snippet to an origin
  2020-08-01 15:17 Newbie tries to add a snippet to an origin divoplade
@ 2020-08-01 15:26 ` John Soo
  2020-08-01 15:44   ` divoplade
  2020-08-01 15:50 ` Julien Lepiller
  1 sibling, 1 reply; 7+ messages in thread
From: John Soo @ 2020-08-01 15:26 UTC (permalink / raw)
  To: divoplade; +Cc: help-guix

Hi divoplade,

What build system are you using? How do you use your version number?

Maybe there’s a simpler solution.

- John

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Newbie tries to add a snippet to an origin
  2020-08-01 15:26 ` John Soo
@ 2020-08-01 15:44   ` divoplade
  0 siblings, 0 replies; 7+ messages in thread
From: divoplade @ 2020-08-01 15:44 UTC (permalink / raw)
  To: John Soo; +Cc: help-guix

Hello,

Le samedi 01 août 2020 à 08:26 -0700, John Soo a écrit :
> What build system are you using? How do you use your version number?

I am using the standard gnu build system with a git repository [1]. The
version number is computed with "git describe --tags" (plus a little
sed "s/^v//g"), and I wish to use it to fix configure.ac. I can also
read the version number from a file in the repository (.tarball-
version), but it will not be part of a commit.

I have defined a guix template for two packages, "pomdappi" and
"pomdappi-dist", and I use the git repository and the gitlab CI
environment variables to fill in the blanks [2]. The "pomdappi-dist"
package creates the release tarball for "pomdappi", with the (dist-
package) constructor. The problem is that using a git source, I cannot
run "git describe"; so I need to patch the git source to add the
version number.

divoplade

[1] 
https://framagit.org/divoplade/pomdappi/-/tree/8-make-the-version-computation-reproducible
[2] 
https://framagit.org/divoplade/pomdappi/-/blob/8-make-the-version-computation-reproducible/dist



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Newbie tries to add a snippet to an origin
  2020-08-01 15:17 Newbie tries to add a snippet to an origin divoplade
  2020-08-01 15:26 ` John Soo
@ 2020-08-01 15:50 ` Julien Lepiller
  2020-08-01 16:00   ` John Soo
  1 sibling, 1 reply; 7+ messages in thread
From: Julien Lepiller @ 2020-08-01 15:50 UTC (permalink / raw)
  To: help-guix, divoplade

I don't think this is how you are supposed to use snippet :). It's code executed from the root of the sources that changes it. Then guix repacks the modified sources and the result is the source for tge package. Look at the code in guix for more examples. Here's what I suggest:

(source (origin
  …
  (modules '((guix build utils)))
  (snipet
   `(begin
       (with-output-to-file ".tarball-version"
         (lambda _
           (format #t "~a~%" ,version)))
       #t))))

Of course version needs to be defined in this context (usually as a field in the package definition, but I'm not sure what dist-package is). You can use any other name or the result of any scheme function, like (package-version pomdappi) if you prefer.

HTH!

Le 1 août 2020 11:17:36 GMT-04:00, divoplade <d@divoplade.fr> a écrit :
>Hello,
>
>I am trying to add a file named ".tarball-version" containing a fixed
>string at the root of my source.
>
>I tried several things, the most promising (I think) being this:
>
>(define-public pomdappi-dist
>  (dist-package
>   pomdappi
>   (origin
>     (method git-fetch)
>     (uri (git-reference
>           (url "@REPO@")
>           (commit "@COMMIT@")))
>     (sha256
>      (base32
>       "@COMMIT_BASE32@"))
>     (snippet
>      #~(symlink #$(plain-file ".tarball-version" "@VERSION@")
>                 ".tarball-version")))))
>
>However, I get "guix build: error: invalid name: `.tarball-version'"
>when running guix build.
>
>My idea was to create a file in the store containing the fixed string
>@VERSION@, and then symlink it withing the source as ".tarball-
>version".
>
>Could someone help me?
>
>divoplade

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Newbie tries to add a snippet to an origin
  2020-08-01 15:50 ` Julien Lepiller
@ 2020-08-01 16:00   ` John Soo
  2020-08-01 16:23     ` divoplade
  0 siblings, 1 reply; 7+ messages in thread
From: John Soo @ 2020-08-01 16:00 UTC (permalink / raw)
  To: Julien Lepiller; +Cc: help-guix

Hi divoplade and guix,

Since you are using the gnu build system, I suggest making your version number a variable in the makefile. The good part of using a make variable is that you can use $(shell git describe ...) normally and override it when building with guix. You can use the make or configure flags arguments to override the version number with the guix package version number.  

Hope that helps,

John



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Newbie tries to add a snippet to an origin
  2020-08-01 16:00   ` John Soo
@ 2020-08-01 16:23     ` divoplade
  2020-08-01 16:27       ` John Soo
  0 siblings, 1 reply; 7+ messages in thread
From: divoplade @ 2020-08-01 16:23 UTC (permalink / raw)
  To: John Soo, Julien Lepiller; +Cc: help-guix

Thank you so much for your help, now I can build both packages without
hassle. The filled-in module template is dynamically computed [1], so I
do not need to care about passing the version number around.

https://framagit.org/divoplade/pomdappi/-/jobs/1068726/artifacts/raw/public/divoplade/packages/pomdappi.scm

Le samedi 01 août 2020 à 09:00 -0700, John Soo a écrit :
> Since you are using the gnu build system, I suggest making your
> version number a variable in the makefile. The good part of using a
> make variable is that you can use $(shell git describe ...) normally
> and override it when building with guix. You can use the make or
> configure flags arguments to override the version number with the
> guix package version number.

I don't think it is wise to let the user update the version number with
a simple configure switch or make variable; it could make things very
confusing for debugging. Updating the version number is more of a
maintainer task, so it makes sense to write it in stone during the
maintainer phase (bootstrap / autoreconf).

divoplade



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Newbie tries to add a snippet to an origin
  2020-08-01 16:23     ` divoplade
@ 2020-08-01 16:27       ` John Soo
  0 siblings, 0 replies; 7+ messages in thread
From: John Soo @ 2020-08-01 16:27 UTC (permalink / raw)
  To: divoplade; +Cc: help-guix

Hi divoplade,

I’m glad you figured it out. 

I do want to say that most guix packages define the version number in the package definition. It would not be out of the ordinary to bump the version number in the scheme file.

Good luck!

John

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-08-01 16:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-01 15:17 Newbie tries to add a snippet to an origin divoplade
2020-08-01 15:26 ` John Soo
2020-08-01 15:44   ` divoplade
2020-08-01 15:50 ` Julien Lepiller
2020-08-01 16:00   ` John Soo
2020-08-01 16:23     ` divoplade
2020-08-01 16:27       ` John Soo

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.