rebuild: rewrite in Racket

master
an 2019-06-11 21:11:37 -04:00
parent 025907fda1
commit 2537aafc4d
4 changed files with 160 additions and 0 deletions

74
scripts/rebuild-pkgs.rkt Executable file
View File

@ -0,0 +1,74 @@
#!/usr/bin/env racket
#lang racket/base
(require racket/format)
(provide all-packages package-options)
(define m64pncp 'mupen64plus-noncore-plugins-git)
(define mc-serv 'minecraft-server-fabric)
(define ext-git "https://git.greyserv.net/marrub")
(define all-packages
(list
'cef-standard
'cereal
'libsodium-git
'vim-runtime-git
'chocolate-doom
'desmume-git
'dolphin-emu-git
'eternity-engine-git
'fceux-git
'gdcc-git
'godot
'gopherus
'gvim-git
'gzdoom-legacy
'higan
'maxcso
'mednaffe
'megatools
'mgba-git
'minecraft-launcher
'motsognir
'mupen64plus-git
'mupen64plus-gui-git
'nicotine-plus-git
'obs-linuxbrowser-bin
'obs-studio-git
'pcsx2-git
'plasma5-applets-mpdnowplaying
'powershell-bin
'ppsspp-git
'prboom-plus
'ripcord
'rpcs3-git
'sharenix-git
'slade
'squirrel-sql
'teamviewer
'ttf-twemoji-color
'xf86-input-xwiimote-git
'xwiimote-git
'zdoom
m64pncp
mc-serv))
(define package-options
(hash
'cef-standard (hash 'asdeps #t)
'cereal (hash 'asdeps #t)
'libsodium-git (hash 'asdeps #t)
'vim-runtime-git (hash 'asdeps #t)
m64pncp (hash 'force #t 'url (~a ext-git "/" m64pncp ".git"))
'gdcc-git (hash 'url (~a ext-git "/gdcc-git.git"))
'higan (hash 'handle 'higan 'url "https://gitlab.com/higan/higan.git")
'motsognir (hash 'url (~a ext-git "/motsognir.git"))
'ppsspp-git (hash 'url (~a ext-git "/ppsspp-git.git"))
'teamviewer (hash 'url (~a ext-git "/teamviewer.git") 'branch "nmfix")
mc-serv (hash 'url (~a ext-git "/" mc-serv ".git"))))
;; EOF

86
scripts/rebuild.rkt Executable file
View File

@ -0,0 +1,86 @@
#!/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