extract_rootfs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/bin/bash
  2. # Yocto ADT Installer
  3. #
  4. # Copyright 2010-2011 by Intel Corp.
  5. #
  6. # Permission is hereby granted, free of charge, to any person obtaining a copy
  7. # of this software and associated documentation files (the "Software"), to deal
  8. # in the Software without restriction, including without limitation the rights
  9. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. # copies of the Software, and to permit persons to whom the Software is
  11. # furnished to do so, subject to the following conditions:
  12. # The above copyright notice and this permission notice shall be included in
  13. # all copies or substantial portions of the Software.
  14. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. # THE SOFTWARE.
  21. extract_rootfs()
  22. {
  23. native_sysroot=$3
  24. target_sysroot=$2
  25. PSEUDO_COMMAND="$native_sysroot/usr/bin/pseudo"
  26. TAR_OPTS="-xjf"
  27. PSEUDO_OPTS="-P $native_sysroot/usr"
  28. rm -rf $PSEUDO_LOCALSTATEDIR
  29. if [ -d "$target_sysroot" ]; then
  30. echo_info "\nTarget sysroot location: $target_sysroot, already exists! If you continue installation, this folder will be re-created."
  31. confirm_install $4
  32. rm -rf "$target_sysroot"
  33. fi
  34. if [ ! -d "$target_sysroot" ]; then
  35. echo_info "Creating directory $target_sysroot..."
  36. mkdir -p "$target_sysroot"
  37. fi
  38. pseudo_state_dir="$target_sysroot/../$(basename "$target_sysroot").pseudo_state"
  39. mkdir -p "$pseudo_state_dir"
  40. touch "$pseudo_state_dir/pseudo.pid"
  41. PSEUDO_LOCALSTATEDIR="$pseudo_state_dir"
  42. export PSEUDO_LOCALSTATEDIR
  43. echo_info "Extracting rootfs: $1, using pseudo..."
  44. $PSEUDO_COMMAND $PSEUDO_OPTS tar -C $2 "$TAR_OPTS" $LOCAL_DOWNLOAD/$1 &>> $YOCTOADT_INSTALL_LOG_FILE
  45. check_result
  46. }
  47. #Main part
  48. . scripts/util
  49. #Parameter detail is listed below:
  50. #Param 4: Silent install or customize install
  51. #Param 3: OECORE_NATIVE_SYSROOT
  52. #Param 2: user defined rootfs extraction directory
  53. #param 1: sysroot image name
  54. extract_rootfs $1 $2 $3 $4