summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/recipes-devtools/e2fsprogs/e2fsprogs-1.42.8/populate-extfs.sh96
-rw-r--r--meta/recipes-devtools/e2fsprogs/e2fsprogs_1.42.8.bb1
2 files changed, 97 insertions, 0 deletions
diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs-1.42.8/populate-extfs.sh b/meta/recipes-devtools/e2fsprogs/e2fsprogs-1.42.8/populate-extfs.sh
new file mode 100644
index 0000000000..9eff030820
--- /dev/null
+++ b/meta/recipes-devtools/e2fsprogs/e2fsprogs-1.42.8/populate-extfs.sh
@@ -0,0 +1,96 @@
1#!/bin/sh
2
3do_usage () {
4 cat << _EOF
5Usage: populate-extfs.sh <source> <device>
6Create an ext2/ext3/ext4 filesystem from a directory or file
7
8 source: The source directory or file
9 device: The target device
10
11_EOF
12 exit 1
13}
14
15[ $# -ne 2 ] && do_usage
16
17SRCDIR=${1%%/}
18DEVICE=$2
19DEBUGFS="debugfs"
20
21{
22 CWD="/"
23 find $SRCDIR | while read FILE; do
24 TGT="${FILE##*/}"
25 DIR="${FILE#$SRCDIR}"
26 DIR="${DIR%$TGT}"
27
28 # Skip the root dir
29 [ ! -z "$DIR" ] || continue
30 [ ! -z "$TGT" ] || continue
31
32 if [ "$DIR" != "$CWD" ]; then
33 echo "cd $DIR"
34 CWD="$DIR"
35 fi
36
37 # Only stat once since stat is a time consuming command
38 STAT=$(stat -c "TYPE=\"%F\";DEVNO=\"0x%t 0x%T\";MODE=\"%f\";U=\"%u\";G=\"%g\"" $FILE)
39 eval $STAT
40
41 case $TYPE in
42 "directory")
43 echo "mkdir $TGT"
44 ;;
45 "regular file" | "regular empty file")
46 echo "write $FILE $TGT"
47 ;;
48 "symbolic link")
49 LINK_TGT=$(readlink $FILE)
50 echo "symlink $TGT $LINK_TGT"
51 ;;
52 "block special file")
53 echo "mknod $TGT b $DEVNO"
54 ;;
55 "character special file")
56 echo "mknod $TGT c $DEVNO"
57 ;;
58 "fifo")
59 echo "mknod $TGT p"
60 ;;
61 *)
62 echo "Unknown/unhandled file type '$TYPE' file: $FILE" 1>&2
63 ;;
64 esac
65
66 # Set the file mode
67 echo "sif $TGT mode 0x$MODE"
68
69 # Set uid and gid
70 echo "sif $TGT uid $U"
71 echo "sif $TGT gid $G"
72 done
73
74 # Handle the hard links.
75 # Save the hard links to a file, use the inode number as the filename, for example:
76 # If a and b's inode number is 6775928, save a and b to /tmp/tmp.VrCwHh5gdt/6775928.
77 INODE_DIR=`mktemp -d` || exit 1
78 for i in `find $SRCDIR -type f -links +1 -printf 'INODE=%i###FN=%p\n'`; do
79 eval `echo $i | sed 's$###$ $'`
80 echo ${FN#$SRCDIR} >>$INODE_DIR/$INODE
81 done
82 # Use the debugfs' ln and "sif links_count" to handle them.
83 for i in `ls $INODE_DIR`; do
84 # The link source
85 SRC=`head -1 $INODE_DIR/$i`
86 # Remove the files and link them again except the first one
87 for TGT in `sed -n -e '1!p' $INODE_DIR/$i`; do
88 echo "rm $TGT"
89 echo "ln $SRC $TGT"
90 done
91 LN_CNT=`cat $INODE_DIR/$i | wc -l`
92 # Set the links count
93 echo "sif $SRC links_count $LN_CNT"
94 done
95 rm -fr $INODE_DIR
96} | $DEBUGFS -w -f - $DEVICE
diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs_1.42.8.bb b/meta/recipes-devtools/e2fsprogs/e2fsprogs_1.42.8.bb
index b54c6a7685..154b864c12 100644
--- a/meta/recipes-devtools/e2fsprogs/e2fsprogs_1.42.8.bb
+++ b/meta/recipes-devtools/e2fsprogs/e2fsprogs_1.42.8.bb
@@ -44,6 +44,7 @@ do_install_append () {
44 mv ${D}${base_libdir}/e2initrd_helper ${D}${libdir} 44 mv ${D}${base_libdir}/e2initrd_helper ${D}${libdir}
45 mv ${D}${base_libdir}/pkgconfig ${D}${libdir} 45 mv ${D}${base_libdir}/pkgconfig ${D}${libdir}
46 fi 46 fi
47 install -m 0755 ${WORKDIR}/populate-extfs.sh ${D}${bindir}
47} 48}
48 49
49RDEPENDS_e2fsprogs = "e2fsprogs-badblocks" 50RDEPENDS_e2fsprogs = "e2fsprogs-badblocks"