forked from puppylinux-woof-CE/petbuilds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
func
120 lines (109 loc) · 2.99 KB
/
func
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# functions library
. ../build.conf
check_md5() {
SRC=$1
MD5_DLD=`md5sum $SRC`
MD5_LST=`grep -w "$SRC" ../md5sums.txt`
if [ "$MD5_DLD" = "${MD5_LST}" ];then
echo "md5 passed"
else
echo "md5 failed - IF YOU KNOW IT IS GOOD add the source to ./0sources and run
./update_md5_db" && exit 1
fi
}
retrieve() {
SRCS=${1%% *}
WC=`echo "$1" | wc -w`
[ "$WC" -eq 2 ] && CERT=${1##* }
[ -f ../0sources/"$SRCS" ] &&\
cp -a ../0sources/${SRCS} . ||\
wget -t0 -c ${URL}/${SRCS} $CERT
[ "$?" -eq 0 ] || exit 1
check_md5 $SRCS
sleep 1
if [ "$DLD_ONLY" -eq 0 ];then
mv -f ${SRCS} ../0sources
exit 0
fi
}
extract() {
tar -xvf ${1}
[ "$?" -eq 0 ] || exit
mv -f ${1} ../0sources/
}
alert () {
echo "
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ATTENTION!
$1 needs to be installed now if it is not on your system.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
"
sleep 5
}
get_files() {
find "$1" -type f -name '*' > ${2}.files.tmp
find "$1" -type l -name '*' >> ${2}.files.tmp
find "$1" -type d -empty >> ${2}.files.tmp
cat ${2}.files.tmp | sort -u > ${2}.files
rm ${2}.files.tmp
}
build_configure() {
PKG=$1
VER=$2
LIBDIR=$3
cd ${PKG}-${VER}
./configure --prefix=/usr \
--localstatedir=/var \
--sysconfdir=/etc \
--libdir=/usr/${LIBDIR}
[ "$?" -eq 0 ] || exit
make $MKFLG
[ "$?" -eq 0 ] || exit
make DESTDIR=$CWD/${PKG}-install install
cd -
}
package_std() {
PKG=$1
VER=$2
ARCH=$3
DESKTOP=$4
DESC="$5"
DEPS=$6
CAT=$7
[ "$DEPS" = 'not' ] && DEPS=''
[ "$DESKTOP" = 'not' ] && DESKTOP=''
# strip
find ${PKG}-install | xargs file | grep -e "executable" -e "shared object" \
| grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
# add this recipe
install -d -m 0755 ./${PKG}-install/usr/src/dev
cat ${PKG}.petbuild > ./${PKG}-install/usr/src/dev/${PKG}-build-recipe
# add custom .desktop
if [ -f "$DESKTOP" ];then
install -d -m 0755 ./${PKG}-install/usr/share/applications
cat $DESKTOP > ./${PKG}-install/usr/share/applications/$DESKTOP
fi
# split
get_files ${PKG}-install ${PKG}-${VER}-${ARCH}_${BUILD}
(cd ${PKG}-${VER}; $MWD/split.sh ../${PKG}-install $BUILD)
# delete any icon cache or library cache
find ./${PKG}-${VER}-${ARCH}_${BUILD} -type f -name '*cache' -delete
# add pinstalls if exists
[ -f ./pinstall.sh ] && install -m 0755 pinstall.sh ./${PKG}-${VER}-${ARCH}_${BUILD}/
[ -f ./puninstall.sh ] && install -m 0755 puninstall.sh ./${PKG}-${VER}-${ARCH}_${BUILD}/
for p in $(ls|grep "\-${ARCH}"|grep -v "files$") ; do
case $p in
*_DEV*) DESC="$PKG development"; DEPS=+${PKG} ;;
*_DOC*) DESC="$PKG documentation"; DEPS=+${PKG} ;;
*_NLS*) DESC="$PKG locales"; DEPS=+${PKG} ;;
esac
echo "packaging $p"
dir2pet -x -s -w="$DESC" -d="$DEPS" -c="$CAT" -p=${p} 2>&1 >/dev/null
rm -r $p
mv ${p}.pet ../0pets_out/
done
rm -r ${PKG}-install
rm -r ${PKG}-${VER}
mv -f *.files ../0logs/
echo "done!"
}