Repository navigation
Expand file tree
/
Copy pathmkpkg
More file actions
executable file
·81 lines (71 loc) · 1.98 KB
/
Copy pathmkpkg
File metadata and controls
executable file
·81 lines (71 loc) · 1.98 KB
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
#!/bin/sh
# Copyright (c) Nate Wiger http://nateware.com
# mkpkg - trivial packager for CGI::FormBuilder
cd `dirname $0`/..
[ $DEBUG ] && set -x
pwd=$PWD
mod=CGI::FormBuilder
pkg=CGI-FormBuilder
pod=pod
inc="Makefile.PL lib pod t"
doc="README Changes MANIFEST INSTALL"
export STRICT_FB_TESTS=1
perl=${PERL:-/usr/bin/perl}
ver=${1:-`$perl -I"$PWD/lib" -M$mod -e 'print $'$mod::VERSION`} || exit $?
echo "This will build a CPAN pkg for $mod v$ver"
echo "Continue (y/n) [y]? \c"
read ans
[ ${ans:-y} = y ] || exit 99
# Create a temp dir that we can tgz into CPAN pkg name
tmpdir=`mktemp -d /tmp/mkpkg.XXXXXX`
tmppkg=$tmpdir/$pkg-$ver
mkdir -p $tmppkg || exit 2
# use h to expand symlinks, since Perl won't install them
export COPY_EXTENDED_ATTRIBUTES_DISABLE=true # fucking Mac
export COPYFILE_DISABLE=true
cp -rp $inc $tmppkg
pushd $tmppkg || exit 3
# create doc files from pods
pod2text $pod/README.pod >README
pod2text $pod/INSTALL.pod >INSTALL
pod2text $pod/Changes.pod >Changes
# Generate MANIFEST
touch MANIFEST # need MANIFEST in MANIFEST
find $inc $doc Makefile.PL -type f -print | sort >MANIFEST
cd ..
tar cvhf $pkg-$ver.tar $pkg-$ver || exit 4
gzip $pkg-$ver.tar || exit 5
mv $pkg-$ver.tar.gz $pkg-$ver.tgz || exit 6
[ -d $pwd/pkgs ] || mkdir -p $pwd/pkgs
mv $pkg-$ver.tgz $pwd/pkgs
popd
rm -rf $tmpdir
pfile="$pwd/pkgs/$pkg-$ver.tgz"
# Now, test it before saying ok
printf "\033[35m"
echo
echo "+----------------------------------------+"
echo "| Testing new package to see if it works |"
echo "+----------------------------------------+"
echo
printf "\033[m"
sleep 1
testdir=`mktemp -d /tmp/mkpkg.XXXXXX`
pushd $testdir
tar zxf $pfile
cd `basename $pfile .tgz`
$perl Makefile.PL || fail=1
[ "$fail" ] || make test
if [ "$fail" ] || [ $# -ne 0 ]; then
printf "\033[31m"
echo "Package FAILED one or more tests"
echo "See test dir: $testdir"
printf "\033[m"
else
printf "\033[32m"
echo "Packaging successful!"
printf "\033[m"
popd
rm -rf $testdir
fi
echo " $pfile"