forked from lancethepants/tomatoware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
package.sh
executable file
·103 lines (83 loc) · 4.06 KB
/
package.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/bash
set -e
set -x
BASE=`pwd`
DEST=$BASE$PREFIX
SRC=$BASE/src
if [ -f $BASE/.packaged ]; then
exit
fi
if [ "$DESTARCH" = "arm" ]; then
GNUEABI=gnueabi
# copy golang build script for arm builds
mkdir -p $DEST/scripts
cp $SRC/golang/build_go.sh $DEST/scripts
sed -i 's,\/mmc,'"$PREFIX"',g' $DEST/scripts/build_go.sh
SCRIPTS=scripts
fi
#Copy lib and include files from toolchain for use in the deployment system.
cp -rf /opt/tomatoware/$DESTARCH-$FLOAT${PREFIX////-}/usr/$DESTARCH-buildroot-linux-uclibc$GNUEABI/sysroot/lib $DEST
cp -rf /opt/tomatoware/$DESTARCH-$FLOAT${PREFIX////-}/usr/$DESTARCH-buildroot-linux-uclibc$GNUEABI/sysroot/usr $DEST
cp -rf $DEST/usr/include $DEST
rm -rf $DEST/usr/include
ln -s $PREFIX/usr/lib/crt1.o $DEST/lib/crt1.o
ln -s $PREFIX/usr/lib/crti.o $DEST/lib/crti.o
ln -s $PREFIX/usr/lib/crtn.o $DEST/lib/crtn.o
ln -s $PREFIX/usr/lib/Scrt1.o $DEST/lib/Scrt1.o
ln -s $PREFIX/usr/lib/libstdc++.so.6.0.22 $DEST/lib/libstdc++.so.6.0.22
ln -s $PREFIX/usr/lib/libstdc++.so.6.0.22 $DEST/lib/libstdc++.so.6
ln -s $PREFIX/usr/lib/libstdc++.so.6.0.22 $DEST/lib/libstdc++.so
#Remove build path directory $BASE from all libtool .la files.
#This makes sure the libtool files show the correct paths to libraries for the deployment system.
find $DEST/lib -iname \*.la -exec sed -i 's,'"$BASE"',,g' {} \;
#Change the base library libtool (.la) files to reference their correct location in the target system.
find $DEST/lib -iname \*.la -exec sed -i 's,\/opt\/tomatoware\/'"$DESTARCH"'-'"$FLOAT"''"${PREFIX////-}"'/'"$DESTARCH"'-linux-uclibc,'"$PREFIX"',g' {} \;
#Make sure all perl scripts have the correct interpreter path.
grep -Irl "\#\!\/usr\/bin\/perl" $DEST | xargs sed -i -e '1,1s,\#\!\/usr\/bin\/perl,\#\!'"$PREFIX"'\/bin\/perl,g'
grep -Irl "\#\! \/usr\/bin\/perl" $DEST | xargs sed -i -e '1,1s,\#\! \/usr\/bin\/perl,\#\! '"$PREFIX"'\/bin\/perl,g'
#Make sure all bash scripts have the correct interpreter path.
grep -Irl "\#\!\/bin\/bash" $DEST | xargs sed -i -e '1,1s,\#\!\/bin\/bash,\#\!'"$PREFIX"'\/bin\/bash,g'
grep -Irl "\#\! \/bin\/bash" $DEST | xargs sed -i -e '1,1s,\#\! \/bin\/bash,\#\! '"$PREFIX"'\/bin\/bash,g'
#Copy and set correct interpreter path for the .autorun file
cp $SRC/.autorun $DEST
sed -i 's,\/opt,'"$PREFIX"',g' $DEST/.autorun
#Create $PREFIX/etc/profile
mkdir -p $DEST/tmp
cd $DEST/etc
echo "#!/bin/sh" > profile
echo "" >> profile
echo "# Please note it's not a system-wide settings, it's only for a current" >> profile
echo "# terminal session. Point your f\w (if necessery) to execute $PREFIX/etc/profile" >> profile
echo "# at console logon." >> profile
echo "" >> profile
if [ $PREFIX = "/opt" ];
then
echo "export PATH='/opt/usr/sbin:/opt/sbin:/opt/bin:/opt/bin/go/bin:/opt/go/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/sbin:/bin'" >> profile
else
echo "export PATH='$PREFIX/sbin:$PREFIX/bin:$PREFIX/bin/go/bin:$PREFIX/go/bin:/opt/usr/sbin:/opt/sbin:/opt/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/sbin:/bin'" >> profile
fi
echo "export TERM=xterm" >> profile
echo "export TERMINFO=$PREFIX/share/terminfo" >> profile
echo "export TMP=$PREFIX/tmp" >> profile
echo "export TEMP=$PREFIX/tmp" >> profile
echo "export TMPDIR=$PREFIX/tmp" >> profile
echo "export PKG_CONFIG_LIBDIR=$PREFIX/lib/pkgconfig" >> profile
echo "export CONFIG_SHELL=$PREFIX/bin/bash" >> profile
echo "export M4=$PREFIX/bin/m4" >> profile
echo "export GOPATH=$PREFIX/go" >> profile
echo "" >> profile
echo "# An influential go environment variable for creating static binaries." >> profile
echo "# Build static by default." >> profile
echo "export CGO_ENABLED=0" >> profile
echo "" >> profile
echo "# You may define localization" >> profile
echo "#export LANG='ru_RU.UTF-8'" >> profile
echo "#export LC_ALL='ru_RU.UTF-8'" >> profile
echo "" >> profile
echo "alias ls='ls --color'" >> profile
chmod +x profile
#Create tarball of the compiled project.
cd $BASE$PREFIX
chmod 1777 tmp/
fakeroot tar zvcf $BASE/$DESTARCH-$FLOAT${PREFIX////-}.tgz $DESTARCH-buildroot-linux-uclibc$GNUEABI bin/ docs/ etc/ include/ lib/ libexec/ man/ sbin/ $SCRIPTS share/ ssl/ tmp/ usr/ var/ .autorun .vimrc
touch $BASE/.packaged