oe-setup-rpmrepo 2.4 KB

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