blob: f005892405acb506e9c4f2f14fa7edee4a9b0917 (
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
|
# Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Syntax is:
# * install_iserial $ID $IMAGE_MOUNTPOINT
# * unpack_image $IMAGE... $IMAGE_UNPACKED
# * mount_image $IMAGE $MOUNTPOINT
# * unmount_image $MOUNTPOINT
#
# Author: Aleksander Mistewicz <a.mistewicz@samsung.com>
install_iserial() {
test -n "${TESTLAB_SCRIPTS}" || die "Missing env: testlab_scripts!"
ID="$1"
IMAGE_MOUNTPOINT="$2"
test -n "${ID}" || die "Missing argument: id!"
test -n "${IMAGE_MOUNTPOINT}" || die "Missing argument: image_mountpoint!"
sudo sh -c "echo -n \"${ID}\" > \"${IMAGE_MOUNTPOINT}/etc/id\""
sudo cp "${TESTLAB_SCRIPTS}/prepare/iserial.service" \
"${IMAGE_MOUNTPOINT}/usr/lib/systemd/system/"
sudo cp "${TESTLAB_SCRIPTS}/prepare/iserial.sh" "${IMAGE_MOUNTPOINT}/usr/sbin/"
sudo ln -s /usr/lib/systemd/system/iserial.service \
"${IMAGE_MOUNTPOINT}/usr/lib/systemd/system/multi-user.target.wants/iserial.service"
}
install_iserial_artik() {
test -n "${TESTLAB_SCRIPTS}" || die "Missing env: testlab_scripts!"
ID="$1"
IMAGE_MOUNTPOINT="$2"
test -n "${ID}" || die "Missing argument: id!"
test -n "${IMAGE_MOUNTPOINT}" || die "Missing argument: image_mountpoint!"
sudo sh -c "echo -n \"${ID}\" > \"${IMAGE_MOUNTPOINT}/etc/id\""
sudo cp "${TESTLAB_SCRIPTS}/prepare/direct_set_debug.sh" "${IMAGE_MOUNTPOINT}/usr/bin/"
sudo cp "${TESTLAB_SCRIPTS}/prepare/sdb-prestart.timer" "${TESTLAB_SCRIPTS}/prepare/sdb-prestart.service" \
"${IMAGE_MOUNTPOINT}/usr/lib/systemd/system/"
sudo cp "${TESTLAB_SCRIPTS}/prepare/iserial.sh" "${IMAGE_MOUNTPOINT}/usr/sbin/"
sudo ln -s /usr/lib/systemd/system/sdb-prestart.timer \
"${IMAGE_MOUNTPOINT}/usr/lib/systemd/system/multi-user.target.wants/sdb-prestart.timer"
}
install_hdmi_force() {
test -n "${TESTLAB_SCRIPTS}" || die "Missing env: testlab_scripts!"
IMAGE_MOUNTPOINT="$1"
test -n "${IMAGE_MOUNTPOINT}" || die "Missing argument: image_mountpoint!"
sudo cp "${TESTLAB_SCRIPTS}/prepare/hdmi_force.sh" "${IMAGE_MOUNTPOINT}/usr/sbin/"
sudo sed -i 's|^ExecStart|ExecStartPre=/usr/sbin/hdmi_force.sh\nExecStart|' \
"${IMAGE_MOUNTPOINT}/usr/lib/systemd/system/display-manager.service"
}
set_usb_mode() {
IMAGE_MOUNTPOINT="$1"
test -n "${IMAGE_MOUNTPOINT}" || die "Missing argument: image_mountpoint!"
sudo sed -i 's|^ExecStart|ExecStartPre=/usr/bin/vconftool set -f -t int db/usb/sel_mode 4\nExecStart|' \
"${IMAGE_MOUNTPOINT}/usr/lib/systemd/system/deviced.service"
}
replace_params() {
test -n "${TESTLAB_SCRIPTS}" || die "Missing env: testlab_scripts!"
IMAGE_MOUNTPOINT="$1"
ARTIK_MODEL="$2"
test -n "${IMAGE_MOUNTPOINT}" || die "Missing argument: image_mountpoint!"
test -n "${ARTIK_MODEL}" || die "Missing argument: artik_model!"
sudo cp "${TESTLAB_SCRIPTS}/prepare/params_${ARTIK_MODEL}" "${IMAGE_MOUNTPOINT}/params.bin"
}
unpack_image() {
test $# -ge 2 || die "Too few arguments!"
eval DESTINATION=\$$#
test -d "${DESTINATION}" || mkdir -p "${DESTINATION}"
while [ $# -ge 2 ]; do
IMAGE="$1"
test -f "${IMAGE}" || die "The image does not exist or is not a regular file: ${IMAGE}!"
tar xvf "${IMAGE}" -C "${DESTINATION}" || die "tar: extracting files from archive failed!"
shift
done
}
mount_image() {
IMAGE="$1"
MOUNTPOINT="$2"
test -n "${IMAGE}" || die "Missing argument: image"
test -n "${MOUNTPOINT}" || die "Missing argument: mountpoint"
test -d "${MOUNTPOINT}" || mkdir -p "${MOUNTPOINT}"
sudo mount -o loop "${IMAGE}" "${MOUNTPOINT}"
}
unmount_image() {
MOUNTPOINT="$1"
test -n "${MOUNTPOINT}" || die "Missing argument: mountpoint"
sudo umount -d "${MOUNTPOINT}"
}
|