87 lines
3.0 KiB
Racket
87 lines
3.0 KiB
Racket
|
#!/usr/bin/env racket
|
||
|
#lang racket/base
|
||
|
|
||
|
(require "rebuild-pkgs.rkt")
|
||
|
|
||
|
(require racket/cmdline)
|
||
|
(require racket/format)
|
||
|
(require racket/system)
|
||
|
(require racket/port)
|
||
|
|
||
|
(define home (find-system-path 'home-dir))
|
||
|
(define cwd current-directory)
|
||
|
|
||
|
(define (sys cmd)
|
||
|
(eprintf "(~v) ~v\n" (cwd) cmd)
|
||
|
(unless (system cmd)
|
||
|
(eprintf "error in rebuild, aborting\n")
|
||
|
(exit 1)))
|
||
|
|
||
|
(define (str-or-empty hash key str)
|
||
|
(if (hash-has-key? hash key) str ""))
|
||
|
|
||
|
(define (higan-make args)
|
||
|
(sys (~a "make -j12 -C " args " uninstall"))
|
||
|
(sys (~a "make -j12 -C " args " clean"))
|
||
|
(sys (~a "make -j12 -C " args " all"))
|
||
|
(sys (~a "make -j12 -C " args " install")))
|
||
|
|
||
|
(define (default-pkg-url pkg)
|
||
|
(~a "https://aur.archlinux.org/" pkg ".git"))
|
||
|
|
||
|
(define (get-latest-tag)
|
||
|
(define latest
|
||
|
(with-output-to-string (λ () (sys "git rev-list --tags --max-count=1"))))
|
||
|
(with-output-to-string (λ () (sys (~a "git describe --tags \"" latest #\")))))
|
||
|
|
||
|
(define (build-pkg pkg opts)
|
||
|
(parameterize ([cwd (build-path home "bin")])
|
||
|
(let ([makepkg-args (~a "-isrLcCf --noconfirm"
|
||
|
(str-or-empty opts 'asdeps " --asdeps")
|
||
|
(str-or-empty opts 'force " -f")
|
||
|
(str-or-empty opts 'skipinteg " --skipinteg"))]
|
||
|
[clone-url (hash-ref opts 'url (default-pkg-url pkg))]
|
||
|
[special-handling (hash-ref opts 'handle 'none)]
|
||
|
[branch (hash-ref opts 'branch "")]
|
||
|
[pkg-dir (build-path (cwd) (symbol->string pkg))])
|
||
|
(unless (directory-exists? pkg-dir)
|
||
|
(sys (~a "git clone " branch " " clone-url)))
|
||
|
(parameterize ([cwd pkg-dir])
|
||
|
(sys "git pull")
|
||
|
(case special-handling
|
||
|
['none
|
||
|
(sys (~a "makepkg " makepkg-args))]
|
||
|
['higan
|
||
|
(sys "git fetch --tags")
|
||
|
(sys (~a "git checkout \"" (get-latest-tag) #\"))
|
||
|
(higan-make "higan target=higan")
|
||
|
(higan-make "icarus")
|
||
|
(sys "make -j12 -C shaders install")]
|
||
|
[else (raise-argument-error 'build-pkg
|
||
|
"(or/c 'none 'higan)"
|
||
|
special-handling)])))))
|
||
|
|
||
|
(define (resume-from-pkg input-pkg [pkg-list all-packages])
|
||
|
(let ([package (car pkg-list)])
|
||
|
(if (equal? package input-pkg)
|
||
|
pkg-list
|
||
|
(resume-from-pkg input-pkg (cdr pkg-list)))))
|
||
|
|
||
|
(let* ([resume-from (make-parameter null)]
|
||
|
[cmdline-pkgs (command-line
|
||
|
#:once-each
|
||
|
["--resume-from" pkg
|
||
|
"Resume compiling from a package."
|
||
|
(resume-from pkg)]
|
||
|
#:args pkgs (map string->symbol pkgs))]
|
||
|
[pkgs (if (null? cmdline-pkgs)
|
||
|
(let ([input-package (resume-from)])
|
||
|
(if (null? input-package)
|
||
|
all-packages
|
||
|
(resume-from-pkg (string->symbol input-package))))
|
||
|
cmdline-pkgs)])
|
||
|
(for ([package pkgs])
|
||
|
(build-pkg package (hash-ref package-options package (hash)))))
|
||
|
|
||
|
;; EOF
|