-
Notifications
You must be signed in to change notification settings - Fork 2
/
mkpkg
executable file
·110 lines (92 loc) · 2.59 KB
/
mkpkg
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
#!/bin/sh
##
## Creates a Slackware package
## Copyright (c) 2005-2007 by Michal Nazarewicz (mina86/AT/mina86.com)
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, see <http://www.gnu.org/licenses/>.
##
## This is part of Tiny Applications Collection
## -> http://tinyapps.sourceforge.net/
##
set -e
##
## Strip executables
##
echo Stripping executables
find . -type f -exec file -- {} + | \
sed -ne '/ELF.*executable/ s/:.*//p
/ELF.*shared object/ s/:.*//p' |
xargs --no-run-if-empty strip --strip-unneeded 2>/dev/null
##
## Search for *.new files and add them do doinst.sh
##
echo Searching for \*.new files
find . -type f -name '*.new' | sed -e "s/'/'\\''/g" \
-e "s/^\\(.*\\)\\.new$/cfg '\\1'/" >mkpkg-new
if [ -s mkpkg-new ]; then
echo Adding \*.new files to doinst.sh
mkdir -p install
cat - mkpkg-new <<EOF >>install/doinst.sh
NEW_CONFIG=
cfg () {
if ! [ -r "\$1" ]; then
mv -- "\$1.new" "\$1"
NEW_CONFIG=yes
elif ! cmp "\$1" "\$1.new" >/dev/null 2>&1; then
rm -- "\$1.new"
else
NEW_CONFIG=yes
fi
}
EOF
echo '[ -z "\$NEW_CONFIG" ] || echo "New configuration file(s) present"' \
>>install/doinst.sh
chmod 755 install/doinst.sh
fi
rm -f mkpkg-new
##
## Gzip man pages
##
echo Gzipping man pages
find . -path '*/man?/*' \( -name '*.?' -o -name '*.??' \) \
\! -name '*.Z' \! -name '*.gz' \! -name '*.bz2' \
-exec gzip -9 -- {} +
##
## Description
##
if ! [ -s install/slack-desc ]; then
echo 'Enter package name (single line):'
IFS= read TITLE
echo 'Enter description (^D to finish; max 9 lines)'
echo '----------------------------------------------------------------------|'
{ echo "$TITLE"; echo; cat; } | cat -s >mkpkg-desc
LINES=$(wc -l <mkpkg-desc)
while [ $LINES -lt 11 ]; do
echo >>mkpkg-desc
LINES=$(($LINES + 1))
done
if [ $LINES -gt 11 ]; then
echo warning: Description has more then 11 lines
fi
PKG="${PWD##*/}"; PKG="${PKG%-*-*-*}"
mkdir -p install
while IFS= read LINE; do
printf '%s: %s\n' "$PKG" "$LINE"
done <mkpkg-desc >install/slack-desc
rm -f mkpkg-desc
fi
##
## Make package
##
makepkg "$@" "$PWD.txz"