#!/bin/sh WORKDIR=`dirname $0` OPKGB_WEB="https://git.yoctoproject.org/cgit/cgit.cgi/opkg-utils/plain/opkg-build" OPKG_PKG_NAME="test-packet1" VERSION="2.0" OPKG_PKG_DIR="${WORKDIR}/package" DEST_DIR="${OPKG_PKG_DIR}/user/${OPKG_PKG_NAME}_${VERSION}" #ARCH defines wether the packet will be used on IBTS (klk_lpbs), iFemtoCell (klk_wifc) # or all the Kerlink Wirnet(TM) products with KerOS FW >=v4.1 (klkgw) ARCH="klkgw" PATH=${PATH}:${WORKDIR} # 1 - Download opkg-build if necessary command -v opkg-build > /dev/null 2>&1 if [ $? -ne 0 ] then echo "Opkg-build is necessary, downloading it from ${OPKGB_WEB}" wget ${OPKGB_WEB} chmod 755 opkg-build fi # 2 - Generate meta-data for opkg rm -rf ${OPKG_PKG_DIR} mkdir -p ${OPKG_PKG_DIR}/CONTROL cat > ${OPKG_PKG_DIR}/CONTROL/control << EOF Package: ${OPKG_PKG_NAME} Version: ${VERSION:=0.0} Architecture: ${ARCH} Maintainer: Kerlink Priority: optional Section: test Source: Kerlink's Wirnet(TM) i-series wiki Description: Install two files in userland EOF # 3 - Copy or create the file(s) to be installed mkdir -p ${DEST_DIR} cat > ${DEST_DIR}/test_file1-${VERSION} << EOF I am a test file. I should be removed if my package is uninstalled. EOF # In most cases, the user doesn't need this script to generate the files to be installed # He just needs to copy pre-existing files from another directory # The previous "cat" command can be replaced by a "cp" command # cp /custom/path/to/file_to_install ${DEST_DIR}/ # 4 - Generate or copy a preinst script cat > ${OPKG_PKG_DIR}/CONTROL/preinst << EOF echo "I am a script file executed before the installation of ${OPKG_PKG_NAME}-${VERSION}" EOF # In most cases, the user doesn't need this script to generate the "preinst" file # He just needs to copy a pre-existing file from another directory # The previous "cat" command can be replaced by a "cp" command # cp /custom/path/to/preinst ${OPKG_PKG_DIR}/CONTROL/ chmod 755 ${OPKG_PKG_DIR}/CONTROL/preinst # 5 - Generate or copy a postinst script cat > ${OPKG_PKG_DIR}/CONTROL/postinst << EOF1 echo "I am a script file executed after the copy of the files in ${OPKG_PKG_NAME}-${VERSION}" echo "# I am the test line from the test IPK package" >> /etc/syslog.conf EOF1 # In most cases, the user doesn't need this script to generate the "postinst" file # He just needs to copy a pre-existing file from another directory # The previous "cat" command can be replaced by a "cp" command # cp /custom/path/to/postinst ${OPKG_PKG_DIR}/CONTROL/ chmod 755 ${OPKG_PKG_DIR}/CONTROL/postinst # 6 - Generate or copy a postrm script cat > ${OPKG_PKG_DIR}/CONTROL/postrm << EOF2 echo "I am a script file executed after the deinstallation of package ${OPKG_PKG_NAME}-${VERSION}" EOF2 # In most cases, the user doesn't need this script to generate the "postrm" file # He just needs to copy a pre-existing file from another directory # The previous "cat" command can be replaced by a "cp" command # cp /custom/path/to/postrm ${OPKG_PKG_DIR}/CONTROL/ chmod 755 ${OPKG_PKG_DIR}/CONTROL/postrm # 7 - Generate the package rm -f *.ipk opkg-build -o root -g root ${OPKG_PKG_DIR} > log cat log rm -f log