Commit 36915173 authored by Guido Gunther's avatar Guido Gunther

root.sh: quote variables

and remove unused ones
parent 1a44b569
......@@ -7,9 +7,8 @@
# distro and basedir set by calling script
basedir=$1
image_name=$2
cwd=`pwd`
basedir="$1"
image_name="$2"
target_qemu="${basedir}/${qemu}"
stamp="${basedir}/var/log/gitrev.log"
......@@ -50,13 +49,15 @@ esac
# bindmount qemu into the rootfs so we can chroot into it if needed
function setup_qemu()
{
[ -f ${target_qemu} ] || cp "${qemu}" "${target_qemu}"
[ -f "${target_qemu}" ] || cp "${qemu}" "${target_qemu}"
}
function setup_kernel()
{
local link="$(basename $basedir/boot/vmlinuz-*)"
local link
link=$(basename "${basedir}"/boot/vmlinuz-*)
rm -f "${basedir}/boot/zImage"
ln -s "${link}" "${basedir}/boot/zImage"
cp data/update-zImage-link "${basedir}/etc/kernel/postinst.d/"
......@@ -68,45 +69,44 @@ function setup_kernel()
function setup_uboot()
{
sed -e "s/##DTBNAME##/${fdt_file}/" data/boot-${pureos_board}.txt.in > $basedir/boot/boot.txt
mkimage -A arm -T script -O linux -d $basedir/boot/boot.txt $basedir/boot/boot.scr
ln -fs boot.scr $basedir/boot/6x_bootscript
sed -e "s/##DTBNAME##/${fdt_file}/" "data/boot-${pureos_board}.txt.in" > "${basedir}/boot/boot.txt"
mkimage -A arm -T script -O linux -d "${basedir}/boot/boot.txt" "${basedir}/boot/boot.scr"
ln -fs boot.scr "${basedir}/boot/6x_bootscript"
[ ! -d files/uboot-${pureos_board} ] || cp -a files/uboot-${pureos_board}/* $basedir/boot/
[ ! -d "files/uboot-${pureos_board}" ] || cp -a "files/uboot-${pureos_board}/"* "${basedir}/boot/"
}
function build_tarball()
{
tarball="$(basename ${image_name} .img)".tar.xz
pwd=$PWD
tarball=$(basename "${image_name}" .img).tar.xz
echo -n "Taring up rootfs to $PWD/$tarball..."
echo -n "Taring up rootfs to $PWD/${tarball}..."
tar --acl \
--exclude='./run/*' \
--exclude='./dev/*' \
--exclude='./sys/*' \
--exclude='./proc/*' \
-acf $PWD/$tarball -C $basedir .
-acf "${PWD}/${tarball}" -C "${basedir}" .
echo "Done."
}
function cleanup_chroot()
{
chroot $basedir apt-get clean
chroot "${basedir}" apt-get clean
rm $basedir/etc/resolv.conf
mv $basedir/etc/resolv.conf.bak $basedir/etc/resolv.conf
rm $basedir/usr/sbin/policy-rc.d
rm "${basedir}/etc/resolv.conf"
mv "${basedir}/etc/resolv.conf.bak" "${basedir}/etc/resolv.conf"
rm "${basedir}/usr/sbin/policy-rc.d"
umount $basedir/dev/pts
umount $basedir/dev
umount $basedir/sys
umount $basedir/proc
umount "${basedir}/dev/pts"
umount "${basedir}/dev"
umount "${basedir}/sys"
umount "${basedir}/proc"
# existence of stamp indicates success
if [ -f $stamp ]; then
if [ -f "${stamp}" ]; then
build_tarball
fi
}
......@@ -116,20 +116,20 @@ function prepare_chroot()
{
trap cleanup_chroot EXIT
mount -t proc chproc $basedir/proc
mount -t sysfs chsys $basedir/sys
mount -t devtmpfs chdev $basedir/dev || mount --bind /dev $basedir/dev
mount -t devpts chpts $basedir/dev/pts
echo -e '#!/bin/sh\nexit 101' > $basedir/usr/sbin/policy-rc.d
chmod 755 $basedir/usr/sbin/policy-rc.d
mv $basedir/etc/resolv.conf $basedir/etc/resolv.conf.bak
cp /etc/resolv.conf $basedir/etc
mount -t proc chproc "${basedir}/proc"
mount -t sysfs chsys "${basedir}/sys"
mount -t devtmpfs chdev "${basedir}/dev" || mount --bind /dev "${basedir}/dev"
mount -t devpts chpts "${basedir}/dev/pts"
echo -e '#!/bin/sh\nexit 101' > "${basedir}/usr/sbin/policy-rc.d"
chmod 755 "${basedir}/usr/sbin/policy-rc.d"
mv "${basedir}/etc/resolv.conf" "${basedir}/etc/resolv.conf.bak"
cp /etc/resolv.conf "${basedir}/etc"
}
function create_stamp()
{
git log --format=format:%H -1 > $stamp
git log --format=format:%H -1 > "${stamp}"
}
......@@ -137,22 +137,22 @@ function setup_gui()
{
# Allow purism user to launch weston from the console, etc.
for group in weston-launch video audio; do
chroot $basedir adduser purism $group
chroot "${basedir}" adduser purism "${group}"
done
# Will move into a debian package once we have build infra
cp data/weston.service $basedir/etc/systemd/system/
chroot $basedir systemctl enable weston.service
cp data/weston.service "${basedir}/etc/systemd/system/"
chroot "${basedir}" systemctl enable weston.service
}
function setup_journal()
{
# Enable systemd journal
chroot $basedir mkdir -p /var/log/journal
chroot $basedir systemd-tmpfiles --create --prefix /var/log/journal
chroot $basedir apt-get -y remove rsyslog
chroot "${basedir}" mkdir -p /var/log/journal
chroot "${basedir}" systemd-tmpfiles --create --prefix /var/log/journal
chroot "${basedir}" apt-get -y remove rsyslog
for l in daemon messages syslog kern mail user; do
chroot $basedir rm -f /var/log/${l}.*
chroot "${basedir}" rm -f /var/log/${l}.*
done
}
......@@ -163,8 +163,8 @@ function setup_sshd()
# Generate new host keys on first boot
cp data/gen-sshd-host-keys "${basedir}/usr/local/bin/"
cp data/sshd-host-keys.service "${basedir}/etc/systemd/system/"
chroot $basedir systemctl enable sshd-host-keys.service
chroot $basedir rm -f /etc/ssh/ssh_host_*
chroot "${basedir}" systemctl enable sshd-host-keys.service
chroot "${basedir}" rm -f /etc/ssh/ssh_host_*
}
......@@ -182,15 +182,15 @@ function install_pkgs()
export LANGUAGE=C
export LANG=C
chroot $basedir apt-get -y update
chroot $basedir apt-get -y install $packages
chroot "${basedir}" apt-get -y update
chroot "${basedir}" apt-get -y install ${packages}
)
}
function setup_apt()
{
cat << EOF > $basedir/etc/apt/sources.list
cat << EOF > "${basedir}/etc/apt/sources.list"
deb http://$mirror/debian $distro main contrib non-free
deb-src http://$mirror/debian $distro main contrib non-free
deb http://$mirror/debian $distro-updates main contrib non-free
......@@ -199,7 +199,7 @@ deb http://security.debian.org/debian-security $distro/updates main contrib non-
deb-src http://security.debian.org/debian-security $distro/updates main contrib non-free
EOF
cat << EOF > $basedir/etc/apt/apt.conf.d/71-no-recommends
cat << EOF > "${basedir}/etc/apt/apt.conf.d/71-no-recommends"
APT::Install-Recommends "0";
APT::Install-Suggests "0";
EOF
......@@ -208,7 +208,7 @@ EOF
function setup_network()
{
cat << EOF > $basedir/etc/hosts
cat << EOF > "${basedir}/etc/hosts"
127.0.0.1 pureos localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
......@@ -217,7 +217,7 @@ ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
EOF
cat << EOF > $basedir/etc/network/interfaces
cat << EOF > "${basedir}/etc/network/interfaces"
auto lo
iface lo inet loopback
......@@ -228,8 +228,8 @@ EOF
# Don't setup resolv.conf if it's a symlink
# DHCP will later handle this just fine
if [ -f $basedir/etc/resolv.conf ]; then
cat <<EOF > $basedir/etc/resolv.conf
if [ -f "${basedir}/etc/resolv.conf" ]; then
cat <<EOF > "${basedir}/etc/resolv.conf"
nameserver 208.67.220.220
nameserver 208.67.222.222
EOF
......@@ -237,14 +237,14 @@ EOF
}
# create the directories so that this script can be tested without the generated filesystem
mkdir -p $basedir/etc/apt/apt.conf.d/
mkdir -p $basedir/etc/network
mkdir -p "${basedir}/etc/apt/apt.conf.d/"
mkdir -p "${basedir}/etc/network"
export MALLOC_CHECK_=0 # workaround for LP: #520465
export LC_ALL=C
export DEBIAN_FRONTEND=noninteractive
cat << EOF > $basedir/debconf.set
cat << EOF > "${basedir}/debconf.set"
console-common console-data/keymap/policy select Select keymap from full list
console-common console-data/keymap/full select en-latin1-nodeadkeys
EOF
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment