OpenSDE Framework (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.0 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: target/share/initramfs.in
  5. # Copyright (C) 2007 The OpenSDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This program is free software; you can redistribute it and/or modify
  10. # it under the terms of the GNU General Public License as published by
  11. # the Free Software Foundation; version 2 of the License. A copy of the
  12. # GNU General Public License can be found in the file COPYING.
  13. # --- SDE-COPYRIGHT-NOTE-END ---
  14. # functions
  15. #
  16. # list the packages active for stage 1
  17. initramfs_list_stage1() {
  18. grep '^X .1' $base/config/$config/packages | cut -d' ' -f5
  19. }
  20. # install a package based on the flist and a given filter
  21. initramfs_install_flist() {
  22. local pkg_name="$1" sandbox="$2" rootfs="$3"
  23. local flist="$sandbox/var/adm/flists/$pkg_name"
  24. shift 3
  25. sed -e '/ var\/adm/ d;' "$@" "$flist" | cut -f2- -d' ' |
  26. tar -C "$sandbox/" -cf- --no-recursion --files-from=- |
  27. tar -C "$rootfs" -xf-
  28. }
  29. # apply an overlay
  30. initramfs_install_overlay() {
  31. local overlaydir="$1" rootfs="$2"
  32. local file= source= target= ext= mode=
  33. for file in $overlaydir/*; do
  34. source="${file##*/}"
  35. ext="${file##*.}"
  36. case "$ext" in
  37. sh|exec|txt|patch)
  38. case "$ext" in
  39. sh|exec) mode='exec' ;;
  40. *) mode="$ext" ;;
  41. esac
  42. target="$( echo ${source%.$ext} | tr '_%' '/_' )"
  43. ;;
  44. *) continue ;;
  45. esac
  46. case "$mode" in
  47. exec|txt)
  48. echo_status "injecting $target ($mode)"
  49. cp -f "$file" "$rootfs/$target"
  50. [ "$mode" != "exec" ] || chmod +x "$rootfs/$target"
  51. ;;
  52. patch)
  53. echo_status "$(patch -p1 -d "${rootfs}" 2>&1 < $file )"
  54. ;;
  55. esac
  56. done
  57. }
  58. # weak functions
  59. #
  60. # should this package be extracted by flist or not?
  61. # initramfs_install <pkg_name> <sandbox> <rootfs>
  62. initramfs_install() { true; }
  63. # what arguments should it pass to sed to filter the flist?
  64. # initramfs_install_pattern <pkg_name> <default_patterns>
  65. initramfs_install_pattern() { shift; echo "$@"; }