summaryrefslogtreecommitdiffstats
path: root/scripts/oe-setup-rpmrepo
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/oe-setup-rpmrepo')
-rwxr-xr-xscripts/oe-setup-rpmrepo97
1 files changed, 97 insertions, 0 deletions
diff --git a/scripts/oe-setup-rpmrepo b/scripts/oe-setup-rpmrepo
new file mode 100755
index 0000000000..917b98b984
--- /dev/null
+++ b/scripts/oe-setup-rpmrepo
@@ -0,0 +1,97 @@
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.
24TMPDIR="$OE_TMPDIR"
25
26function usage() {
27 echo "Usage: $0 <rpm-dir>"
28 echo " <rpm-dir>: default is $TMPDIR/deploy/rpm"
29}
30
31if [ $# -gt 1 ]; then
32 usage
33 exit 1
34fi
35
36setup_tmpdir() {
37 if [ -z "$TMPDIR" ]; then
38 # Try to get TMPDIR from bitbake
39 type -P bitbake &>/dev/null || {
40 echo "In order for this script to dynamically infer paths";
41 echo "to kernels or filesystem images, you either need";
42 echo "bitbake in your PATH or to source oe-init-build-env";
43 echo "before running this script" >&2;
44 exit 1; }
45
46 # We have bitbake in PATH, get TMPDIR from bitbake
47 TMPDIR=`bitbake -e | grep ^TMPDIR=\" | cut -d '=' -f2 | cut -d '"' -f2`
48 if [ -z "$TMPDIR" ]; then
49 echo "Error: this script needs to be run from your build directory,"
50 echo "or you need to explicitly set TMPDIR in your environment"
51 exit 1
52 fi
53 fi
54}
55
56setup_sysroot() {
57 # Toolchain installs set up $OECORE_NATIVE_SYSROOT in their
58 # environment script. If that variable isn't set, we're
59 # either in an in-tree poky scenario or the environment
60 # script wasn't source'd.
61 if [ -z "$OECORE_NATIVE_SYSROOT" ]; then
62 setup_tmpdir
63 BUILD_ARCH=`uname -m`
64 BUILD_OS=`uname | tr '[A-Z]' '[a-z]'`
65 BUILD_SYS="$BUILD_ARCH-$BUILD_OS"
66
67 OECORE_NATIVE_SYSROOT=$TMPDIR/sysroots/$BUILD_SYS
68 fi
69}
70
71setup_tmpdir
72setup_sysroot
73
74
75if [ -n "$1" ]; then
76 RPM_DIR="$1"
77else
78 RPM_DIR="$TMPDIR/deploy/rpm"
79fi
80
81if [ ! -d "$RPM_DIR" ]; then
82 echo "Error: rpm dir $RPM_DIR doesn't exist"
83 exit 1
84fi
85
86CREATEREPO=$OECORE_NATIVE_SYSROOT/usr/bin/createrepo
87if [ ! -e "$CREATEREPO" ]; then
88 echo "Error: can't find createrepo binary"
89 echo "please run bitbake createrepo-native first"
90 exit 1
91fi
92
93export PATH=${PATH}:${OECORE_NATIVE_SYSROOT}/usr/bin
94
95$CREATEREPO "$RPM_DIR"
96
97exit 0