Blame
Date:
Sun Aug 3 20:18:56 2014 UTC
Message:
fix
001
2014-05-30
alienus
#!/bin/bash
002
2014-05-30
alienus
#
003
2014-06-23
alienus
#
004
2014-05-30
alienus
# pkgdir
005
2014-05-30
alienus
#
006
2014-05-30
alienus
# The MIT License (MIT)
007
2014-05-30
alienus
#
008
2014-05-30
alienus
# Copyright (c) 2014 Fred. Galusik <alienus at nutyx dot org>
009
2014-05-30
alienus
#
010
2014-05-30
alienus
# Permission is hereby granted, free of charge, to any person obtaining a copy
011
2014-05-30
alienus
# of this software and associated documentation files (the "Software"), to deal
012
2014-05-30
alienus
# in the Software without restriction, including without limitation the rights
013
2014-05-30
alienus
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
014
2014-05-30
alienus
# copies of the Software, and to permit persons to whom the Software is
015
2014-05-30
alienus
# furnished to do so, subject to the following conditions:
016
2014-05-30
alienus
#
017
2014-05-30
alienus
# The above copyright notice and this permission notice shall be included in
018
2014-05-30
alienus
# all copies or substantial portions of the Software.
019
2014-05-30
alienus
#
020
2014-05-30
alienus
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
021
2014-05-30
alienus
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
022
2014-05-30
alienus
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
023
2014-05-30
alienus
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
024
2014-05-30
alienus
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
025
2014-05-30
alienus
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
026
2014-05-30
alienus
# THE SOFTWARE.
027
2014-05-30
alienus
028
2014-06-23
alienus
PKGDIR_VERSION=0.2.2
029
2014-05-30
alienus
030
2014-05-30
alienus
#
031
2014-05-30
alienus
# ex: pkgdir -p plop@0.1
032
2014-05-30
alienus
# make a plop@0.1 dir with a Pkgfile perl template and a info template
033
2014-05-30
alienus
#
034
2014-05-30
alienus
print_help()
035
2014-05-30
alienus
{
036
2014-05-30
alienus
echo "Usage: pkgdir [options] Dir"
037
2014-05-30
alienus
echo "Options:"
038
2014-05-30
alienus
echo " -d, --default Install default Pkgfile & info in Dir"
039
2014-06-23
alienus
echo " -k, --kde Install kde Pkgfile & info in Dir"
040
2014-05-30
alienus
echo " -p, --perl Install perl Pkgfile & info in Dir"
041
2014-05-30
alienus
echo " -py, --python Install python Pkgfile & info in Dir"
042
2014-05-30
alienus
echo " -w, --waf Install waf Pkgfile & info in Dir"
043
2014-05-30
alienus
echo " -v, --version Print pkgdir version and exit"
044
2014-05-30
alienus
echo " -h, --help Print this help and exit"
045
2014-05-30
alienus
exit 0
046
2014-05-30
alienus
}
047
2014-05-30
alienus
048
2014-05-30
alienus
die()
049
2014-05-30
alienus
{
050
2014-05-30
alienus
echo "$@"
051
2014-05-30
alienus
exit 1
052
2014-05-30
alienus
}
053
2014-05-30
alienus
054
2014-05-30
alienus
# check dir name scheme : name@version and make it
055
2014-05-30
alienus
check_dir()
056
2014-05-30
alienus
{
057
2014-05-30
alienus
IFS="@"
058
2014-05-30
alienus
set -- $DIR
059
2014-05-30
alienus
if [ "${#@}" -ne 2 ]; then
060
2014-05-30
alienus
die "Please, write dir name like that: name@version, aborting..."
061
2014-05-30
alienus
fi
062
2014-05-30
alienus
PKGNAME="$1"
063
2014-05-30
alienus
PKGVERSION="$2"
064
2014-05-30
alienus
065
2014-05-30
alienus
# mkdir
066
2014-05-30
alienus
PORT="${PKGNAME}@${PKGVERSION}"
067
2014-05-30
alienus
mkdir -p $PKGNAME\@$PKGVERSION
068
2014-05-30
alienus
echo "$PORT created"
069
2014-05-30
alienus
}
070
2014-05-30
alienus
071
2014-05-30
alienus
# basic default template
072
2014-05-30
alienus
pkg_default()
073
2014-05-30
alienus
{
074
2014-05-30
alienus
cat > $PKGNAME\@$PKGVERSION/Pkgfile << EOF
075
2014-05-30
alienus
source=()
076
2014-05-30
alienus
077
2014-05-30
alienus
build(){
078
2014-05-30
alienus
cd \$name-\$version
079
2014-06-07
alienus
./configure --prefix=/usr
080
2014-05-30
alienus
make
081
2014-06-23
alienus
make DESTDIR=\$PKG install
082
2014-05-30
alienus
}
083
2014-05-30
alienus
084
2014-05-30
alienus
085
2014-05-30
alienus
086
2014-05-30
alienus
# NuTyX Pkgfile (http://nutyx.org)
087
2014-05-30
alienus
EOF
088
2014-05-30
alienus
echo "$PORT/Pkgfile default created"
089
2014-05-30
alienus
}
090
2014-05-30
alienus
091
2014-05-30
alienus
# python template
092
2014-05-30
alienus
pkg_python()
093
2014-05-30
alienus
{
094
2014-05-30
alienus
cat > $PKGNAME\@$PKGVERSION/Pkgfile << EOF
095
2014-05-30
alienus
source=()
096
2014-05-30
alienus
097
2014-05-30
alienus
build() {
098
2014-05-30
alienus
cd \$name-\$version
099
2014-05-30
alienus
python2 setup.py install --prefix=/usr --root=\$PKG
100
2014-05-30
alienus
}
101
2014-05-30
alienus
102
2014-05-30
alienus
103
2014-05-30
alienus
104
2014-05-30
alienus
# NuTyX Pkgfile (http://nutyx.org)
105
2014-05-30
alienus
EOF
106
2014-05-30
alienus
107
2014-05-30
alienus
echo "$PORT/Pkgfile python created"
108
2014-05-30
alienus
}
109
2014-05-30
alienus
110
2014-05-30
alienus
# perl template
111
2014-05-30
alienus
pkg_perl()
112
2014-05-30
alienus
{
113
2014-05-30
alienus
cat > $PKGNAME\@$PKGVERSION/Pkgfile << EOF
114
2014-05-30
alienus
source=()
115
2014-05-30
alienus
116
2014-05-30
alienus
build() {
117
2014-05-30
alienus
cd \$name-\$version
118
2014-05-30
alienus
perl Makefile.PL
119
2014-05-30
alienus
make OPTIMIZE="\$CFLAGS" || exit 1
120
2014-05-30
alienus
make install INSTALLDIRS=vendor DESTDIR=\$PKG || exit 1
121
2014-05-30
alienus
122
2014-05-30
alienus
# Remove perllocal.pod and .packlist if present in the package
123
2014-05-30
alienus
for i in perllocal.pod .packlist; do
124
2014-05-30
alienus
find \$PKG -name "\$i" -exec rm -rf {} \;
125
2014-05-30
alienus
done
126
2014-05-30
alienus
}
127
2014-05-30
alienus
128
2014-05-30
alienus
129
2014-05-30
alienus
130
2014-05-30
alienus
# NuTyX Pkgfile (http://nutyx.org)
131
2014-05-30
alienus
EOF
132
2014-05-30
alienus
133
2014-05-30
alienus
echo "$PORT/Pkgfile perl created"
134
2014-05-30
alienus
}
135
2014-05-30
alienus
136
2014-05-30
alienus
# waf template
137
2014-05-30
alienus
pkg_waf()
138
2014-05-30
alienus
{
139
2014-05-30
alienus
cat > $PKGNAME\@$PKGVERSION/Pkgfile << EOF
140
2014-05-30
alienus
source=()
141
2014-05-30
alienus
142
2014-05-30
alienus
build() {
143
2014-05-30
alienus
cd \$name-\$version
144
2014-05-30
alienus
./waf configure --prefix=/usr
145
2014-05-30
alienus
./waf build
146
2014-05-30
alienus
./waf install --destdir=\$PKG
147
2014-05-30
alienus
}
148
2014-05-30
alienus
149
2014-05-30
alienus
150
2014-05-30
alienus
151
2014-05-30
alienus
# NuTyX Pkgfile (http://nutyx.org)
152
2014-05-30
alienus
EOF
153
2014-05-30
alienus
echo "$PORT/Pkgfile waf created"
154
2014-05-30
alienus
}
155
2014-05-30
alienus
156
2014-05-30
alienus
# kde template
157
2014-06-23
alienus
pkg_kde()
158
2014-05-30
alienus
{
159
2014-05-30
alienus
cat > $PKGNAME\@$PKGVERSION/Pkgfile << EOF
160
2014-05-30
alienus
source=()
161
2014-05-30
alienus
162
2014-05-30
alienus
build() {
163
2014-05-30
alienus
cd \${_name}-\$version
164
2014-05-30
alienus
mkdir build
165
2014-05-30
alienus
cd build
166
2014-05-30
alienus
cmake -DCMAKE_INSTALL_PREFIX=\$KDE_PREFIX \
167
2014-05-30
alienus
-DCMAKE_BUILD_TYPE=Release \
168
2014-05-30
alienus
-Wno-dev .. \
169
2014-05-30
alienus
make
170
2014-05-30
alienus
make DESTDIR=\$PKG install
171
2014-05-30
alienus
}
172
2014-05-30
alienus
173
2014-05-30
alienus
174
2014-05-30
alienus
175
2014-05-30
alienus
# NuTyX Pkgfile (http://nutyx.org)
176
2014-05-30
alienus
EOF
177
2014-05-30
alienus
178
2014-05-30
alienus
echo "$PORT/Pkgfile kde created"
179
2014-05-30
alienus
}
180
2014-05-30
alienus
181
2014-05-30
alienus
#
182
2014-05-30
alienus
# info template
183
2014-05-30
alienus
#
184
2014-05-30
alienus
pkg_info()
185
2014-05-30
alienus
{
186
2014-05-30
alienus
cat > $PKGNAME\@$PKGVERSION/$PKGNAME.info << EOF
187
2014-05-30
alienus
blabla
188
2014-05-30
alienus
189
2014-06-23
alienus
URL:
190
2014-05-30
alienus
191
2014-05-30
alienus
Packager:
192
2014-05-30
alienus
193
2014-05-30
alienus
x at nutyx dot org
194
2014-05-30
alienus
195
2014-05-30
alienus
196
2014-05-30
alienus
197
2014-05-30
alienus
# NuTyX package info file (http://nutyx.org)
198
2014-05-30
alienus
EOF
199
2014-05-30
alienus
200
2014-05-30
alienus
echo "$PORT/$PKGNAME.info created"
201
2014-05-30
alienus
}
202
2014-05-30
alienus
203
2014-05-30
alienus
#
204
2014-05-30
alienus
# parse the packager options
205
2014-05-30
alienus
#
206
2014-05-30
alienus
parse_options()
207
2014-05-30
alienus
{
208
2014-05-30
alienus
if [ $# -ge 1 ]; then
209
2014-05-30
alienus
case $1 in
210
2014-05-30
alienus
-d|--default)
211
2014-05-30
alienus
DIR=$2
212
2014-05-30
alienus
DEFAULT=YES ;;
213
2014-05-30
alienus
-k|--kde)
214
2014-05-30
alienus
DIR=$2
215
2014-05-30
alienus
KDE=YES ;;
216
2014-05-30
alienus
-p|--perl)
217
2014-05-30
alienus
DIR=$2
218
2014-05-30
alienus
PERL=YES ;;
219
2014-05-30
alienus
-py|--python)
220
2014-05-30
alienus
DIR=$2
221
2014-05-30
alienus
PYTHON=YES ;;
222
2014-05-30
alienus
-w|--waf)
223
2014-05-30
alienus
DIR=$2
224
2014-05-30
alienus
WAF=YES ;;
225
2014-05-30
alienus
-v|--version)
226
2014-05-30
alienus
VERSION=YES ;;
227
2014-05-30
alienus
-h|--help)
228
2014-05-30
alienus
HELP=YES ;;
229
2014-05-30
alienus
*)
230
2014-05-30
alienus
die "Invalid option, see pkgdir --help, aborting!" ;;
231
2014-05-30
alienus
esac
232
2014-05-30
alienus
else
233
2014-05-30
alienus
die "Invalid option, see pkgdir --help, aborting!"
234
2014-05-30
alienus
fi
235
2014-05-30
alienus
}
236
2014-05-30
alienus
237
2014-05-30
alienus
#
238
2014-05-30
alienus
# main function
239
2014-05-30
alienus
#
240
2014-05-30
alienus
main()
241
2014-05-30
alienus
{
242
2014-05-30
alienus
parse_options "$@"
243
2014-05-30
alienus
244
2014-05-30
alienus
if [ $DEFAULT ]; then
245
2014-05-30
alienus
check_dir
246
2014-05-30
alienus
pkg_default
247
2014-05-30
alienus
pkg_info
248
2014-05-30
alienus
elif [ $KDE ]; then
249
2014-05-30
alienus
check_dir
250
2014-05-30
alienus
pkg_kde
251
2014-05-30
alienus
pkg_info
252
2014-05-30
alienus
elif [ $PERL ]; then
253
2014-05-30
alienus
check_dir
254
2014-05-30
alienus
pkg_perl
255
2014-05-30
alienus
pkg_info
256
2014-05-30
alienus
elif [ $PYTHON ]; then
257
2014-05-30
alienus
check_dir
258
2014-05-30
alienus
pkg_python
259
2014-05-30
alienus
pkg_info
260
2014-05-30
alienus
elif [ $WAF ]; then
261
2014-05-30
alienus
check_dir
262
2014-05-30
alienus
pkg_waf
263
2014-05-30
alienus
pkg_info
264
2014-05-30
alienus
elif [ $VERSION ]; then
265
2014-05-30
alienus
die "pkgdir $PKGDIR_VERSION"
266
2014-05-30
alienus
elif [ $HELP ]; then
267
2014-05-30
alienus
print_help
268
2014-05-30
alienus
else
269
2014-05-30
alienus
die "Wrong option, see pkgdir --help !"
270
2014-06-23
alienus
fi
271
2014-05-30
alienus
}
272
2014-05-30
alienus
273
2014-05-30
alienus
main "$@"
274
2014-05-30
alienus
Frédéric Galusik