summaryrefslogtreecommitdiffstats
path: root/inc/env.setup-sqfs-base.sh
blob: b2c4c383df1dbbfb836e86959468274c43f1777f (plain) (blame)
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
#!/bin/bash

ROOT_DIR=$(readlink -f $(dirname $(readlink -f $0))/..)

. ${ROOT_DIR}/config/paths.conf

mkdir -p ${ROOT_DIR}/build/sqfs-base
cd ${ROOT_DIR}/build/sqfs-base

[ ! -f ${BUILDROOT_OUT_PATH}/rootfs.tar ] && \
  echo "ERROR: rootfs.tar not found in BUILDROOT_OUT_PATH (${BUILDROOT_OUT_PATH})." && \
  echo "       check if buildroot run successful and if path in config/paths.conf is correct." && \
  exit 1

if [ ! -f .osib_unpacked ]; then
  tar xf ${BUILDROOT_OUT_PATH}/rootfs.tar
  touch .osib_unpacked
fi

rm -f run var/cache var/log var/lock var/pcmcia var/run var/spool var/tmp

mkdir -p run var/log/journal

tar xzf ${ROOT_DIR}/share/files/dev.tgz

if [ ! -f .osib_moved_libs ]; then
  for f in $(find {lib,usr/lib} |grep "\.so\(\..*\|$\)"); do
    targetdir=$(dirname $f)
    if [ ! -d openslx/$targetdir ]; then
      #echo "creating openslx/$targetdir"
      mkdir -p openslx/$targetdir
    fi
    mv $f openslx/$f
  done
  touch .osib_moved_libs
fi

if [ ! -f .osib_create_ld_links ]; then
    echo "create ld-*.so links from /lib"
    for f in $(ls -1 openslx/lib/ld*); do
       ln -sf "../$f" "lib/$(basename $f)"
    done
    touch .osib_create_ld_links
fi


if [ ! -f .osib_moved_bins ]; then
    for d in $(find {bin,sbin,usr/bin,usr/sbin,usr/local/bin,usr/local/sbin} -type d); do
      #echo $d
      mkdir -p "openslx/$d"
      mv $d/* openslx/$d/
    done
    touch .osib_moved_bins
fi

ln -sf /usr/lib/systemd/systemd init

if [ ! -f .osib_patched ]; then
   for p in $(ls -1 ${ROOT_DIR}/share/patches/* | sort); do
      patch -p1 < $p
   done
   touch .osib_patched
fi

cp ${ROOT_DIR}/share/files/*.service etc/systemd/system/
ln -sf ../debug-shell.service etc/systemd/system/sysinit.target.wants/
ln -sf /usr/lib/systemd/system/getty\@.service etc/systemd/system/getty.target.wants/getty\@tty2.service
ln -sf /usr/lib/systemd/system/getty\@.service etc/systemd/system/getty.target.wants/getty\@tty3.service
ln -sf /usr/lib/systemd/system/getty\@.service etc/systemd/system/getty.target.wants/getty\@tty4.service
ln -sf /usr/lib/systemd/system/getty\@.service etc/systemd/system/getty.target.wants/getty\@tty5.service
ln -sf /usr/lib/systemd/system/getty\@.service etc/systemd/system/getty.target.wants/getty\@tty6.service


ln -sf /openslx/bin/login bin/login
ln -sf /openslx/bin/sh bin/sh
ln -sf /openslx/bin/hostname bin/hostname

cp ${ROOT_DIR}/share/files/profile etc
cp ${ROOT_DIR}/share/files/helper helper
chmod +x helper

sed -i -e "s,81:81,102:105," etc/passwd
sed -i -e "s,81,105," etc/group