all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Martin Becze <mjbecze@riseup.net>
To: Leo Famulari <leo@famulari.name>, guix-devel@gnu.org
Subject: Re: rav1e AV1 encoder
Date: Fri, 21 Feb 2020 04:15:43 -0500	[thread overview]
Message-ID: <9e81d5d5-1f2a-3c6d-5f99-c001d1a03b7f@riseup.net> (raw)
In-Reply-To: <20200220224353.GA28976@jasmine.lan>

[-- Attachment #1: Type: text/plain, Size: 1411 bytes --]



On 2/20/20 5:43 PM, Leo Famulari wrote:
> Should they be added to (gnu packages crates-io)?

yep!

> And if so, should it
> be done as a single commit? Or one-by-one? 

One-by-one unfortunately

> It's 258 new packages, and
> figuring out the order they should be added in seems... too hard. 

They should be alphanumeric

> The c-bindgen and cargo-c packages could go in (gnu packages rust-apps).
> 
> What about updating them later? Will `guix refresh` handle it? 

guix refresh should  handle them. But currently it should do thing 
recursively so keep that in mind.

I have a small tool I have been working will make the new packages 
easier to commit.... its very much WIP but if I would appreciate any 
feedback. Attached is sort2.scm and merge.scm

sort2.scm will sort a files exported packages alphanumerically.
merge.scm will merge exported packages of two files into a single file 
creating a git commit for every new or updated package.

Here is my work flow,
1) Import the package using `guix import crate -r mypackage > mypackage.scm`

2) Sort the packages, `guile -s ./sort2.scm mypackage.scm > 
mypackage.scm` (you will probably also want to sort crates-io.scm, i 
think some packages may be out-of-order now)

3) merge mypackages.scm and crates-io.scm `guile -s ./merge.scm 
./mypackage.scm ./crates-io.scm`

4) check that the git log looks correct and that everything still runs! :D

-Martin

[-- Attachment #2: merge.scm --]
[-- Type: text/x-scheme, Size: 3350 bytes --]

(use-modules (guix utils))
(use-modules (guix build utils))
(use-modules (ice-9 binary-ports))
(use-modules (ice-9 match))
(use-modules (srfi srfi-1))
(use-modules (srfi srfi-9))
(use-modules (srfi srfi-71))

(define-record-type <iter-pos>
    (make-iter-pos port name str version eof?)
    iter-pos?
    (port    iter-pos-port)
    (name    iter-pos-name)
    (str     iter-pos-str)
    (version iter-pos-version)
    (eof?    iter-pos-eof?))

(define-values (a-filename b-filename)
  (match (command-line)
    ((self a-file b-file) (values a-file b-file))))

(define (peek-operation port proc)
  (let ((org-pos (ftell port)))
    (call-with-values
      proc	
      (lambda vals
	(seek port org-pos SEEK_SET)
	(apply values vals)))))

(define (peek-rest port)
  (peek-operation port (λ ∅ (get-bytevector-all port))))

(define a-port (open-input-file a-filename))
(define out-port (open-io-file b-filename))
(define b-port (open-bytevector-input-port
		(peek-rest out-port)))

(define (git-commit msg)
  (sync)
  (invoke "git" "commit" "-a" "-m" msg))

(define (git-commit-new-package a)
  (define name (iter-pos-name a))
  (git-commit
   (string-append "gnu: Add " name "\n\n* gnu/packages/" b-filename
		  " (" name "): New varible.")))

(define (git-commit-update-package a)
  (let ((name (iter-pos-name a))
	(version (iter-pos-version a)))
    (git-commit
     (string-append "gnu: " name ": Upgrade to " version "\n\n* gnu/packages/" b-filename
		    " (" name "): Upgrade to " version))))

(define (file-iter port)
  (λ ∅
    (let* ((start (ftell port))
	   (sexp (read port))
	   (end (ftell port))
	   (str (begin
		  (seek port start SEEK_SET)
		  (get-bytevector-n port (- end start))))
	   (name version
		 (match sexp
		   (('define-public name
		      (or
		       ('package ('name _) ('version version) . _)
		       ('let _ ('package ('name _) ('version version) . _))))
		    (values (symbol->string name) version))
		   (_ (values #f #f))))
	   (eof? (eof-object? sexp)))
      (make-iter-pos port name str version eof?))))

(define* (insert-before a b out #:optional replace)
  (let ((a-str (iter-pos-str a))
	(b-str (iter-pos-str b))
	(b-rest (peek-rest
		 (iter-pos-port b))))

    (put-bytevector out-port a-str)
    (peek-operation
     out-port (λ ∅ 
		(unless replace
		  (put-bytevector out-port b-str))
		;; read the rest of port-b
		(put-bytevector out-port b-rest)))))

(define (merge-iter a-iter b-iter out-port)
  (let lp ((a (a-iter))
	   (b (b-iter)))
    (unless (iter-pos-eof? a)
      (let ((a-name (iter-pos-name a))
	    (b-name (iter-pos-name b))
	    (a-str  (iter-pos-str a))
	    (b-str  (iter-pos-str b)))
	(cond
	 ((not b-name)
	  (begin
	    (put-bytevector out-port (iter-pos-str b))
	    (lp a (b-iter))))
	 ((string<? a-name b-name)
	  (begin
	    (insert-before a b out-port)
	    (git-commit-new-package a)
	    (lp (a-iter) b)))
	 ((string>? a-name b-name)
	  (lp a (b-iter)))
	 (#t
	  (begin ;; else the names are equal
	    ;; make sure the action are idenpotent
	    (unless (equal? b-str a-str)
	      (insert-before a b out-port #t)
	      (git-commit-update-package a))
	    (lp (a-iter) (b-iter)))))))))

(merge-iter
 (file-iter a-port) (file-iter b-port) out-port)

[-- Attachment #3: sort2.scm --]
[-- Type: text/x-scheme, Size: 966 bytes --]

(use-modules (ice-9 pretty-print))
(use-modules (ice-9 binary-ports))
(use-modules (ice-9 match))

(define filename (match (command-line)
		   ((self file) file)))

(define* (package-list port #:optional (init '()))
  (let ((start (ftell port))
	(sexp (read port))
	(end (ftell port)))
    (if (eof-object? sexp)
	init
	(package-list port (cons (list start end sexp)  init)))))

(define out-port (current-output-port))
(define port (open-file filename "r"))
(define packages (package-list port))
(define sorted-packages
  (sort-list
   packages
   (match-lambda* (((_ _ ('define-public names _)) ...)
		   (apply string<? (map symbol->string names)))
		  (_ #t))))

(define (write-packages packages in-port out-port)
  (for-each (match-lambda
	      ((start end _)
	       (let* ((len (- end start)))
		 (seek in-port start SEEK_SET)
		 (put-bytevector
		  out-port
		  (get-bytevector-n port len)))))
	    packages))

(write-packages sorted-packages port out-port)

  reply	other threads:[~2020-02-21  9:15 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-20 22:43 rav1e AV1 encoder Leo Famulari
2020-02-21  9:15 ` Martin Becze [this message]
2020-02-21 16:16   ` Leo Famulari
2020-02-21 16:41   ` Leo Famulari
2020-02-21 16:43     ` Martin Becze
2020-02-21 16:46     ` Martin Becze
2020-02-21 16:56       ` Leo Famulari
2020-02-22 11:09         ` Martin Becze
2020-02-22 22:41           ` Leo Famulari
2020-02-24 11:02             ` Martin Becze
2020-02-25 20:08   ` Leo Famulari
2020-02-25 21:21     ` John Soo
2020-02-26  4:14       ` Leo Famulari
2020-02-26  7:09         ` Efraim Flashner
2020-02-27 17:16           ` Leo Famulari
2020-02-28 13:24             ` Efraim Flashner
2020-02-27 17:26           ` Leo Famulari
2020-02-28 13:30             ` Efraim Flashner
2020-02-28 17:04             ` Martin Becze
2020-04-02 22:31   ` sorting Rust crates [was Re: rav1e AV1 encoder] Leo Famulari
2020-04-12 15:22     ` Martin Becze
2020-04-14 20:08       ` Martin Becze
2020-04-26 17:05 ` rav1e AV1 encoder Efraim Flashner
2020-04-26 17:47   ` Leo Famulari
2020-04-26 17:48   ` Leo Famulari
2020-04-26 17:53     ` Efraim Flashner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9e81d5d5-1f2a-3c6d-5f99-c001d1a03b7f@riseup.net \
    --to=mjbecze@riseup.net \
    --cc=guix-devel@gnu.org \
    --cc=leo@famulari.name \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.