oe-setup-rpmrepo 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. function usage() {
  24. echo "Usage: $0 <rpm-dir>"
  25. echo " <rpm-dir>: default is $TMPDIR/deploy/rpm"
  26. }
  27. if [ $# -gt 1 ]; then
  28. usage
  29. exit 1
  30. fi
  31. setup_tmpdir() {
  32. if [ -z "$TMPDIR" ]; then
  33. # Try to get TMPDIR from bitbake
  34. type -P bitbake &>/dev/null || {
  35. echo "In order for this script to dynamically infer paths";
  36. echo "to kernels or filesystem images, you either need";
  37. echo "bitbake in your PATH or to source oe-init-build-env";
  38. echo "before running this script" >&2;
  39. exit 1; }
  40. # We have bitbake in PATH, get TMPDIR from bitbake
  41. TMPDIR=`bitbake -e | grep ^TMPDIR=\" | cut -d '=' -f2 | cut -d '"' -f2`
  42. if [ -z "$TMPDIR" ]; then
  43. echo "Error: this script needs to be run from your build directory,"
  44. echo "or you need to explicitly set TMPDIR in your environment"
  45. exit 1
  46. fi
  47. fi
  48. }
  49. setup_sysroot() {
  50. # Toolchain installs set up $OECORE_NATIVE_SYSROOT in their
  51. # environment script. If that variable isn't set, we're
  52. # either in an in-tree poky scenario or the environment
  53. # script wasn't source'd.
  54. if [ -z "$OECORE_NATIVE_SYSROOT" ]; then
  55. setup_tmpdir
  56. BUILD_ARCH=`uname -m`
  57. BUILD_OS=`uname | tr '[A-Z]' '[a-z]'`
  58. BUILD_SYS="$BUILD_ARCH-$BUILD_OS"
  59. OECORE_NATIVE_SYSROOT=$TMPDIR/sysroots/$BUILD_SYS
  60. fi
  61. }
  62. setup_tmpdir
  63. setup_sysroot
  64. if [ -n "$1" ]; then
  65. RPM_DIR="$1"
  66. else
  67. RPM_DIR="$TMPDIR/deploy/rpm"
  68. fi
  69. if [ ! -d "$RPM_DIR" ]; then
  70. echo "Error: rpm dir $RPM_DIR doesn't exist"
  71. exit 1
  72. fi
  73. CREATEREPO=$OECORE_NATIVE_SYSROOT/usr/bin/createrepo
  74. if [ ! -e "$CREATEREPO" ]; then
  75. echo "Error: can't find createrepo binary"
  76. echo "please run bitbake createrepo-native first"
  77. exit 1
  78. fi
  79. $CREATEREPO "$RPM_DIR"
  80. exit 0