Advertisement
bobdodds

get_mainline_kernel (bash script,CODE)

Mar 19th, 2017
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. #!/bin/bash
  2. vars='?C=N;O=D'
  3. mainline=http://kernel.ubuntu.com/~kernel-ppa/mainline/
  4. arch=amd64
  5. rm -r /tmp/k /tmp/md /tmp/mt 2>/dev/null
  6. wget -O- ${mainline}$vars > /tmp/k
  7. if [ -s /tmp/k ]
  8. then distrgx='/href=/{s/\(^.*href="\)\(v[^"]\+[a-z]\/\)\(".*\)/\2/p;}'
  9. tiprgx='/href=/{s/\(^.*href="\)\(v[^"]\+\/\)\(".*\)/\2/p;}'
  10. patrgx='s/\(^.*href="\)\([0-9].*\.patch\)\(".*$\)/\2/p'
  11. d=`sed -n -e $distrgx /tmp/k | head -n1`
  12. t=`sed -n -e $tiprgx /tmp/k | head -n1`
  13. echo d $d t $t
  14. wget -O- ${mainline}$d > /tmp/md
  15. wget -O- ${mainline}$t > /tmp/mt
  16. if [ -s /tmp/md ] && [ -s /tmp/mt ]
  17. then tpatches=( `sed -n -e $patrgx /tmp/mt | sort | uniq` )
  18. for (( n=0 ; n<${#tpatches[@]} ; n++ ))
  19. do tpatches[$n]=${mainline}${t}${tpatches[$n]}
  20. done
  21. deb='/href=/{/generic/{/'$arch'/{/image/s/\(^.*href="\)\([^"]\+\)\(".*\)/\2/p;};};}'
  22. headers='/href=/{/generic/{/'$arch'/{/headers/s/\(^.*href="\)\([^"]\+\)\(".*\)/\2/p;};};}'
  23. allhdrs='/href=/{/all/{/headers/s/\(^.*href="\)\([^"]\+\)\(".*\)/\2/p;};}'
  24. dist=${mainline}${d}`sed -n -e $deb /tmp/md | tail -n1`
  25. distheaders=${mainline}${d}`sed -n -e $headers /tmp/md | tail -n1`
  26. alld=${mainline}${d}`sed -n -e $allhdrs /tmp/md | tail -n1`
  27. tip=${mainline}${t}`sed -n -e $deb /tmp/mt | tail -n1`
  28. tipheaders=${mainline}${t}`sed -n -e $headers /tmp/mt | tail -n1`
  29. allt=${mainline}${t}`sed -n -e $allhdrs /tmp/mt | tail -n1`
  30. echo dist $dist
  31. echo distheaders $distheaders prereq all $alld
  32. echo tip $tip
  33. echo tipheaders $tipheaders prereq all $allt
  34. mkdir -p ~/Downloads/mainline
  35. pushd ~/Downloads/mainline 2>/dev/null
  36. rm *.deb *.patch # install headers first for grub mkinitramfs
  37. for f in $alld $distheaders $dist $allt $tipheaders $tip ${tpatches[@]}
  38. do ff=`echo $f | sed -e 's/^.*\///'`
  39. [ -s "$ff" ] || wget $f
  40. [ -n "$ff" ] && [ -f $ff ] && [ -s $ff ] && \
  41. [ $ff != ${ff%.deb} ] && sudo dpkg -i $ff
  42. done
  43. popd 2>/dev/null
  44. fi
  45. fi
  46. rm -r /tmp/k /tmp/md /tmp/mt 2>/dev/null
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement