Skip to content

Commit 922e7b7

Browse files
committed
build: fix build script issue.
1 parent bfb0382 commit 922e7b7

File tree

3 files changed

+146
-151
lines changed

3 files changed

+146
-151
lines changed

package/build-pkg.sh

Lines changed: 94 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ showhelp()
5353

5454
init_env()
5555
{
56-
if [ -z "$CC" ]; then
57-
CC=gcc
58-
fi
56+
if [ -z "$CC" ]; then
57+
CC=gcc
58+
fi
5959

6060
MAKE_NJOBS=$(grep processor /proc/cpuinfo | wc -l 2>/dev/null || echo 1)
6161
export MAKE_NJOBS
@@ -70,13 +70,13 @@ init_env()
7070
SMARTDNS_WITH_LIBS=1
7171
fi
7272

73-
check_cc="`echo "$CC" | grep -E "(\-gcc|\-cc)"`"
74-
if [ ! -z "$check_cc" ]; then
75-
TARGET_ARCH="`$CC -dumpmachine`"
76-
echo "target arch: $TARGET_ARCH"
77-
fi
73+
check_cc="`echo "$CC" | grep -E "(\-gcc|\-cc)"`"
74+
if [ ! -z "$check_cc" ]; then
75+
TARGET_ARCH="`$CC -dumpmachine`"
76+
echo "target arch: $TARGET_ARCH"
77+
fi
7878

79-
if [ $SMARTDNS_WITH_LIBS -eq 1 ]; then
79+
if [ $SMARTDNS_WITH_LIBS -eq 1 ]; then
8080
case "$TARGET_ARCH" in
8181
*arm*)
8282
NEED_UPDATE_ARM_CP15=1
@@ -103,89 +103,89 @@ copy_smartdns_libs()
103103
{
104104
SMARTDNS_BIN="$CODE_DIR/src/smartdns"
105105

106-
copy_libs_recursive $SMARTDNS_BIN
107-
if [ $? -ne 0 ]; then
108-
echo "copy libs failed"
109-
return 1
110-
fi
111-
112-
LIB_WEBUI_SO="$CODE_DIR/plugin/smartdns-ui/target/smartdns_ui.so"
113-
copy_libs_recursive $LIB_WEBUI_SO
114-
if [ $? -ne 0 ]; then
115-
echo "copy libs failed"
116-
return 1
117-
fi
106+
copy_libs_recursive $SMARTDNS_BIN
107+
if [ $? -ne 0 ]; then
108+
echo "copy libs failed"
109+
return 1
110+
fi
111+
112+
LIB_WEBUI_SO="$CODE_DIR/plugin/smartdns-ui/target/smartdns_ui.so"
113+
copy_libs_recursive $LIB_WEBUI_SO
114+
if [ $? -ne 0 ]; then
115+
echo "copy libs failed"
116+
return 1
117+
fi
118118
}
119119

120120
copy_libs_recursive()
121121
{
122-
local lib=$1
123-
local lib_path=`$CC -print-file-name=$lib`
124-
if [ -z "$lib_path" ]; then
125-
return 0
126-
fi
127-
128-
if [ -e $SMARTDNS_STATIC_DIR/lib/$lib ]; then
129-
return 0
130-
fi
131-
132-
local tmp_path="`echo "$lib_path" | grep "libc.so"`"
133-
if [ ! -z "$tmp_path" ]; then
134-
LIBC_PATH="$tmp_path"
135-
fi
136-
137-
if [ "$lib" != "$SMARTDNS_BIN" ]; then
138-
echo "copy $lib_path to $SMARTDNS_STATIC_DIR/lib"
139-
cp $lib_path $SMARTDNS_STATIC_DIR/lib
140-
if [ $? -ne 0 ]; then
141-
echo "copy $lib failed"
142-
return 1
143-
fi
144-
fi
145-
146-
local shared_libs="`objdump -p $lib_path | grep NEEDED | awk '{print $2}'`"
147-
for sub_lib in $shared_libs; do
148-
copy_libs_recursive $sub_lib
149-
if [ $? -ne 0 ]; then
150-
return 1
151-
fi
152-
done
153-
154-
return 0
122+
local lib=$1
123+
local lib_path=`$CC -print-file-name=$lib`
124+
if [ -z "$lib_path" ]; then
125+
return 0
126+
fi
127+
128+
if [ -e $SMARTDNS_STATIC_DIR/lib/$lib ]; then
129+
return 0
130+
fi
131+
132+
local tmp_path="`echo "$lib_path" | grep "libc.so"`"
133+
if [ ! -z "$tmp_path" ]; then
134+
LIBC_PATH="$tmp_path"
135+
fi
136+
137+
if [ "$lib" != "$SMARTDNS_BIN" ]; then
138+
echo "copy $lib_path to $SMARTDNS_STATIC_DIR/lib"
139+
cp $lib_path $SMARTDNS_STATIC_DIR/lib
140+
if [ $? -ne 0 ]; then
141+
echo "copy $lib failed"
142+
return 1
143+
fi
144+
fi
145+
146+
local shared_libs="`objdump -p $lib_path | grep NEEDED | awk '{print $2}'`"
147+
for sub_lib in $shared_libs; do
148+
copy_libs_recursive $sub_lib
149+
if [ $? -ne 0 ]; then
150+
return 1
151+
fi
152+
done
153+
154+
return 0
155155
}
156156

157157
copy_linker()
158158
{
159-
LINK_PATH=`$CC -print-file-name=$LINKER_NAME`
160-
SYM_LINKER_NAME=`readlink -f $LINK_PATH`
161-
162-
echo "linker: $LINK_PATH"
163-
echo "sym linker: $SYM_LINKER_NAME"
164-
echo "libc: $LIBC_PATH"
165-
166-
if [ "$SYM_LINKER_NAME" = "$LIBC_PATH" ]; then
167-
ln -f -s $(basename $LIBC_PATH) $SMARTDNS_STATIC_DIR/lib/$(basename $LINKER_NAME)
168-
else
169-
cp $LINK_PATH $SMARTDNS_STATIC_DIR/lib -af
170-
if [ $? -ne 0 ]; then
171-
echo "copy $lib failed"
172-
return 1
173-
fi
174-
175-
SYM_LINKER_NAME=`readlink $SMARTDNS_STATIC_DIR/lib/$LINKER_NAME`
176-
if [ ! -e $SMARTDNS_STATIC_DIR/lib/$SYM_LINKER_NAME ]; then
177-
SYM_LINKER_NAME=`basename $SYM_LINKER_NAME`
178-
ln -f -s $SYM_LINKER_NAME $SMARTDNS_STATIC_DIR/lib/$LINKER_NAME
179-
fi
180-
fi
181-
182-
ln -f -s ${LINKER_NAME} ${SMARTDNS_STATIC_DIR}/lib/ld-linux.so
183-
if [ $? -ne 0 ]; then
184-
echo "copy $lib failed"
185-
return 1
186-
fi
187-
188-
return 0
159+
LINK_PATH=`$CC -print-file-name=$LINKER_NAME`
160+
SYM_LINKER_NAME=`readlink -f $LINK_PATH`
161+
162+
echo "linker: $LINK_PATH"
163+
echo "sym linker: $SYM_LINKER_NAME"
164+
echo "libc: $LIBC_PATH"
165+
166+
if [ "$SYM_LINKER_NAME" = "$LIBC_PATH" ]; then
167+
ln -f -s $(basename $LIBC_PATH) $SMARTDNS_STATIC_DIR/lib/$(basename $LINKER_NAME)
168+
else
169+
cp $LINK_PATH $SMARTDNS_STATIC_DIR/lib -af
170+
if [ $? -ne 0 ]; then
171+
echo "copy $lib failed"
172+
return 1
173+
fi
174+
175+
SYM_LINKER_NAME=`readlink $SMARTDNS_STATIC_DIR/lib/$LINKER_NAME`
176+
if [ ! -e $SMARTDNS_STATIC_DIR/lib/$SYM_LINKER_NAME ]; then
177+
SYM_LINKER_NAME=`basename $SYM_LINKER_NAME`
178+
ln -f -s $SYM_LINKER_NAME $SMARTDNS_STATIC_DIR/lib/$LINKER_NAME
179+
fi
180+
fi
181+
182+
ln -f -s ${LINKER_NAME} ${SMARTDNS_STATIC_DIR}/lib/ld-linux.so
183+
if [ $? -ne 0 ]; then
184+
echo "copy $lib failed"
185+
return 1
186+
fi
187+
188+
return 0
189189
}
190190

191191
build_smartdns()
@@ -238,12 +238,12 @@ build_smartdns()
238238
cp $CURR_DIR/run-smartdns $SMARTDNS_STATIC_DIR
239239
chmod +x $SMARTDNS_STATIC_DIR/run-smartdns
240240
if [ "$NEED_UPDATE_ARM_CP15" = "1" ]; then
241-
sed -i 's/NEED_CHECK_ARM_CP15=0/NEED_CHECK_ARM_CP15=1/' $SMARTDNS_STATIC_DIR/run-smartdns
242-
if [ $? -ne 0 ]; then
243-
echo "sed run-smartdns failed"
244-
return 1
245-
fi
246-
fi
241+
sed -i 's/NEED_CHECK_ARM_CP15=0/NEED_CHECK_ARM_CP15=1/' $SMARTDNS_STATIC_DIR/run-smartdns
242+
if [ $? -ne 0 ]; then
243+
echo "sed run-smartdns failed"
244+
return 1
245+
fi
246+
fi
247247

248248
copy_smartdns_libs
249249
if [ $? -ne 0 ]; then
@@ -253,10 +253,10 @@ build_smartdns()
253253
rm $SMARTDNS_STATIC_DIR/lib/smartdns_ui.so >/dev/null 2>&1
254254

255255
copy_linker
256-
if [ $? -ne 0 ]; then
257-
echo "copy linker failed"
258-
return 1
259-
fi
256+
if [ $? -ne 0 ]; then
257+
echo "copy linker failed"
258+
return 1
259+
fi
260260

261261
return 0
262262
}

package/copy-smartdns.sh

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -6,57 +6,57 @@ CODE_DIR="$CURR_DIR/.."
66
SMARTDNS_STATIC_DIR="$WORKDIR/smartdns-static"
77

88
main() {
9-
TARGET_DIR=$1
10-
PREFIX=$2
11-
if [ -z "$TARGET_DIR" ]; then
12-
echo "Usage: $0 <target_directory> [prefix_directory]"
13-
exit 1
14-
fi
15-
16-
if [ ! -d "$TARGET_DIR" ]; then
17-
echo "Target directory $TARGET_DIR does not exist."
18-
exit 1
19-
fi
20-
21-
22-
if [ ! -f "$SMARTDNS_STATIC_DIR/smartdns" ]; then
23-
cp "$CODE_DIR/src/smartdns" "$TARGET_DIR$PREFIX/usr/sbin/smartdns"
24-
if [ $? -ne 0 ]; then
25-
echo "Failed to copy smartdns binary to $TARGET_DIR/usr/sbin."
26-
return 1
27-
fi
28-
29-
chmod +x "$TARGET_DIR/usr/sbin/smartdns"
30-
31-
return 0
32-
fi
33-
34-
if [ ! -f "$SMARTDNS_STATIC_DIR/smartdns" ]; then
35-
echo "SmartDNS binary not found in $SMARTDNS_STATIC_DIR."
36-
return 1
37-
fi
38-
39-
mkdir -p "$TARGET_DIR/usr/local/lib/smartdns"
40-
if [ $? -ne 0 ]; then
41-
echo "Failed to create directory $TARGET_DIR/usr/local/lib/smartdns."
42-
return 1
43-
fi
44-
45-
cp $SMARTDNS_STATIC_DIR/* $TARGET_DIR/usr/local/lib/smartdns/ -a
46-
if [ $? -ne 0 ]; then
47-
echo "Failed to copy smartdns static files to $TARGET_DIR/usr/local/lib/smartdns."
48-
return 1
49-
fi
50-
51-
ln -f -s "$PREFIX/usr/local/lib/smartdns/run-smartdns" "$TARGET_DIR/usr/sbin/smartdns"
52-
if [ $? -ne 0 ]; then
53-
echo "Failed to create symlink for smartdns in $TARGET_DIR/usr/sbin."
54-
return 1
55-
fi
56-
chmod +x "$TARGET_DIR/usr/local/lib/smartdns/run-smartdns"
57-
58-
echo "SmartDNS files copied successfully to $TARGET_DIR."
59-
return 0
9+
TARGET_DIR=$1
10+
PREFIX=$2
11+
if [ -z "$TARGET_DIR" ]; then
12+
echo "Usage: $0 <target_directory> [prefix_directory]"
13+
exit 1
14+
fi
15+
16+
if [ ! -d "$TARGET_DIR" ]; then
17+
echo "Target directory $TARGET_DIR does not exist."
18+
exit 1
19+
fi
20+
21+
22+
if [ ! -f "$SMARTDNS_STATIC_DIR/smartdns" ]; then
23+
cp "$CODE_DIR/src/smartdns" "$TARGET_DIR$PREFIX/usr/sbin/smartdns"
24+
if [ $? -ne 0 ]; then
25+
echo "Failed to copy smartdns binary to $TARGET_DIR$PREFIX/usr/sbin."
26+
return 1
27+
fi
28+
29+
chmod +x "$TARGET_DIR$PREFIX/usr/sbin/smartdns"
30+
31+
return 0
32+
fi
33+
34+
if [ ! -f "$SMARTDNS_STATIC_DIR/smartdns" ]; then
35+
echo "SmartDNS binary not found in $SMARTDNS_STATIC_DIR."
36+
return 1
37+
fi
38+
39+
mkdir -p "$TARGET_DIR$PREFIX/usr/local/lib/smartdns"
40+
if [ $? -ne 0 ]; then
41+
echo "Failed to create directory $TARGET_DIR$PREFIX/usr/local/lib/smartdns."
42+
return 1
43+
fi
44+
45+
cp $SMARTDNS_STATIC_DIR/* $TARGET_DIR$PREFIX/usr/local/lib/smartdns/ -a
46+
if [ $? -ne 0 ]; then
47+
echo "Failed to copy smartdns static files to $TARGET_DIR$PREFIX/usr/local/lib/smartdns."
48+
return 1
49+
fi
50+
51+
ln -f -s "$PREFIX/usr/local/lib/smartdns/run-smartdns" "$TARGET_DIR$PREFIX/usr/sbin/smartdns"
52+
if [ $? -ne 0 ]; then
53+
echo "Failed to create symlink for smartdns in $TARGET_DIR$PREFIX/usr/sbin."
54+
return 1
55+
fi
56+
chmod +x "$TARGET_DIR$PREFIX/usr/local/lib/smartdns/run-smartdns"
57+
58+
echo "SmartDNS files copied successfully to $TARGET_DIR$PREFIX."
59+
return 0
6060
}
6161

6262
main $@

package/optware/make.sh

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,12 @@ build()
4949
cp $SMARTDNS_CONF $ROOT/opt/etc/smartdns/
5050
cp $SMARTDNS_OPT $ROOT/opt/etc/smartdns/
5151
cp $CURR_DIR/S50smartdns $ROOT/opt/etc/init.d/
52-
$SMARTDNS_CP $ROOT/opt /opt
52+
$SMARTDNS_CP $ROOT /opt
5353
if [ $? -ne 0 ]; then
5454
echo "copy smartdns file failed."
5555
rm -fr $PKG_ROOT
5656
return 1
5757
fi
58-
if [ $? -ne 0 ]; then
59-
echo "copy smartdns file failed."
60-
rm -fr $ROOT/
61-
return 1
62-
fi
6358

6459
if [ $IS_BUILD_SMARTDNS_UI -ne 0 ]; then
6560
mkdir $ROOT/opt/usr/lib/smartdns -p

0 commit comments

Comments
 (0)