Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 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 | |
| 20 | |
| 21 | # Don't use TMPDIR from the external environment, it may be a distro |
| 22 | # variable pointing to /tmp (e.g. within X on OpenSUSE) |
| 23 | # Instead, use OE_TMPDIR for passing this in externally. |
| 24 | TMPDIR="$OE_TMPDIR" |
| 25 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 26 | setup_tmpdir() { |
| 27 | if [ -z "$TMPDIR" ]; then |
| 28 | # Try to get TMPDIR from bitbake |
| 29 | type -P bitbake &>/dev/null || { |
| 30 | echo "In order for this script to dynamically infer paths"; |
| 31 | echo "to kernels or filesystem images, you either need"; |
| 32 | echo "bitbake in your PATH or to source oe-init-build-env"; |
| 33 | echo "before running this script" >&2; |
| 34 | exit 1; } |
| 35 | |
| 36 | # We have bitbake in PATH, get TMPDIR from bitbake |
| 37 | TMPDIR=`bitbake -e | grep ^TMPDIR=\" | cut -d '=' -f2 | cut -d '"' -f2` |
| 38 | if [ -z "$TMPDIR" ]; then |
| 39 | echo "Error: this script needs to be run from your build directory," |
| 40 | echo "or you need to explicitly set TMPDIR in your environment" |
| 41 | exit 1 |
| 42 | fi |
| 43 | fi |
| 44 | } |
| 45 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 46 | setup_tmpdir |
| 47 | |
| 48 | function usage() { |
| 49 | echo 'Usage: oe-setup-rpmrepo rpm-dir' |
| 50 | echo '' |
| 51 | echo 'OpenEmbedded setup-rpmrepo - setup rpm repository' |
| 52 | echo '' |
| 53 | echo 'arguments:' |
| 54 | echo " rpm-dir rpm repo directory, default is $TMPDIR/deploy/rpm" |
| 55 | echo '' |
| 56 | } |
| 57 | |
| 58 | if [ $# -gt 1 -o "$1" = '--help' -o "$1" = '-h' ]; then |
| 59 | usage |
| 60 | exit 2 |
| 61 | fi |
| 62 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 63 | setup_sysroot() { |
| 64 | # Toolchain installs set up $OECORE_NATIVE_SYSROOT in their |
| 65 | # environment script. If that variable isn't set, we're |
| 66 | # either in an in-tree poky scenario or the environment |
| 67 | # script wasn't source'd. |
| 68 | if [ -z "$OECORE_NATIVE_SYSROOT" ]; then |
| 69 | setup_tmpdir |
| 70 | BUILD_ARCH=`uname -m` |
| 71 | BUILD_OS=`uname | tr '[A-Z]' '[a-z]'` |
| 72 | BUILD_SYS="$BUILD_ARCH-$BUILD_OS" |
| 73 | |
| 74 | OECORE_NATIVE_SYSROOT=$TMPDIR/sysroots/$BUILD_SYS |
| 75 | fi |
| 76 | } |
| 77 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 78 | setup_sysroot |
| 79 | |
| 80 | |
| 81 | if [ -n "$1" ]; then |
| 82 | RPM_DIR="$1" |
| 83 | else |
| 84 | RPM_DIR="$TMPDIR/deploy/rpm" |
| 85 | fi |
| 86 | |
| 87 | if [ ! -d "$RPM_DIR" ]; then |
| 88 | echo "Error: rpm dir $RPM_DIR doesn't exist" |
| 89 | exit 1 |
| 90 | fi |
| 91 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 92 | CREATEREPO=$OECORE_NATIVE_SYSROOT/usr/bin/createrepo_c |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 93 | if [ ! -e "$CREATEREPO" ]; then |
| 94 | echo "Error: can't find createrepo binary" |
| 95 | echo "please run bitbake createrepo-native first" |
| 96 | exit 1 |
| 97 | fi |
| 98 | |
| 99 | export PATH=${PATH}:${OECORE_NATIVE_SYSROOT}/usr/bin |
| 100 | |
| 101 | $CREATEREPO "$RPM_DIR" |
| 102 | |
| 103 | exit 0 |