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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
#! /bin/sh
# $NetBSD: gimme.sh,v 1.1.1.1 2015/11/22 21:57:38 agc Exp $
# Copyright (c) 2015 Alistair Crooks <agc@NetBSD.org>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# small script to be used to provide binary packages
# args:
# -c use current host to provide base operating system
# -d use the sets in this dir as base operating system
# -v be verbose in operation
current=false
distribdir=''
while [ $# -gt 0 ]; do
case "$1" in
-c) current=true ;;
-d) distribdir="$2"; shift ;;
-v) set -x ;;
*) break ;;
esac
shift
done
# check whether sudo is needed
case "$(id -u)" in
0) sudo="" ;;
*) sudo=sudo ;;
esac
# function to clean up stuff
cleanup() {
case "${conf}" in
"") ;;
*) if [ -f /root/pkg_comp/${conf} ]; then
${sudo} rm -f /root/pkg_comp/${conf}
fi
;;
esac
if ${current}; then
case "${distribdir}" in
"") ;;
*) if [ -d ${distribdir} ]; then
${sudo} rm -rf ${distribdir}
fi
;;
esac
fi
}
trap cleanup 9 15
pkgsdir=/usr/pkgsrc/packages/All
conf=gimme.$$
# don't need the chatty message about editing by hand
${sudo} pkg_comp -c ${conf} maketemplate >/dev/null
base_files='
./altroot
./bin
./lib
./libdata
./libexec
./rescue
./sbin
./usr/bin
./usr/lib
./usr/libdata
./usr/libexec
./usr/mdec
./usr/sbin
./var/chroot
./var/db
./var/games
./var/heimdal
./var/log/rdist
./var/mail
./var/msgs
./var/preserve
./var/quotas
./var/run
./var/rwho
./var/shm
./var/spool
./var/tmp/vi.recover
./var/tpm
./var/www
./var/yp/binding
'
etc_files='
.cshrc
.profile
boot.cfg
./dev/MAKEDEV
./dev/MAKEDEV.local
./etc
./var/at/at.deny
./var/crash/minfree
./var/cron/tabs/root
./var/games
./var/log
./var/msgs
./var/run/utmp
./var/run/utmpx
./var/yp/Makefile.yp
./var/yp/nicknames
'
# current means to use current os as basis for compilation
if ${current}; then
echo "creating temporary set files for operating system"
distribdir=$(${sudo} mktemp -d /tmp/gimmesets.XXXXXX)
${sudo} mkdir -p ${distribdir}/binary/sets
tmptmpdir=$(${sudo} mktemp -d /tmp/tmptmp.XXXXXX)
${sudo} chmod 1777 ${tmptmpdir}
vartmptmpdir=$(${sudo} mktemp -d /tmp/tmptmp.XXXXXX)
${sudo} chmod 1777 ${vartmptmpdir}
(cd / && ${sudo} tar -czf ${distribdir}/binary/sets/base.tgz -s '|'./${tmptmpdir}'|./tmp|' -s '|'./${vartmptmpdir}'|./var/tmp|' ${base_files} ./${tmptmpdir} ./${vartmptmpdir})
(cd / && ${sudo} tar -czf ${distribdir}/binary/sets/comp.tgz ./usr/include)
(cd / && ${sudo} tar -czf ${distribdir}/binary/sets/etc.tgz ${etc_files})
(cd / && ${sudo} tar -czf ${distribdir}/binary/sets/kern-GENERIC.tgz ./netbsd)
(cd / && ${sudo} tar -czf ${distribdir}/binary/sets/text.tgz ./usr/share)
(cd / && ${sudo} tar -czf ${distribdir}/binary/sets/xbase.tgz ./usr/X11R7/bin ./usr/X11R7/lib ./usr/X11R7/man ./usr/libdata/debug/usr/X11R7)
(cd / && ${sudo} tar -czf ${distribdir}/binary/sets/xcomp.tgz ./usr/X11R7/include)
(cd / && ${sudo} tar -czf ${distribdir}/binary/sets/xetc.tgz ./etc/X11 ./etc/fonts ./etc/rc.d/fccache ./etc/rc.d/xdm ./etc/rc.d/xfs)
(cd / && ${sudo} tar -czf ${distribdir}/binary/sets/xfont.tgz ./usr/X11R7/lib/X11/fonts)
(cd / && ${sudo} tar -czf ${distribdir}/binary/sets/xserver.tgz ./usr/X11R7/bin/X ./usr/X11R7/bin/Xnest ./usr/X11R7/bin/Xorg ./usr/X11R7/bin/Xvfb ./usr/X11R7/share)
${sudo} rm -rf ${tmptmpdir} ${vartmptmpdir}
fi
# set where the binary sets are
case "${distribdir}" in
"") ;;
*)
tmp=$(mktemp /tmp/gimme.XXXXXX)
sed -e 's|^DISTRIBDIR=.*|DISTRIBDIR='${distribdir}'|' /root/pkg_comp/${conf}.conf > ${tmp} &&
${sudo} mv ${tmp} /root/pkg_comp/${conf}.conf
;;
esac
# sanity check for distribdir
if [ ! -f ${distribdir}/binary/sets/etc.tgz ]; then
t1=${distribdir##/binary/sets}
if [ -f ${t1}/etc.tgz ]; then
echo "Info: no need to specify "/binary/sets" on end of distribdir"
distribdir=${t1}
else
echo "can't find binary sets in ${distribdir}" >&2
cleanup
exit 1
fi
fi
# use pkg_comp to make the packages
${sudo} pkg_comp -c ${conf} makeroot
for p in $@; do
${sudo} pkg_comp -c ${conf} build ${p}
ls -al ${pkgsdir}/${p}*
done
${sudo} pkg_comp -c ${conf} removeroot
cleanup
|