oe-setup-rpmrepo 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #!/bin/bash
  2. #
  3. # This utility setup the necessary metadata for an rpm repo
  4. #
  5. # Copyright (c) 2011 Intel Corp.
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License version 2 as
  9. # published by the Free Software Foundation.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. # See the GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program; if not, write to the Free Software
  18. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. # Don't use TMPDIR from the external environment, it may be a distro
  20. # variable pointing to /tmp (e.g. within X on OpenSUSE)
  21. # Instead, use OE_TMPDIR for passing this in externally.
  22. TMPDIR="$OE_TMPDIR"
  23. setup_tmpdir() {
  24. if [ -z "$TMPDIR" ]; then
  25. # Try to get TMPDIR from bitbake
  26. type -P bitbake &>/dev/null || {
  27. echo "In order for this script to dynamically infer paths";
  28. echo "to kernels or filesystem images, you either need";
  29. echo "bitbake in your PATH or to source oe-init-build-env";
  30. echo "before running this script" >&2;
  31. exit 1; }
  32. # We have bitbake in PATH, get TMPDIR from bitbake
  33. TMPDIR=`bitbake -e | grep ^TMPDIR=\" | cut -d '=' -f2 | cut -d '"' -f2`
  34. if [ -z "$TMPDIR" ]; then
  35. echo "Error: this script needs to be run from your build directory,"
  36. echo "or you need to explicitly set TMPDIR in your environment"
  37. exit 1
  38. fi
  39. fi
  40. }
  41. setup_tmpdir
  42. function usage() {
  43. echo 'Usage: oe-setup-rpmrepo rpm-dir'
  44. echo ''
  45. echo 'OpenEmbedded setup-rpmrepo - setup rpm repository'
  46. echo ''
  47. echo 'arguments:'
  48. echo " rpm-dir rpm repo directory, default is $TMPDIR/deploy/rpm"
  49. echo ''
  50. }
  51. if [ $# -gt 1 -o "$1" = '--help' -o "$1" = '-h' ]; then
  52. usage
  53. exit 2
  54. fi
  55. setup_sysroot() {
  56. # Toolchain installs set up $OECORE_NATIVE_SYSROOT in their
  57. # environment script. If that variable isn't set, we're
  58. # either in an in-tree poky scenario or the environment
  59. # script wasn't source'd.
  60. if [ -z "$OECORE_NATIVE_SYSROOT" ]; then
  61. setup_tmpdir
  62. BUILD_ARCH=`uname -m`
  63. BUILD_OS=`uname | tr '[A-Z]' '[a-z]'`
  64. BUILD_SYS="$BUILD_ARCH-$BUILD_OS"
  65. OECORE_NATIVE_SYSROOT=$TMPDIR/sysroots/$BUILD_SYS
  66. fi
  67. }
  68. setup_sysroot
  69. if [ -n "$1" ]; then
  70. RPM_DIR="$1"
  71. else
  72. RPM_DIR="$TMPDIR/deploy/rpm"
  73. fi
  74. if [ ! -d "$RPM_DIR" ]; then
  75. echo "Error: rpm dir $RPM_DIR doesn't exist"
  76. exit 1
  77. fi
  78. CREATEREPO=$OECORE_NATIVE_SYSROOT/usr/bin/createrepo_c
  79. if [ ! -e "$CREATEREPO" ]; then
  80. echo "Error: can't find createrepo binary"
  81. echo "please run bitbake createrepo-native first"
  82. exit 1
  83. fi
  84. export PATH=${PATH}:${OECORE_NATIVE_SYSROOT}/usr/bin
  85. $CREATEREPO "$RPM_DIR"
  86. exit 0