Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

avoid using public API from within the API itself

Reusing public API calls is lazy and effective when run with an empty
$basedir, but it's just pain and misery otherwise. This is for the best,
as it actually cuts back on callstack abuse.
  • Loading branch information...
commit e37a45408e2e20ece14e95ba30b848cb7995b343 1 parent df47890
@falconindy authored
Showing with 23 additions and 18 deletions.
  1. +2 −2 geninit
  2. +21 −16 geninit.api
View
4 geninit
@@ -192,11 +192,11 @@ __build_image() { # {{{
done
# only create depmod files if there's modules added
- if [[ -d $buildroot/lib/modules/$kernver ]]; then
+ if [[ -d $buildroot$moduledir ]]; then
info "Generating module dependencies"
depmod -b "$buildroot" "$kernver"
# trim excess depmod files
- rm "$buildroot/lib/modules/$kernver"/modules.!(dep|alias|symbols)
+ rm "$buildroot$moduledir"/modules.!(dep|alias|symbols)
fi
if (( dryrun )); then
View
37 geninit.api
@@ -46,7 +46,7 @@ add_file() { # {{{
#add_path_to_file "$dest"
- __add_file "$dest" "$src" "$mode"
+ __add_file "${dest#$basedir}" "$src" "$mode"
} # }}}
add_symlink() { # {{{
@@ -76,24 +76,25 @@ add_module() { # {{{
(( $# )) || return 1
local -a firmware moddeps
- local modpath= module= dep=
+ local modpath= module= mod= dep=
module=${1%.ko?(.gz)}
if [[ -z $basedir ]]; then # fast path =)
read -rd '' modpath < <(kmodinfo -n "$module" 2>/dev/null)
else # slow path =(
- read -rd '' modpath < <(find "$basedir$moduledir/kernel" -type f -name "$mod.ko" -o -name "$mod.ko.gz" -print0)
+ read -rd '' modpath < <(find "$basedir$moduledir/kernel" -type f \
+ -name "$module.ko" -o -name "$module.ko.gz" -print0)
fi
- [[ -z $modpath ]] && return 1
+ [[ -z $modpath ]] && { echo 'modpath no eist'; return 1; }
- add_file "$modpath" || return 1
+ __add_file "${modpath#$basedir}" "$modpath" 644 || return 1
# grab firmware
IFS=',' read -rd '' -a firmware < <(kmodinfo -F firmware "$modpath")
for fw in "${firmware[@]}"; do
- add_file "/lib/firmware/$fw"
+ __add_file "/lib/firmware/$fw" "/lib/firmware/$fw" 644
done
# resolve deps
@@ -119,11 +120,13 @@ add_binary() { # {{{
[[ -f $basedir$1 ]] || { err "$1 not found"; return 1; }
local -a sodeps
- local binary=$basedir$1 sodep= resolved=
+ local binary=$basedir$1 mode= sodep= resolved= dirname=
+
+ mode=$(stat -c %a "$binary")
if ! "$ld_so" --verify "$binary"; then
# this isn't a binary!
- add_file "$binary"
+ __add_file "${binary#$basedir}" "$binary" "$mode"
return $? # return with add_file's return val
fi
@@ -134,22 +137,24 @@ add_binary() { # {{{
[[ -e $sodep ]] || continue
if [[ -f $sodep ]]; then # but wait! a symlink is a regular file! FFFUUUUU
+ mode=$(stat -c %a "$sodep")
if [[ ! -L $sodep ]]; then
- add_file "$sodep"
+ __add_file "$sodep"
else
- resolved="$(readlink -e "$sodep")"
- __add_dir "${resolved%/*}" 755
- __add_slink "$sodep" "$resolved"
- add_file "$resolved"
+ resolved=$(readlink -e "$basedir$sodep")
+ dirname=${resolved%/*}
+ __add_dir "${dirname#$basedir}" 755
+ __add_slink "$sodep" "${resolved#$basedir}"
+ __add_file "$resolved" "$resolved" 755
fi
fi
done
# the binary itself
- add_file "$basedir$1" "${2:-$1}"
+ __add_file "${1#$basedir}" "$1" 755
# we always need the big bad linker
- __add_slink "$ld_so" $(readlink -e "$ld_so")
+ __add_slink "$ld_so" "$(readlink -e "$ld_so")"
add_file "$(readlink -e "$ld_so")"
} # }}}
@@ -180,7 +185,7 @@ add_driver_classes() { # {{{
local mod=
# find modules by class (e.g. drivers/ata)
- pushd "$moduledir/kernel" &>/dev/null
+ pushd "$basedir$moduledir/kernel" &>/dev/null
while read -rd '' mod; do
mod=${mod##*/}
mods+=("${mod%.ko?(.gz)}")
Please sign in to comment.
Something went wrong with that request. Please try again.