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.

84 lines
2.2 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 - 2008 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 "$@" "$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=
  33. local type= mode= ref= targetdir=
  34. for file in $overlaydir/*; do
  35. source="${file##*/}"
  36. ext="${file##*.}"
  37. case "$ext" in
  38. sh|exec|txt|patch|ln)
  39. case "$ext" in
  40. sh|exec) type='exec'; mode=0755 ;;
  41. *) type="$ext"; mode=0644 ;;
  42. esac
  43. target="$( echo ${source%.$ext} | tr '_%' '/_' )"
  44. targetdir="$rootfs/$target"; targetdir="${targetdir%/*}"
  45. ;;
  46. *) continue ;;
  47. esac
  48. case "$type" in
  49. exec|txt)
  50. echo_status "injecting $target ($type)"
  51. mkdir -p "$targetdir"
  52. cp -f "$file" "$rootfs/$target"
  53. chmod $mode "$rootfs/$target"
  54. ;;
  55. ln) ref=$( cat "$file" )
  56. echo_status "injecting $target -> $ref"
  57. mkdir -p "$targetdir"
  58. ln -snf "$ref" "$rootfs/$target"
  59. ;;
  60. patch)
  61. echo_status "$(patch -p1 -d "${rootfs}" 2>&1 < $file )"
  62. ;;
  63. esac
  64. done
  65. }
  66. # weak functions
  67. #
  68. # should this package be extracted by flist or not?
  69. # initramfs_install <pkg_name> <sandbox> <rootfs>
  70. initramfs_install() { true; }
  71. # what arguments should it pass to sed to filter the flist?
  72. # initramfs_install_pattern <pkg_name> <default_patterns>
  73. initramfs_install_pattern() { shift; echo "$@"; }