Debian Codegraph @

scripts/install.sh

raw symbols SCIP
1 #! /bin/sh
2 # SPDX-License-Identifier: MIT
3 # Copyright (c) 2024 Linaro Ltd.
4 #
5 # Install DSP shell and libraries
6
7 set -e
8
9 if [ "$#" -ne 2 -o "$1" = "-h" -o "$1" = "--help" ]
10 then
11 echo "Usage: $0 config.txt <destdir>" >&2
12 exit 1
13 fi
14
15 CFG="$1"
16 DST="$2"
17
18 if ! [ -r "${CFG}" ]
19 then
20 echo "config ${CFG} is unreadable" >&2
21 exit 1
22 fi
23
24 mkdir -p "${DST}"
25
26 # dstdir srcdir
27 do_licence() {
28 found=0
29 while read line ; do
30 [ "$line" = "Dir: $2" ] && break
31 done
32 while read line ; do
33 lic=${line##Licence: }
34 if [ "$lic" != "$line" ]
35 then
36 install -m 0644 $lic "$1" || exit 1
37 found=1
38 break
39 fi
40 done
41 if [ $found -eq 0 ] ; then
42 echo "License for $2 not found"
43 exit 1
44 fi
45 }
46
47 # dest subdir DSP QC_IMAGE_VERSION_STRING
48 # FIXME: maybe install only a fixed set of files
49 do_install() {
50 local srcdir="$2/$4"
51 local dstdir="$1/$2/dsp/$3"
52
53 mkdir -p "${dstdir}"
54 install -m 0644 "${srcdir}"/* "${dstdir}"
55
56 do_licence "${dstdir}" "${srcdir}" < WHENCE
57 }
58
59 # dest target link
60 do_link() {
61 local target="$1/$2"
62 local link="$1/$3"
63
64 mkdir -p "`dirname "${link}"`"
65 rm -f "${link}"
66 ln -sr -T "${target}" "${link}"
67 }
68
69 grep -v '^#\|^$' "${CFG}" | while read verb rest
70 do
71 case ${verb} in
72 "Install:" )
73 do_install ${DST} ${rest}
74 ;;
75 "Link:" )
76 do_link ${DST} ${rest}
77 ;;
78 * )
79 echo "Unsupported clause ${verb}" >&2
80 exit 1
81 esac
82 done