source: trunk/debian/package/hostapd/build.sh @ 277

Last change on this file since 277 was 216, checked in by stappers, 8 years ago

infrastructure for patching hostapd, early release

  • Property svn:executable set to *
File size: 2.9 KB
Line 
1#!/bin/bash
2#
3# 1. Download package and unpack package
4# 2. Copy debian/directory to it
5# 3. Run dpkg-buildpackage --arch=<ARCH> -rfakeroot
6
7if [ -z $ARCH ]; then echo "First set \$ARCH before running the build script"; exit 1; fi
8
9export DEBFULLNAME="Amain (DebWrt.net)"
10export LC_ALL=C
11VERBOSE=0
12
13[ "1" == $VERBOSE ] && set -x
14
15PACKAGE=hostapd
16VERSION=1.0
17RELEASE=1
18DOWNLOAD_URL=svn://svn.openwrt.org/openwrt/trunk/package/${PACKAGE}
19DEP=
20
21BASE_DIR=/usr/src
22BUILD_BASE_DIR=${BASE_DIR}/${PACKAGE}
23BUILD_DIR=${BUILD_BASE_DIR}/${PACKAGE}-${VERSION}
24DOWNLOAD_DIR=${BASE_DIR}/dl
25
26mkdir -p $DOWNLOAD_DIR
27rm -rf ${BUILD_DIR}
28mkdir -p ${BUILD_DIR}
29svn checkout ${DOWNLOAD_URL} ${BUILD_DIR} | tail -n 3
30
31VERSION=`cat ${BUILD_DIR}/Makefile  | grep ^PKG_VERSION | awk -F ":=" '{print $2}'`
32OPENWRT_VERSION=${VERSION:=20100705}
33PACKAGE_SOURCE=hostapd-${OPENWRT_VERSION}.tar.bz2
34DOWNLOAD_URL2=http://mirror2.openwrt.org/sources/hostapd-${OPENWRT_VERSION}.tar.bz2
35
36if [ ! -s ${DOWNLOAD_DIR}/${PACKAGE_SOURCE} ]; then rm -f ${DOWNLOAD_DIR}/${PACKAGE_SOURCE}; wget -O ${DOWNLOAD_DIR}/${PACKAGE_SOURCE} $DOWNLOAD_URL2; fi
37mkdir -p ${BUILD_DIR}/src
38tar xjf ${DOWNLOAD_DIR}/${PACKAGE_SOURCE} -C ${BUILD_DIR}/src --strip 1
39
40# apply openwrt patches
41for patch in `ls ${BUILD_DIR}/patches | sort`; do
42    patch -d ${BUILD_DIR}/src -p1 <${BUILD_DIR}/patches/$patch
43done
44
45# download madwifi from openwrt, to determine which madwifi version to use
46DOWNLOAD_URL3=svn://svn.openwrt.org/openwrt/trunk/package/madwifi
47mkdir -p ${BUILD_DIR}/src/madwifi
48svn checkout ${DOWNLOAD_URL3} ${BUILD_DIR}/src/madwifi | tail -n 3
49
50# download correct version from madwifi
51REV=`cat ${BUILD_DIR}/src/madwifi/Makefile  | grep ^PKG_REV | awk -F ":=" '{print $2}'`
52OPENWRT_VERSION="r${REV:=3314}"
53PACKAGE_SOURCE=madwifi-trunk-${OPENWRT_VERSION}.tar.gz
54DOWNLOAD_URL4=http://mirror2.openwrt.org/sources/${PACKAGE_SOURCE}
55
56if [ ! -s ${DOWNLOAD_DIR}/${PACKAGE_SOURCE} ]; then rm -f ${DOWNLOAD_DIR}/${PACKAGE_SOURCE}; wget -O ${DOWNLOAD_DIR}/${PACKAGE_SOURCE} $DOWNLOAD_URL4; fi
57tar xzf ${DOWNLOAD_DIR}/${PACKAGE_SOURCE} -C ${BUILD_DIR}/src/madwifi --strip 1
58
59# cp config file
60cp ${BUILD_DIR}/files/hostapd-mini.config ${BUILD_DIR}/src/hostapd/.config
61
62# make sure it compiles
63echo "CONFIG_INTERNAL_LIBTOMMATH=internal" >>${BUILD_DIR}/src/hostapd/.config
64
65# temporary remove madwifi
66#sed -i '/CONFIG_DRIVER_MADWIFI/d' ${BUILD_DIR}/src/hostapd/.config
67
68# apply debwrt patches, if any
69for patch in $( ls patches/*.diff )
70do
71    echo "I:patch file = ${patch}"
72    patch -d ${BUILD_DIR} -p0 < ${patch}
73done
74
75if [ ! -d debian ]; then
76   cd ${BUILD_DIR} 
77   dh_make -c gpl -e "amain@debwrt.net" -s -n
78   echo "Please complete debian package configuration. And copy the files back to the svn working directory."
79   exit 1
80else
81   cp -a debian ${BUILD_DIR}
82   cd ${BUILD_DIR}
83   dpkg-buildpackage -a${ARCH} -rfakeroot
84   find ${BUILD_BASE_DIR} -maxdepth 1 -name "*.deb"  | xargs -r -t -i sudo dpkg-cross -a ${ARCH} -i {} || true
85fi
86
Note: See TracBrowser for help on using the repository browser.