summaryrefslogtreecommitdiff
path: root/sub/layout/copylayout
blob: 01e15743de12dd70e3f489051d8cd2c5283ca1c7 (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
#!/bin/sh -e

output="$1"

s6-hiercopy layout/rootfs $output/rootfs
chown -R 0:0 $output/rootfs $output/rwfs $output/userfs
find "$output/rootfs" -type f -name .empty -size 0c -exec s6-rmrf {} \;
s6-hiercopy layout/rwfs $output/rwfs
find "$output/rwfs" -type f -name .empty -size 0c -exec s6-rmrf {} \;
s6-hiercopy layout/userfs $output/userfs
find "$output/userfs" -type f -name .empty -size 0c -exec s6-rmrf {} \;

buildtime=$(s6-clock)

hostarch=$(s6-echo -- $TRIPLE | cut -f1 -d-)
sed -i -e "s/%%HOSTNAME%%/lh-$hostarch/g" $output/rootfs/etc/motd $output/rootfs/etc/issue.net $output/rootfs/root/.execline-shell $output/rootfs/etc/s6-rc/source-base/00/up

while read file user group perms ; do
  if s6-test -n "$file" -a "$file" != "#" ; then
    $output/build-build/command/s6-chown -u $user -g $group -- $output/$file
    $output/build-build/command/s6-chmod $perms $output/$file
  fi
done < sub/layout/permissions

# If dynamic: copy shared libs from the toolchain into the target

if ! ${BUILD_HOST_STATIC} ; then
  sysroot=`${BUILD_HOST_CC} -print-sysroot`
  for lib in lib lib32 lib64 ; do
    if s6-test -d "$sysroot/$lib" ; then
      s6-mkdir -p "$output/rootfs/$lib"
      for i in `ls -1 "$sysroot/$lib" | grep -e '\.so$' -e '\.so\.'` ; do
        s6-hiercopy "$sysroot/$lib/$i" "$output/rootfs/$lib/$i"
      done
    fi
  done
fi