summaryrefslogtreecommitdiff
path: root/community/virtualbox-modules-lts/build.sh
blob: b5c163db90995af44426dfecc137c0182ae1fc08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
# lazyness can be enhanced everyday

usage() {
  echo "usage: $0 extra"
  echo "       $0 testing"
  exit 1
}

# $1: reference package
update() {
  url="https://www.archlinux.org/packages/$1/x86_64/$2/"
  curkernel=$(wget -qO- "$url"|sed -nr "s/.*<h2>$2 ([0-9]+)\.([0-9]+).*<\/h2>.*/\1.\2/p")
  nextkernel=${curkernel%.*}.$(( ${curkernel#*.}+1))

  echo "** Current kernel: $curkernel"
  echo "** Next kernel: $nextkernel"

  sed -ri \
    -e "s/(_?extramodules=).*-(ARCH|lts).*/\1extramodules-$curkernel-\2/i" \
    -e "s/(linux.*>=)[0-9]+.[0-9]+/\1$curkernel/" \
    -e "s/(linux.*<)[0-9]+.[0-9]+/\1$nextkernel/" \
    PKGBUILD *.install
}

# $1: repo
# $2: arch
build() {
  _pwd=$PWD
  cd /var/empty
  makechrootpkg -cu -I "$_pwd"/../../virtualbox/trunk/virtualbox-host-dkms-*-$arch.pkg.tar.xz -r "$1"
  makechrootpkg -I "$_pwd"/../../virtualbox/trunk/virtualbox-guest-dkms-*-$arch.pkg.tar.xz  -r "$1"
  cd "$_pwd"
  makechrootpkg -n -r "$1"
}

(( $# == 1 )) || usage

# detect lts case
grep -q linux-lts PKGBUILD && suf=-lts

case $1 in
  extra)
    update core linux$suf-headers
    for arch in i686 x86_64; do
      build /var/lib/archbuild/extra-$arch $arch
    done
  ;;
  testing)
    update testing linux$suf-headers
    for arch in i686 x86_64; do
      build /var/lib/archbuild/testing-$arch $arch
    done
  ;;
  *)
    usage
  ;;
esac

# vim:set ts=2 sw=2 ft=sh et: