Skip to content

Instantly share code, notes, and snippets.

@unya
Last active August 29, 2015 13:56
Show Gist options
  • Save unya/8856967 to your computer and use it in GitHub Desktop.
Save unya/8856967 to your computer and use it in GitHub Desktop.
How to use DKMS, according to https://github.com/ryao
dkms status | awk -F', ' '!z[$1]++{ a[$1]="dkms remove -m "$1" -v "$2; } END {{for (i in a) print a[i]}}' | grep -E '(zfs|spl)' | sort -r | sed -e "s/$/ $(ls /usr/src/kernels/* -d | sed -e 's/.*kernels\///' | sort -V | xargs -n1 printf -- '-k %s\n' | tr '\n' ' ');/" | bash
03:11 < ryao+> Hmm... this dkms stuff is not as hard as I thought. It is only 1 line to get it to uninstall/remove the existing modules: dkms status | awk -F', ' '!z[$1]++{ a[$1]="dkms remove -m "$1" -v "$2; } END {{for (i in a) print a[i]}}' | grep -E '(zfs|spl)' | sort -r | sed -e "s/$/ $(ls /usr/src/kernels/* -d | sed -e 's/.*kernels\///' | sort -V | xargs -n1 printf -- '-k %s\n' | tr '\n' ' ');/" | bash
03:11 < ryao+> behlendorf: ^ I finally figured out how to do dkms stuff.
03:12 < ryao+> I am partially joking and partially serious with that command, and yes, it apparently does work. I am running it now.
03:13 < jamesd > ryao: that reminds me of this http://bash.org/?464385 <-- only takes 3 commands to install gentoo, this was before eveyone started using pre-built binaries.
03:13 < ryao+> jamesd: Someone asked me to write a script to help them with upgrades on CentOS and I felt creative.
03:14 < ryao+> I should `s/bash/sh/` that to make it POSIX conformant... I am assuming that my awk is POSIX conformant, but quite honestly, I have no idea. I am not very good at awk.
03:15 < ryao+> I pieced that together by finding a bunch of awk commands online that others wrote, dissecting the grammar and then recombining it in a way that made awk do what I wanted.
03:16 < ryao+> Each one of the donator commands did one aspect of what I wanted.
03:16 < ryao+> s/donator/donor/
03:16 < p_l > lol @ bash link
03:17 < ryao+> By the way, that command runs very quickly if I insert `echo` before `dkms`. However, it is agonizingly slow when actually run.
03:18 < ryao+> Actually, I just need to remove the pipe to the shell to print it... This is polymorphic code. I have not written anything like this in a while.
03:18 < ryao+> In fact, I have not written anything like this in over 10 years.
03:19 < ryao+> I wrote a routine in PHP that wrote the PHP code that accomplished a task around 2003. This is the first time I have used this technique since then.
03:20 < p_l > hahahahaha
03:20 < p_l > it needs immortalizing
@unya
Copy link
Author

unya commented Feb 7, 2014

From #zfsonlinux @ freenode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment