xref: /openbmc/openbmc-tools/ipkdbg/build-opkg (revision 4ffeec6f)
1#!/bin/sh
2
3set -eu
4
5set -x
6
7# : ${OPKG_LIBS:="-llzma -lldap -llber -lz -pthread"}
8: ${OPKG_LIBS:="-lz -pthread"}
9
10generate_configure_id() {
11    echo "$@" | sha256sum | awk '{ printf "build-opkg-%s", $1 }'
12}
13
14mark_configured() {
15    rm -f build-opkg-*
16    touch $1
17}
18
19# libarchive
20[ -f libarchive-3.5.2.tar.gz ] || wget http://libarchive.org/downloads/libarchive-3.5.2.tar.gz
21[ -d libarchive-3.5.2 ] || tar -xvf libarchive-3.5.2.tar.gz
22cd libarchive-3.5.2
23LIBARCHIVE_OPTS="\
24--without-zlib \
25--without-bz2lib \
26--without-libb2 \
27--without-lz4 \
28--without-zstd \
29--without-lzo2 \
30--without-cng \
31--without-nettle \
32--without-xml2 \
33--without-expat \
34--disable-acl \
35--disable-xattr \
36--enable-posix-regex-lib=libc \
37--disable-rpath \
38--disable-bsdcat \
39--disable-bsdtar \
40--disable-bsdcpio \
41--with-pic"
42LIBARCHIVE_ID=$(generate_configure_id "$LIBARCHIVE_OPTS")
43[ -f $LIBARCHIVE_ID ] || ( ./configure $LIBARCHIVE_OPTS && mark_configured $LIBARCHIVE_ID )
44mkdir -p root && make -j$(nproc) install DESTDIR=$(realpath root)
45cd ..
46
47# curl
48[ -f curl-7.79.1.tar.bz2 ] || wget https://curl.haxx.se/download/curl-7.79.1.tar.bz2
49[ -d curl-7.79.1 ] || tar -xvf curl-7.79.1.tar.bz2
50cd curl-7.79.1
51CURL_OPTS=--with-openssl
52CURL_ID=$(generate_configure_id "$CURL_OPTS")
53[ -f $CURL_ID ] || ( ./configure $CURL_OPTS && mark_configured $CURL_ID )
54mkdir -p root && make -j$(nproc) install DESTDIR=$(realpath root)
55cd ..
56
57# opkg
58[ -f opkg-0.4.5.tar.gz ] || wget http://downloads.yoctoproject.org/releases/opkg/opkg-0.4.5.tar.gz
59[ -d opkg-0.4.5 ] || tar -xvf opkg-0.4.5.tar.gz
60cd opkg-0.4.5
61OPKG_OPTS="\
62--with-static-libopkg \
63--without-libsolv \
64--enable-curl \
65--enable-openssl \
66--disable-gpg \
67--disable-dependency-tracking"
68OPKG_ID=$(generate_configure_id "$OPKG_OPTS" "$OPKG_LIBS")
69[ -f $OPKG_ID ] || ( \
70        AR_FLAGS=Tcru \
71        PKG_CONFIG_PATH=$(realpath ../libarchive-3.5.2/root/usr/local/lib/pkgconfig/):$(realpath ../curl-7.79.1/root/usr/local/lib/pkgconfig/) \
72        CURL_CFLAGS=-I$(realpath ../curl-7.79.1/root/usr/local/include/) \
73        CURL_LIBS=$(realpath ../curl-7.79.1/root/usr/local/lib/libcurl.a) \
74        LIBARCHIVE_CFLAGS=-I$(realpath ../libarchive-3.5.2/root/usr/local/include/) \
75        LIBARCHIVE_LIBS=$(realpath ../libarchive-3.5.2/root/usr/local/lib/libarchive.a) \
76        LIBS="$OPKG_LIBS" \
77        ./configure $OPKG_OPTS && mark_configured $OPKG_ID \
78    )
79make -j$(nproc)
80cd ..
81