Add package build script

This commit is contained in:
Nick Peng
2019-12-14 15:46:18 +08:00
parent 8433729186
commit cc93156ee3
8 changed files with 481 additions and 185 deletions

View File

@@ -680,6 +680,10 @@ https://github.com/pymumu/smartdns/releases
bind [::]:6053 -no-speed-check -group office -no-rule-addr bind [::]:6053 -no-speed-check -group office -no-rule-addr
``` ```
## 编译
smartdns包含了编译软件包的脚本支持编译lucidebianopenwrtoptare安装包可执行`package/build-pkg.sh`编译。
## Donate ## Donate
如果你觉得此项目对你有帮助,请捐助我们,以使项目能持续发展,更加完善。 如果你觉得此项目对你有帮助,请捐助我们,以使项目能持续发展,更加完善。

View File

@@ -677,6 +677,10 @@ Note: Merlin firmware is derived from ASUS firmware and can theoretically be use
bind [::]:6053 -no-speed-check -group office -no-rule-addr bind [::]:6053 -no-speed-check -group office -no-rule-addr
``` ```
## Compile
smartdns contains scripts for compiling packages, supports compiling luci, debian, openwrt, opare installation packages, and can execute `package/build-pkg.sh` compilation.
## [Donate](#Donate) ## [Donate](#Donate)
If you feel that this project is helpful to you, please donate to us so that the project can continue to develop and be more perfect. If you feel that this project is helpful to you, please donate to us so that the project can continue to develop and be more perfect.

180
package/build-pkg.sh Normal file
View File

@@ -0,0 +1,180 @@
#!/bin/sh
# Copyright (C) 2018-2019 Nick Peng (pymumu@gmail.com)
CURR_DIR=$(cd $(dirname $0);pwd)
VER="`date +"1.%Y.%m.%d-%H%M"`"
CODE_DIR="$CURR_DIR/.."
IS_BUILD_SMARTDNS=1
OUTPUTDIR=$CURR_DIR
export CC
export STRIP
showhelp()
{
echo "Usage: $0 [OPTION]"
echo "Options:"
echo " --platform [luci|debian|openwrt|optware|linux] build for platform. "
echo " --arch [all|armhf|arm64|x86_64|...] build for architecture, e.g. "
echo " --cross-tool [cross-tool] cross compiler, e.g. mips-openwrt-linux-"
echo ""
echo "Advance Options:"
echo " --static static link smartdns"
echo " --only-package only package, not build source"
echo " --filearch [arch] output file arch, default: equal --arch"
echo " --outputdir [dir] output package to specific directory"
echo " "
echo "Example:"
echo " build luci:"
echo " $0 --platform luci"
echo " build debian:"
echo " $0 --platform debian --arch x86_64"
echo " build raspbian pi:"
echo " $0 --platform debian --arch armhf"
echo " build optware mips:"
echo " $0 --platform optware --arch mipsbig"
echo " build openwrt mips:"
echo " $0 --platform openwrt --arch mips_24kc"
echo " build generic linux:"
echo " $0 --platform linux --arch x86_64"
}
build_smartdns()
{
if [ "$PLATFORM" != "luci" ]; then
make -C $CODE_DIR/src clean
make -C $CODE_DIR/src all -j8 VER=$VER $MAKE_ARGS
if [ $? -ne 0 ]; then
echo "make smartdns failed"
exit 1
fi
fi
$STRIP -d $CODE_DIR/src/smartdns >/dev/null 2>&1
return 0
}
build()
{
echo "build package for $PLATFORM"
if [ $IS_BUILD_SMARTDNS -eq 1 ]; then
build_smartdns
if [ $? -ne 0 ]; then
return 1
fi
fi
chmod +x $CODE_DIR/package/$PLATFORM/make.sh
$CODE_DIR/package/$PLATFORM/make.sh -o $CURR_DIR --arch $ARCH --ver $VER --filearch $FILEARCH -o $OUTPUTDIR
if [ $? -ne 0 ]; then
echo "build package for $PLATFORM failed"
return 1
fi
echo "build package for $PLATFORM success."
return 0
}
main()
{
OPTS=`getopt -o o:h --long arch:,filearch:,ver:,platform:,cross-tool:,static,only-package,outputdir: \
-n "" -- "$@"`
if [ "$#" -le "1" ]; then
showhelp
exit 1
fi
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
# Note the quotes around `$TEMP': they are essential!
eval set -- "$OPTS"
while true; do
case "$1" in
--arch)
ARCH="$2"
shift 2;;
--filearch)
FILEARCH="$2"
shift 2;;
--platform)
PLATFORM="$2"
shift 2;;
--cross-tool)
CROSS_TOOL="$2"
shift 2;;
--static)
export STATIC="yes"
shift 1;;
--only-package)
IS_BUILD_SMARTDNS=0
shift 1;;
--outputdir)
OUTPUTDIR="$2"
shift 2;;
--ver)
VER="$2"
shift 2;;
-h | --help )
showhelp
return 0
shift ;;
-- ) shift; break ;;
* ) break ;;
esac
done
if [ -z "$PLATFORM" ]; then
echo "please input platform"
echo "run $0 -h for help."
return 1
fi
if [ "$PLATFORM" = "luci" ]; then
ARCH="all"
fi
if [ -z "$ARCH" ]; then
echo "please input arch."
echo "run $0 -h for help."
return 1
fi
if [ -z "$FILEARCH" ]; then
FILEARCH="$ARCH"
fi
if [ -z "$OUTPUTDIR" ]; then
OUTPUTDIR=$CURR_DIR
fi
if [ ! -z "$CROSS_TOOL" ]; then
CC="${CROSS_TOOL}gcc"
STRIP="${CROSS_TOOL}strip"
fi
if [ -z "$CC" ]; then
CC="gcc"
fi
if [ -z "$STRIP" ]; then
if [ ! -z "`echo $CC | grep '\-gcc'`" ]; then
STRIP="`echo "$CC" | sed 's/-gcc\$/-strip/g'`"
else
STRIP="strip"
fi
fi
if [ ! -e "`which $CC`" ]; then
echo "Cannot find compiler $CC"
return 1
fi
build
}
main $@
exit $?

View File

@@ -14,7 +14,6 @@
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
CURR_DIR=$(cd $(dirname $0);pwd) CURR_DIR=$(cd $(dirname $0);pwd)
VER="`date +"1.%Y.%m.%d-%H%M"`" VER="`date +"1.%Y.%m.%d-%H%M"`"
SMARTDNS_DIR=$CURR_DIR/../../ SMARTDNS_DIR=$CURR_DIR/../../
@@ -26,37 +25,41 @@ showhelp()
echo "Options:" echo "Options:"
echo " -o output directory." echo " -o output directory."
echo " --arch archtecture." echo " --arch archtecture."
echo " --ver version." echo " --ver version."
echo " -h show this message." echo " -h show this message."
} }
build() build()
{ {
ROOT=/tmp/smartdns-deiban ROOT=/tmp/smartdns-deiban
rm -fr $ROOT rm -fr $ROOT
mkdir -p $ROOT mkdir -p $ROOT
cd $ROOT/ cd $ROOT/
cp $CURR_DIR/DEBIAN $ROOT/ -af cp $CURR_DIR/DEBIAN $ROOT/ -af
CONTROL=$ROOT/DEBIAN/control CONTROL=$ROOT/DEBIAN/control
mkdir $ROOT/usr/sbin -p mkdir $ROOT/usr/sbin -p
mkdir $ROOT/etc/smartdns/ -p mkdir $ROOT/etc/smartdns/ -p
mkdir $ROOT/etc/default/ -p mkdir $ROOT/etc/default/ -p
mkdir $ROOT/lib/systemd/system/ -p mkdir $ROOT/lib/systemd/system/ -p
sed -i "s/Version:.*/Version: $VER/" $ROOT/DEBIAN/control sed -i "s/Version:.*/Version: $VER/" $ROOT/DEBIAN/control
sed -i "s/Architecture:.*/Architecture: $ARCH/" $ROOT/DEBIAN/control sed -i "s/Architecture:.*/Architecture: $ARCH/" $ROOT/DEBIAN/control
chmod 0755 $ROOT/DEBIAN/prerm chmod 0755 $ROOT/DEBIAN/prerm
cp $SMARTDNS_DIR/etc/smartdns/smartdns.conf $ROOT/etc/smartdns/ cp $SMARTDNS_DIR/etc/smartdns/smartdns.conf $ROOT/etc/smartdns/
cp $SMARTDNS_DIR/etc/default/smartdns $ROOT/etc/default/ cp $SMARTDNS_DIR/etc/default/smartdns $ROOT/etc/default/
cp $SMARTDNS_DIR/systemd/smartdns.service $ROOT/lib/systemd/system/ cp $SMARTDNS_DIR/systemd/smartdns.service $ROOT/lib/systemd/system/
cp $SMARTDNS_DIR/src/smartdns $ROOT/usr/sbin cp $SMARTDNS_DIR/src/smartdns $ROOT/usr/sbin
chmod +x $ROOT/usr/sbin/smartdns if [ $? -ne 0 ]; then
echo "copy smartdns file failed."
return 1
fi
chmod +x $ROOT/usr/sbin/smartdns
dpkg -b $ROOT $OUTPUTDIR/smartdns.$VER.$FILEARCH.deb dpkg -b $ROOT $OUTPUTDIR/smartdns.$VER.$FILEARCH.deb
rm -fr $ROOT/ rm -fr $ROOT/
} }
main() main()
@@ -74,38 +77,38 @@ main()
--arch) --arch)
ARCH="$2" ARCH="$2"
shift 2;; shift 2;;
--filearch) --filearch)
FILEARCH="$2" FILEARCH="$2"
shift 2;; shift 2;;
--ver) --ver)
VER="$2" VER="$2"
shift 2;; shift 2;;
-o ) -o )
OUTPUTDIR="$2" OUTPUTDIR="$2"
shift 2;; shift 2;;
-h | --help ) -h | --help )
showhelp showhelp
return 0 return 0
shift ;; shift ;;
-- ) shift; break ;; -- ) shift; break ;;
* ) break ;; * ) break ;;
esac esac
done done
if [ -z "$ARCH" ]; then if [ -z "$ARCH" ]; then
echo "please input arch." echo "please input arch."
return 1; return 1;
fi fi
if [ -z "$FILEARCH" ]; then if [ -z "$FILEARCH" ]; then
FILEARCH=$ARCH FILEARCH=$ARCH
fi fi
if [ -z "$OUTPUTDIR" ]; then if [ -z "$OUTPUTDIR" ]; then
OUTPUTDIR=$CURR_DIR; OUTPUTDIR=$CURR_DIR;
fi fi
build build
} }
main $@ main $@

98
package/linux/make.sh Normal file
View File

@@ -0,0 +1,98 @@
#!/bin/sh
CURR_DIR=$(cd $(dirname $0);pwd)
VER="`date +"1.%Y.%m.%d-%H%M"`"
SMARTDNS_DIR=$CURR_DIR/../../
SMARTDNS_BIN=$SMARTDNS_DIR/src/smartdns
showhelp()
{
echo "Usage: make [OPTION]"
echo "Options:"
echo " -o output directory."
echo " --arch archtecture."
echo " --ver version."
echo " -h show this message."
}
build()
{
PKG_ROOT=/tmp/smartdns-linux
rm -fr $PKG_ROOT
mkdir -p $PKG_ROOT/smartdns
cd $PKG_ROOT/
# Generic x86_64
mkdir $PKG_ROOT/smartdns/src -p
mkdir $PKG_ROOT/smartdns/package -p
cd $SMARTDNS_DIR
cp package/windows $PKG_ROOT/smartdns/package/ -a
cp etc systemd *.md LICENSE install $PKG_ROOT/smartdns/ -a
cp src/smartdns $PKG_ROOT/smartdns/src -a
if [ $? -ne 0 ]; then
echo "copy smartdns file failed"
rm -fr $PKG_ROOT
exit 1
fi
cd $PKG_ROOT
tar zcf $OUTPUTDIR/smartdns.$VER.$FILEARCH.tar.gz smartdns
if [ $? -ne 0 ]; then
echo "create package failed"
rm -fr $PKG_ROOT
exit 1
fi
cd $CURR_DIR
rm -fr $PKG_ROOT
}
main()
{
OPTS=`getopt -o o:h --long arch:,ver:,filearch: \
-n "" -- "$@"`
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
# Note the quotes around `$TEMP': they are essential!
eval set -- "$OPTS"
while true; do
case "$1" in
--arch)
ARCH="$2"
shift 2;;
--filearch)
FILEARCH="$2"
shift 2;;
--ver)
VER="$2"
shift 2;;
-o )
OUTPUTDIR="$2"
shift 2;;
-h | --help )
showhelp
return 0
shift ;;
-- ) shift; break ;;
* ) break ;;
esac
done
if [ -z "$ARCH" ]; then
echo "please input arch."
return 1;
fi
if [ -z "$FILEARCH" ]; then
FILEARCH=$ARCH
fi
if [ -z "$OUTPUTDIR" ]; then
OUTPUTDIR=$CURR_DIR;
fi
build
}
main $@
exit $?

View File

@@ -14,7 +14,6 @@
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
CURR_DIR=$(cd $(dirname $0);pwd) CURR_DIR=$(cd $(dirname $0);pwd)
VER="`date +"1.%Y.%m.%d-%H%M"`" VER="`date +"1.%Y.%m.%d-%H%M"`"
@@ -27,58 +26,58 @@ showhelp()
echo "Options:" echo "Options:"
echo " -o output directory." echo " -o output directory."
echo " --arch archtecture." echo " --arch archtecture."
echo " --ver version." echo " --ver version."
echo " -h show this message." echo " -h show this message."
} }
build_tool() build_tool()
{ {
make -C $ROOT/tool/po2lmo -j make -C $ROOT/tool/po2lmo -j
PO2LMO="$ROOT/tool/po2lmo/src/po2lmo" PO2LMO="$ROOT/tool/po2lmo/src/po2lmo"
} }
clean_tool() clean_tool()
{ {
make -C $ROOT/tool/po2lmo clean make -C $ROOT/tool/po2lmo clean
} }
build() build()
{ {
ROOT=/tmp/luci-app-smartdns ROOT=/tmp/luci-app-smartdns
rm -fr $ROOT rm -fr $ROOT
mkdir -p $ROOT mkdir -p $ROOT
cp $CURR_DIR/* $ROOT/ -af cp $CURR_DIR/* $ROOT/ -af
cd $ROOT/ cd $ROOT/
build_tool build_tool
mkdir $ROOT/root/usr/lib/lua/ -p mkdir $ROOT/root/usr/lib/lua/ -p
cp $ROOT/files/luci $ROOT/root/usr/lib/lua/ -af cp $ROOT/files/luci $ROOT/root/usr/lib/lua/ -af
#Generate Language #Generate Language
$PO2LMO $ROOT/files/luci/i18n/smartdns.zh-cn.po $ROOT/root/usr/lib/lua/luci/i18n/smartdns.zh-cn.lmo $PO2LMO $ROOT/files/luci/i18n/smartdns.zh-cn.po $ROOT/root/usr/lib/lua/luci/i18n/smartdns.zh-cn.lmo
rm $ROOT/root/usr/lib/lua/luci/i18n/smartdns.zh-cn.po rm $ROOT/root/usr/lib/lua/luci/i18n/smartdns.zh-cn.po
cp $ROOT/files/etc $ROOT/root/ -af cp $ROOT/files/etc $ROOT/root/ -af
INST_SIZE="`du -sb $ROOT/root/ | awk '{print $1}'`" INST_SIZE="`du -sb $ROOT/root/ | awk '{print $1}'`"
sed -i "s/^Architecture.*/Architecture: $ARCH/g" $ROOT/control/control sed -i "s/^Architecture.*/Architecture: all/g" $ROOT/control/control
sed -i "s/Version:.*/Version: $VER/" $ROOT/control/control sed -i "s/Version:.*/Version: $VER/" $ROOT/control/control
if [ ! -z "$INST_SIZE" ]; then if [ ! -z "$INST_SIZE" ]; then
echo "Installed-Size: $INST_SIZE" >> $ROOT/control/control echo "Installed-Size: $INST_SIZE" >> $ROOT/control/control
fi fi
cd $ROOT/control cd $ROOT/control
chmod +x * chmod +x *
tar zcf ../control.tar.gz ./ tar zcf ../control.tar.gz ./
cd $ROOT cd $ROOT
tar zcf $ROOT/data.tar.gz -C root . tar zcf $ROOT/data.tar.gz -C root .
tar zcf $OUTPUTDIR/luci-app-smartdns.$VER.$FILEARCH.ipk control.tar.gz data.tar.gz debian-binary tar zcf $OUTPUTDIR/luci-app-smartdns.$VER.$FILEARCH.ipk control.tar.gz data.tar.gz debian-binary
rm -fr $ROOT/ rm -fr $ROOT/
} }
main() main()
@@ -96,38 +95,38 @@ main()
--arch) --arch)
ARCH="$2" ARCH="$2"
shift 2;; shift 2;;
--filearch) --filearch)
FILEARCH="$2" FILEARCH="$2"
shift 2;; shift 2;;
--ver) --ver)
VER="$2" VER="$2"
shift 2;; shift 2;;
-o ) -o )
OUTPUTDIR="$2" OUTPUTDIR="$2"
shift 2;; shift 2;;
-h | --help ) -h | --help )
showhelp showhelp
return 0 return 0
shift ;; shift ;;
-- ) shift; break ;; -- ) shift; break ;;
* ) break ;; * ) break ;;
esac esac
done done
if [ -z "$ARCH" ]; then if [ -z "$ARCH" ]; then
echo "please input arch." echo "please input arch."
return 1; return 1;
fi fi
if [ -z "$FILEARCH" ]; then if [ -z "$FILEARCH" ]; then
FILEARCH=$ARCH FILEARCH=$ARCH
fi fi
if [ -z "$OUTPUTDIR" ]; then if [ -z "$OUTPUTDIR" ]; then
OUTPUTDIR=$CURR_DIR; OUTPUTDIR=$CURR_DIR;
fi fi
build build
} }
main $@ main $@

View File

@@ -14,7 +14,6 @@
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
CURR_DIR=$(cd $(dirname $0);pwd) CURR_DIR=$(cd $(dirname $0);pwd)
VER="`date +"1.%Y.%m.%d-%H%M"`" VER="`date +"1.%Y.%m.%d-%H%M"`"
@@ -31,47 +30,52 @@ showhelp()
echo "Options:" echo "Options:"
echo " -o output directory." echo " -o output directory."
echo " --arch archtecture." echo " --arch archtecture."
echo " --ver version." echo " --ver version."
echo " -h show this message." echo " -h show this message."
} }
build() build()
{ {
ROOT=/tmp/smartdns-openwrt ROOT=/tmp/smartdns-openwrt
rm -fr $ROOT rm -fr $ROOT
mkdir -p $ROOT mkdir -p $ROOT
cp $CURR_DIR/* $ROOT/ -af cp $CURR_DIR/* $ROOT/ -af
cd $ROOT/ cd $ROOT/
mkdir $ROOT/root/usr/sbin -p mkdir $ROOT/root/usr/sbin -p
mkdir $ROOT/root/etc/init.d -p mkdir $ROOT/root/etc/init.d -p
mkdir $ROOT/root/etc/smartdns/ -p mkdir $ROOT/root/etc/smartdns/ -p
cp $SMARTDNS_CONF $ROOT/root/etc/smartdns/ cp $SMARTDNS_CONF $ROOT/root/etc/smartdns/
cp $ADDRESS_CONF $ROOT/root/etc/smartdns/ cp $ADDRESS_CONF $ROOT/root/etc/smartdns/
cp $BLACKLIST_IP_CONF $ROOT/root/etc/smartdns/ cp $BLACKLIST_IP_CONF $ROOT/root/etc/smartdns/
cp $CUSTOM_CONF $ROOT/root/etc/smartdns/ cp $CUSTOM_CONF $ROOT/root/etc/smartdns/
cp $CURR_DIR/files/etc $ROOT/root/ -af cp $CURR_DIR/files/etc $ROOT/root/ -af
cp $SMARTDNS_BIN $ROOT/root/usr/sbin cp $SMARTDNS_BIN $ROOT/root/usr/sbin
if [ $? -ne 0 ]; then
echo "copy smartdns file failed."
rm -fr $ROOT/
return 1
fi
chmod +x $ROOT/root/etc/init.d/smartdns chmod +x $ROOT/root/etc/init.d/smartdns
INST_SIZE="`du -sb $ROOT/root/ | awk '{print $1}'`" INST_SIZE="`du -sb $ROOT/root/ | awk '{print $1}'`"
sed -i "s/^Architecture.*/Architecture: $ARCH/g" $ROOT/control/control sed -i "s/^Architecture.*/Architecture: $ARCH/g" $ROOT/control/control
sed -i "s/Version:.*/Version: $VER/" $ROOT/control/control sed -i "s/Version:.*/Version: $VER/" $ROOT/control/control
sed -i "s/^\(bind .*\):53/\1:6053/g" $ROOT/root/etc/smartdns/smartdns.conf sed -i "s/^\(bind .*\):53/\1:6053/g" $ROOT/root/etc/smartdns/smartdns.conf
if [ ! -z "$INST_SIZE" ]; then if [ ! -z "$INST_SIZE" ]; then
echo "Installed-Size: $INST_SIZE" >> $ROOT/control/control echo "Installed-Size: $INST_SIZE" >> $ROOT/control/control
fi fi
cd $ROOT/control cd $ROOT/control
chmod +x * chmod +x *
tar zcf ../control.tar.gz --owner=0 --group=0 ./ tar zcf ../control.tar.gz --owner=0 --group=0 ./
cd $ROOT cd $ROOT
tar zcf $ROOT/data.tar.gz -C root --owner=0 --group=0 . tar zcf $ROOT/data.tar.gz -C root --owner=0 --group=0 .
tar zcf $OUTPUTDIR/smartdns.$VER.$FILEARCH.ipk --owner=0 --group=0 control.tar.gz data.tar.gz debian-binary tar zcf $OUTPUTDIR/smartdns.$VER.$FILEARCH.ipk --owner=0 --group=0 control.tar.gz data.tar.gz debian-binary
rm -fr $ROOT/ rm -fr $ROOT/
} }
main() main()
@@ -89,38 +93,38 @@ main()
--arch) --arch)
ARCH="$2" ARCH="$2"
shift 2;; shift 2;;
--filearch) --filearch)
FILEARCH="$2" FILEARCH="$2"
shift 2;; shift 2;;
--ver) --ver)
VER="$2" VER="$2"
shift 2;; shift 2;;
-o ) -o )
OUTPUTDIR="$2" OUTPUTDIR="$2"
shift 2;; shift 2;;
-h | --help ) -h | --help )
showhelp showhelp
return 0 return 0
shift ;; shift ;;
-- ) shift; break ;; -- ) shift; break ;;
* ) break ;; * ) break ;;
esac esac
done done
if [ -z "$ARCH" ]; then if [ -z "$ARCH" ]; then
echo "please input arch." echo "please input arch."
return 1; return 1;
fi fi
if [ -z "$FILEARCH" ]; then if [ -z "$FILEARCH" ]; then
FILEARCH=$ARCH FILEARCH=$ARCH
fi fi
if [ -z "$OUTPUTDIR" ]; then if [ -z "$OUTPUTDIR" ]; then
OUTPUTDIR=$CURR_DIR; OUTPUTDIR=$CURR_DIR;
fi fi
build build
} }
main $@ main $@

View File

@@ -14,7 +14,6 @@
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
CURR_DIR=$(cd $(dirname $0);pwd) CURR_DIR=$(cd $(dirname $0);pwd)
VER="`date +"1.%Y.%m.%d-%H%M"`" VER="`date +"1.%Y.%m.%d-%H%M"`"
SMARTDNS_DIR=$CURR_DIR/../../ SMARTDNS_DIR=$CURR_DIR/../../
@@ -28,39 +27,44 @@ showhelp()
echo "Options:" echo "Options:"
echo " -o output directory." echo " -o output directory."
echo " --arch archtecture." echo " --arch archtecture."
echo " --ver version." echo " --ver version."
echo " -h show this message." echo " -h show this message."
} }
build() build()
{ {
ROOT=/tmp/smartdns-optware ROOT=/tmp/smartdns-optware
rm -fr $ROOT rm -fr $ROOT
mkdir -p $ROOT mkdir -p $ROOT
cp $CURR_DIR/* $ROOT/ -af cp $CURR_DIR/* $ROOT/ -af
cd $ROOT/ cd $ROOT/
mkdir $ROOT/opt/usr/sbin -p mkdir $ROOT/opt/usr/sbin -p
mkdir $ROOT/opt/etc/init.d -p mkdir $ROOT/opt/etc/init.d -p
mkdir $ROOT/opt/etc/smartdns/ -p mkdir $ROOT/opt/etc/smartdns/ -p
cp $SMARTDNS_CONF $ROOT/opt/etc/smartdns/ cp $SMARTDNS_CONF $ROOT/opt/etc/smartdns/
cp $SMARTDNS_OPT $ROOT/opt/etc/smartdns/ cp $SMARTDNS_OPT $ROOT/opt/etc/smartdns/
cp $CURR_DIR/S50smartdns $ROOT/opt/etc/init.d/ cp $CURR_DIR/S50smartdns $ROOT/opt/etc/init.d/
cp $SMARTDNS_BIN $ROOT/opt/usr/sbin cp $SMARTDNS_BIN $ROOT/opt/usr/sbin
if [ $? -ne 0 ]; then
echo "copy smartdns file failed."
rm -fr $ROOT/
return 1
fi
sed -i "s/# *server-name smartdns/server-name smartdns/g" $ROOT/opt/etc/smartdns/smartdns.conf sed -i "s/# *server-name smartdns/server-name smartdns/g" $ROOT/opt/etc/smartdns/smartdns.conf
sed -i "s/^Architecture.*/Architecture: $ARCH/g" $ROOT/control/control sed -i "s/^Architecture.*/Architecture: $ARCH/g" $ROOT/control/control
sed -i "s/Version:.*/Version: $VER/" $ROOT/control/control sed -i "s/Version:.*/Version: $VER/" $ROOT/control/control
cd $ROOT/control cd $ROOT/control
chmod +x * chmod +x *
tar zcf ../control.tar.gz --owner=0 --group=0 ./ tar zcf ../control.tar.gz --owner=0 --group=0 ./
cd $ROOT cd $ROOT
tar zcf data.tar.gz --owner=0 --group=0 opt tar zcf data.tar.gz --owner=0 --group=0 opt
tar zcf $OUTPUTDIR/smartdns.$VER.$FILEARCH.ipk --owner=0 --group=0 control.tar.gz data.tar.gz debian-binary tar zcf $OUTPUTDIR/smartdns.$VER.$FILEARCH.ipk --owner=0 --group=0 control.tar.gz data.tar.gz debian-binary
rm -fr $ROOT/ rm -fr $ROOT/
} }
main() main()
@@ -78,38 +82,38 @@ main()
--arch) --arch)
ARCH="$2" ARCH="$2"
shift 2;; shift 2;;
--filearch) --filearch)
FILEARCH="$2" FILEARCH="$2"
shift 2;; shift 2;;
--ver) --ver)
VER="$2" VER="$2"
shift 2;; shift 2;;
-o ) -o )
OUTPUTDIR="$2" OUTPUTDIR="$2"
shift 2;; shift 2;;
-h | --help ) -h | --help )
showhelp showhelp
return 0 return 0
shift ;; shift ;;
-- ) shift; break ;; -- ) shift; break ;;
* ) break ;; * ) break ;;
esac esac
done done
if [ -z "$ARCH" ]; then if [ -z "$ARCH" ]; then
echo "please input arch." echo "please input arch."
return 1; return 1;
fi fi
if [ -z "$FILEARCH" ]; then if [ -z "$FILEARCH" ]; then
FILEARCH=$ARCH FILEARCH=$ARCH
fi fi
if [ -z "$OUTPUTDIR" ]; then if [ -z "$OUTPUTDIR" ]; then
OUTPUTDIR=$CURR_DIR; OUTPUTDIR=$CURR_DIR;
fi fi
build build
} }
main $@ main $@