gen_kselftest_tar.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/bash
  2. #
  3. # SPDX-License-Identifier: GPL-2.0
  4. # gen_kselftest_tar
  5. # Generate kselftest tarball
  6. # Author: Shuah Khan <[email protected]>
  7. # Copyright (C) 2015 Samsung Electronics Co., Ltd.
  8. # main
  9. main()
  10. {
  11. if [ "$#" -eq 0 ]; then
  12. echo "$0: Generating default compression gzip"
  13. copts="cvzf"
  14. ext=".tar.gz"
  15. else
  16. case "$1" in
  17. tar)
  18. copts="cvf"
  19. ext=".tar"
  20. ;;
  21. targz)
  22. copts="cvzf"
  23. ext=".tar.gz"
  24. ;;
  25. tarbz2)
  26. copts="cvjf"
  27. ext=".tar.bz2"
  28. ;;
  29. tarxz)
  30. copts="cvJf"
  31. ext=".tar.xz"
  32. ;;
  33. *)
  34. echo "Unknown tarball format $1"
  35. exit 1
  36. ;;
  37. esac
  38. fi
  39. # Create working directory.
  40. dest=`pwd`
  41. install_work="$dest"/kselftest_install
  42. install_name=kselftest
  43. install_dir="$install_work"/"$install_name"
  44. mkdir -p "$install_dir"
  45. # Run install using INSTALL_KSFT_PATH override to generate install
  46. # directory
  47. ./kselftest_install.sh "$install_dir"
  48. (cd "$install_work"; tar $copts "$dest"/kselftest${ext} $install_name)
  49. # Don't put the message at the actual end as people may be parsing the
  50. # "archive created" line in their scripts.
  51. echo -e "\nConsider using 'make gen_tar' instead of this script\n"
  52. echo "Kselftest archive kselftest${ext} created!"
  53. # clean up top-level install work directory
  54. rm -rf "$install_work"
  55. }
  56. main "$@"