xref: /openbmc/openbmc-tools/ipkdbg/build-opkg (revision 636a6d42)
1#!/bin/sh
2
3set -eu
4
5set -x
6
7# : ${OPKG_LIBS:="-llzma -lldap -llber -lz -pthread"}
8: ${OPKG_LIBS:="-lz -pthread -lzstd"}
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-lzo2 \
29--without-cng \
30--without-nettle \
31--without-xml2 \
32--without-expat \
33--with-zstd \
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.6.3.tar.gz ] || wget http://downloads.yoctoproject.org/releases/opkg/opkg-0.6.3.tar.gz
59[ -d opkg-0.6.3 ] || tar -xvf opkg-0.6.3.tar.gz
60cd opkg-0.6.3
61OPKG_OPTS="\
62--with-static-libopkg \
63--without-libsolv \
64--enable-curl \
65--enable-openssl \
66--enable-zstd \
67--disable-gpg \
68--disable-dependency-tracking"
69OPKG_ID=$(generate_configure_id "$OPKG_OPTS" "$OPKG_LIBS")
70[ -f $OPKG_ID ] || ( \
71        AR_FLAGS=Tcru \
72        PKG_CONFIG_PATH=$(realpath ../libarchive-3.5.2/root/usr/local/lib/pkgconfig/):$(realpath ../curl-7.79.1/root/usr/local/lib/pkgconfig/) \
73        CURL_CFLAGS=-I$(realpath ../curl-7.79.1/root/usr/local/include/) \
74        CURL_LIBS=$(realpath ../curl-7.79.1/root/usr/local/lib/libcurl.a) \
75        LIBARCHIVE_CFLAGS=-I$(realpath ../libarchive-3.5.2/root/usr/local/include/) \
76        LIBARCHIVE_LIBS=$(realpath ../libarchive-3.5.2/root/usr/local/lib/libarchive.a) \
77        LIBS="$OPKG_LIBS" \
78        ./configure $OPKG_OPTS && mark_configured $OPKG_ID \
79    )
80make -j$(nproc)
81cd ..
82