summaryrefslogtreecommitdiffstats
path: root/functions
diff options
context:
space:
mode:
authorDave Reisner <d@falconindy.com>2011-06-05 21:42:09 +0200
committerDave Reisner <d@falconindy.com>2011-06-16 20:19:12 +0200
commitb117e2ae0cf948d4afe59eee6e503f30f184ddba (patch)
tree862a994d1a7a1302814981bf9ba2b5a4f4a88e63 /functions
parent3efc8b39b126c6eaaedcc1585a17105a5ab67a8f (diff)
downloadmkinitcpio-b117e2ae0cf948d4afe59eee6e503f30f184ddba.tar.gz
mkinitcpio-b117e2ae0cf948d4afe59eee6e503f30f184ddba.tar.xz
use bsdcpio to create images
This is a departure from using gen_init_cpio, which proved to be a huge bottleneck in performance. Tests for existance change from being a call to grep, to a simple shell test. In the process, we have to modify the behavior of the -s option, and we lose the -a option. Signed-off-by: Dave Reisner <d@falconindy.com>
Diffstat (limited to 'functions')
-rw-r--r--functions41
1 files changed, 18 insertions, 23 deletions
diff --git a/functions b/functions
index dc20566..662df7b 100644
--- a/functions
+++ b/functions
@@ -79,12 +79,12 @@ checked_modules ()
add_full_dir ()
{
- if [ -n "${1}" -a -d "${1}" ]; then
- for f in ${1}/*; do
- if [ -d "${f}" ]; then
- add_full_dir "${f}"
+ if [[ -n $1 && -d $1 ]]; then
+ for f in "$1"/*; do
+ if [[ -d "$f" ]]; then
+ add_full_dir "$f"
else
- add_file "${f}"
+ add_file "$f"
fi
done
fi
@@ -92,28 +92,23 @@ add_full_dir ()
add_dir ()
{
- #skip root directory and "." for relative directories... i.e. /foo/bar/./blah
- if [ -n "${1}" -a "${1}" != "/" -a "${1}" != "." ]; then
- if ! grep -q "dir ${1} " "${FILELIST}"; then
- add_dir $(get_dirname "${1}")
- msg " adding dir ${1}"
- echo "dir ${1} 755 0 0" >> "${FILELIST}"
- fi
+ if [[ ! -e "$TMPDIR/root/$1" ]]; then
+ msg " adding dir ${1}"
+ command install -dm755 "$TMPDIR/root/$1"
fi
}
-# what the hell does this do?
add_symlink ()
{
local fil dest dir
- if [ -h ${1} ]; then
+ if [[ -h $1 ]]; then
fil="${1##$BASEDIR}"
dest="${2##$BASEDIR}"
add_dir $(get_dirname "${dest}")
add_dir $(get_dirname "${fil}")
- if ! grep -q "slink ${fil} " "${FILELIST}"; then
+ if [[ ! -e "$TMPDIR/root/$dest" ]]; then
msg " adding link ${fil} -> ${dest}"
- echo "slink ${fil} ${dest} $(stat -c '%a' ${1}) 0 0" >> "${FILELIST}"
+ ln -s "$dest" "$TMPDIR/root/$fil"
fi
fi
#fail quietly
@@ -122,27 +117,27 @@ add_symlink ()
add_file ()
{
local fil lnk dir dest
- if [ -f "${1}" ]; then
- fil="${1}"
+ if [[ -f "$1" ]]; then
+ fil=$1
lnk=$(readlink -f "${fil}")
- if [ -n "${lnk}" ]; then
+ if [[ ${lnk} ]]; then
add_symlink "${fil}" "${lnk}"
fil="${lnk}"
fi
if [[ $2 ]]; then
- dest="${2}"
+ dest=$2
else
dest="${fil##$BASEDIR}"
- if [ "${dest}" = "${dest#/}" ]; then
+ if [[ "${dest}" = "${dest#/}" ]]; then
dest="/${dest}"
fi
fi
add_dir $(get_dirname "${dest}")
- if ! grep -q "file ${dest} " "${FILELIST}"; then
+ if [[ ! -e $TMPDIR/root/$dest ]]; then
msg " adding file ${dest}"
- echo "file ${dest} ${fil} $(stat -c '%a' ${fil}) 0 0" >> "${FILELIST}"
+ command install -Dm$(stat -c '%a' "$fil") "$fil" "$TMPDIR/root/$dest"
fi
else
err "file '${1}' does not exist"