diff options
Diffstat (limited to 'miniprokit.sh')
-rwxr-xr-x | miniprokit.sh | 70 |
1 files changed, 69 insertions, 1 deletions
diff --git a/miniprokit.sh b/miniprokit.sh index 769004a..3d1f628 100755 --- a/miniprokit.sh +++ b/miniprokit.sh @@ -159,7 +159,7 @@ cmd_install() info 'Setting up root...' mkdir -p "${root}/etc/opkg" \ "${root}/var/lib/opkg/lists" "${root}/var/lib/opkg/info" \ - "${root}/var/cache/opkg/archives" || \ + "${root}/var/cache/opkg/archives" "${root}/tmp/opkg" || \ error 2 'Failed to set up root' info 'Configuring opkg and retrieving Packages...' @@ -200,6 +200,8 @@ cmd_install() EOF + configure_pkgs "${root}" + [ -r /etc/resolv.conf ] && cp /etc/resolv.conf "${root}/etc" [ -r /etc/hostname ] && cp /etc/hostname "${root}/etc" } @@ -223,6 +225,72 @@ get_pkg() (cd ${root}; tar -xzOf "${filename#${root}/}" data.tar.gz | tar -xz) } +configure_pkgs() +{ + local root="${1}" + local opk= + local pkg= + local file= + local script= + local control= + local printed= + + for opk in "${root}/var/cache/opkg/archives/"*.opk; do + pkg="${opk##*/}" + pkg="${pkg%%_*}" + + # Finish unpacking. + mkdir "${root}/tmp/opkg/${pkg}" + ( + cd "${root}/tmp/opkg/${pkg}" + tar -xzOf "../../../${opk#${root}/}" control.tar.gz | \ + tar -xz + ) + for file in "${root}/tmp/opkg/${pkg}/"*; do + mv "${file}" \ + "${root}/var/lib/opkg/info/${pkg}.${file##*/}" + done + rmdir "${root}/tmp/opkg/${pkg}" + + info 'Configuring %s...' "${pkg}" + for script in 'preinst' 'postinst'; do + if [ -x "${root}/var/lib/opkg/info/${pkg}.${script}" ] + then + chroot "${root}" \ + "/var/lib/opkg/info/${pkg}.${script}" \ + configure + fi + done + + tar -xzOf "${opk}" data.tar.gz | tar tz | sed 's/^\.//' \ + >"${root}/var/lib/opkg/info/${pkg}.list" + + # Write status file. + exec 3>>"${root}/var/lib/opkg/status" + control="${root}/var/lib/opkg/info/${pkg}.control" + for field in Package Version Depends Recommends Suggests \ + Provides Replaces Conflicts; do + grep "^${field}: " "${control}" >&3 + done + printf 'Status: install user installed\n' >&3 + for field in Essential Architecture; do + grep "^${field}: " "${control}" >&3 + done + if [ -r "${root}/var/lib/opkg/info/${pkg}.conffiles" ]; then + printed=false + while read -r file; do + ${printed} || printf 'Conffiles:\n' >&3 + printf ' %s %s\n' "${file}" "$(md5sum \ + "${root}/${file}" | cut -d ' ' -f 1)" \ + >&3 + printed=true + done <"${root}/var/lib/opkg/info/${pkg}.conffiles" + fi + printf 'Installed-Time: %s\n\n' "$(date '+%s')" >&3 + exec 3>&- + done +} + cmd_shell() { local root= |