release.sh: add support for meson projects
[xorg-util-modular.git] / update-moduleset.sh
blob691402e729b6d1249a09f0b1e759cfcb0401e541
1 #!/bin/sh
3 module=
4 version=
6 usage()
8 cat <<EOF
9 Usage: `basename $0` MODULESET SHA1SUM TARBALL
11 Updates the module associated to TARBALL in MODULESET.
12 EOF
15 # check input arguments
16 moduleset=$1
17 sha1sum=$2
18 tarball=$3
19 if [ -z "$moduleset" ] || [ -z "$sha1sum" ] || [ -z "$tarball" ]; then
20 echo "error: Not enough arguments" >&2
21 usage >&2
22 exit 1
25 # check that the moduleset exists and is writable
26 if [ ! -w "$moduleset" ]; then
27 echo "error: moduleset \"$moduleset\" does not exist or is not writable" >&2
28 exit 1
31 # we only want the tarball name
32 tarball=`basename $tarball`
34 # pull the module and version from the tarball
35 module=${tarball%-*}
36 version=${tarball##*-}
37 version=${version%.tar*}
39 # sometimes the jhbuild id doesn't match the tarball name
40 module_id=$module
41 case "$module" in
42 xorg-server)
43 module_id=xserver
45 util-macros)
46 module_id=macros
48 libXres)
49 module_id=libXRes
51 xtrans)
52 module_id=libxtrans
54 xbitmaps)
55 module_id=bitmaps
57 MesaLib)
58 module_id=libGL
60 xcursor-themes)
61 module_id=cursors
63 libpthread-stubs)
64 module_id=pthread-stubs
66 xproto)
67 module_id=x11proto
69 esac
71 # edit the moduleset
72 sed -i \
73 "/id=\"$module_id\"/{
74 # read the next line until we get />, which should be the end
75 # of the branch tag
76 :next
78 /\/>$/!b next
80 # update the info
81 s/$module-[^\"]*\"/$tarball\"/
82 s/version=\"[^\"]*\"/version=\"$version\"/
83 s/hash=\"[^\"]*\"/hash=\"sha1:$sha1sum\"/
84 }" "$moduleset"