Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/usr/bin/env zsh
list_ghc_cblrepo() {
cblrepo list --ghc --no-repo | sed -E 's/-xx$//'
}
list_ghc_repo() {
expac '%P' --listdelim '\n' -S ghc | grep '^haskell-' | sed -E 's/^haskell-//; s/=/ /'
}
list_distro_cblrepo() {
cblrepo list --distro --no-repo
}
list_distro_repo() {
expac '%n %v' -Ss haskell | grep '^haskell-' | sed -E 's/^haskell-//; s/ (\S*)-/ \1_0-/; s/\.([^._]*)-(.*)/.\1_0-\2/'
}
gen_add_updated() {
case "$1" in
ghc)
join <(list_ghc_cblrepo | sort -k 1b,1) <(list_ghc_repo | sort -k 1b,1) | \
gawk '$2 != $3 { printf " -g " $1 "," gensub("[-_]", ",", "g", $3) }' && \
printf '\n'
;;
distro)
join <(list_distro_cblrepo | sort -k 1b,1) <(list_distro_repo | sort -k 1b,1) | \
gawk '$2 != $3 { printf " -d " $1 "," gensub("[-_]", ",", "g", $3) }' && \
printf '\n'
;;
esac
}
gen_add_new() {
case "$1" in
ghc)
grep -vf <(list_ghc_cblrepo | gawk -F ' ' '{ print "^" $1 " " }') <(list_ghc_repo) | \
gawk '{ printf " -g " $1 "," gensub("[-_]", ",", "g", $2) }' && \
printf '\n'
;;
distro)
grep -vf <(list_distro_cblrepo | gawk -F ' ' '{ print "^" $1 " " }') <(list_distro_repo) | \
gawk '{ printf " -d " $1 "," gensub("[-_]", ",", "g", $2) }' && \
printf '\n'
;;
esac
}
gen_drop_missing() {
case "$1" in
ghc)
cblr=list_ghc_cblrepo
repo=list_ghc_repo
;;
distro)
cblr=list_distro_cblrepo
repo=list_distro_repo
;;
esac
grep -vf <($repo | gawk -F ' ' '{ print "^" $1 " " }') <($cblr) | \
gawk '{ printf " " $1 }' && \
printf '\n'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.