Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/update-archlinux32-package
blob: 33c9549c59a4c0c7d6be4b2c1bd023c3e4befbb7 (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/bash

git_repo_path='/usr/src/archlinux32/packages/'
vagrant_path=$(
  readlink -f ~/"virtual-boxes/archlinux32-test"
)
base_dir=$(
  dirname "$(
    readlink -f "$0"
  )"
)
pkgname="$1"

update_checksum() {
  checksums=$(
    ssh arch32-test '
      cd '"${pkgname}"'
      makepkg -g
    ' | \
      sed '
        $! s/$/\\n/
      ' | \
      tr -d '\n'
  )
  sed -i '
    /^\S\+sums=(/{
      :a
      N
      /)/!ba
      s/^\S\+sums=(.*)/'"${checksums}"'/
    }
  ' "${git_repo_path}/${repo}/${pkgname}/PKGBUILD"
}

if [ $# -ne 1 ]; then
  >&2 echo 'usage: update-archlinux32-package $pkgname'
  exit
fi

if [ "${pkgname}" != 'linux-pae' ]; then
  >&2 echo 'sry, this is not yet implemented - I only know "linux-pae".'
  exit
fi

infos=$(
  "${base_dir}/watch-versions" "${pkgname}"
)

if [ -z "${infos}" ]; then
  >&2 echo 'Nothing to do.'
  exit
fi

old_pkgver=$(
  printf '%s\n' "${infos}" | \
    cut -d' ' -f4
)

new_pkgver=$(
  printf '%s\n' "${infos}" | \
    cut -d' ' -f2
)

repo=$(
  readlink -f "${git_repo_path}"*"/${pkgname}" | \
    cut -d/ -f6
)

sed -i '
  s/^pkgver=.*$/pkgver='"'${new_pkgver}'"'/
  s/^pkgrel=.*$/pkgrel='"'1'"'/
' "${git_repo_path}/${repo}/${pkgname}/PKGBUILD"

if ssh -o ConnectTimeout=1 arch32-test true; then
  vm_is_running=true
else
  vm_is_running=false
fi

if ! ${vm_is_running}; then
  cd "${vagrant_path}"
  vagrant up
fi

scp -r "${git_repo_path}/${repo}/${pkgname}" 'arch32-test:'
update_checksum

case "${pkgname}" in
  'linux-pae')
    scp "${git_repo_path}/${repo}/${pkgname}/PKGBUILD" 'arch32-test:'"${pkgname}/"
    ssh arch32-test '
      cd '"${pkgname}"'
      sed -i '"'"'
        /make oldconfig/ s/^\s*#//
        s/^}$/return 1\n\0/
      '"'"' PKGBUILD
      makepkg -fcrs --asdeps --noconfirm
      cp src/linux-'"${new_pkgver}"'/.config config
    '
    update_checksum
    scp 'arch32-test:'"${pkgname}"'/config' "${git_repo_path}/${repo}/${pkgname}/"
    git -C "${git_repo_path}/${repo}/${pkgname}" add 'PKGBUILD' 'config'
  ;;
  *)
    >&2 printf 'Whoops, I thought I knew %s, but apparently I don'"'"'t.\n' \
      "${pkgname}"
    exit
  ;;
esac
ssh arch32-test 'rm -rf --one-file-system '"${pkgname}"

git -C "${git_repo_path}" commit -m "${repo}/${pkgname}: ${old_pkgver} -> ${new_pkgver}"

if ! ${vm_is_running}; then
  ssh arch32-test 'sudo poweroff'
fi