This repository has been archived by the owner on Aug 1, 2022. It is now read-only.
forked from dcantrell/bsdutils
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathimport-src.sh
executable file
·183 lines (164 loc) · 4.44 KB
/
import-src.sh
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
#!/bin/sh
#
# import-src.sh - Import specific release of FreeBSD source in to
# this tree. Primarily for maintenance use when
# a new version of FreeBSD comes out.
#
# Author: David Cantrell <[email protected]>
#
PATH=/bin:/usr/bin
CWD="$(pwd)"
TMPDIR="$(mktemp -d --tmpdir=${CWD})"
. ${CWD}/upstream.conf
fail_exit() {
cd ${CWD}
rm -rf ${TMPDIR}
exit 1
}
for sub in src ; do
[ -d ${CWD}/${sub} ] || mkdir -p ${CWD}/${sub}
done
cd ${TMPDIR}
curl -L --retry 3 --ftp-pasv -O ${SRC} || fail_exit
xz -dc src.txz | tar -xf -
# XXX: commands
#usr.bin/arch
#usr.bin/readlink (part of stat)
# copy in the source for all coreutils programs
CMDS="bin/test
usr.bin/basename
usr.bin/bc
bin/cat
bin/chmod
usr.sbin/chown
usr.bin/cksum
usr.bin/comm
bin/cp
usr.bin/csplit
usr.bin/cut
bin/date
usr.bin/dc
bin/dd
bin/df
usr.bin/dirname
usr.bin/du
bin/echo
usr.bin/env
usr.bin/expand
bin/expr
usr.bin/factor
usr.bin/false
usr.bin/find
usr.bin/fmt
usr.bin/fold
usr.bin/head
usr.bin/hexdump
bin/hostname
usr.bin/id
usr.bin/join
bin/ln
usr.bin/logname
bin/ls
bin/mkdir
sbin/mknod
usr.bin/mktemp
usr.bin/mkfifo
bin/mv
usr.bin/nice
usr.bin/nl
usr.bin/nohup
usr.bin/paste
usr.bin/pr
usr.bin/printenv
usr.bin/printf
bin/pwd
bin/realpath
bin/rm
bin/rmdir
usr.bin/seq
bin/sleep
usr.bin/sort
usr.bin/split
usr.bin/stat
usr.bin/stdbuf
bin/stty
bin/sync
usr.bin/tail
usr.bin/tee
usr.bin/timeout
usr.bin/touch
usr.bin/tr
usr.bin/true
usr.bin/truncate
usr.bin/tsort
usr.bin/tty
usr.bin/uname
usr.bin/unexpand
usr.bin/uniq
usr.bin/users
usr.bin/wc
usr.bin/which
usr.bin/who
usr.bin/yes
usr.sbin/chroot
usr.bin/xargs
usr.bin/xinstall"
for p in ${CMDS} ; do
rp="usr/src/${p}"
sp="$(basename ${p})"
# Drop the tests/ subdirectories
[ -d ${rp}/tests ] && rm -rf ${rp}/tests
# Rename the upstream Makefile for later manual checking. We don't
# commit these to our tree, but just look at them when rebasing and
# pick up any rule changes to put in our Makefile.am files.
if [ -f "${rp}/Makefile" ]; then
mv ${rp}/Makefile ${rp}/Makefile.bsd
fi
# Drop the Makefile.depend* files
rm -f ${rp}/Makefile.depend*
# Copy in the upstream files
[ -d ${CWD}/src/${sp} ] || mkdir -p ${CWD}/src/${sp}
cp -pr ${rp}/* ${CWD}/src/${sp}
done
# 'compat' is our static library with a subset of BSD library functions
cp -p usr/src/lib/libc/gen/setmode.c ${CWD}/compat
cp -p usr/src/lib/libc/string/strmode.c ${CWD}/compat
cp -p usr/src/lib/libc/gen/getbsize.c ${CWD}/compat
cp -p usr/src/lib/libutil/humanize_number.c ${CWD}/compat
cp -p usr/src/lib/libutil/expand_number.c ${CWD}/compat
cp -p usr/src/lib/libc/stdlib/merge.c ${CWD}/compat
cp -p usr/src/lib/libc/stdlib/heapsort.c ${CWD}/compat
cp -p usr/src/contrib/libc-vis/vis.c ${CWD}/compat
cp -p usr/src/contrib/libc-vis/vis.h ${CWD}/include
# These files are needed for the factor command
cp -p usr/src/usr.bin/primes/primes.h ${CWD}/src/factor
cp -p usr/src/usr.bin/primes/pr_tbl.c ${CWD}/src/factor
# These files are needed for the df command
cp -p usr/sbin/sbin/mount/vfslist.c ${CWD}/src/df
# These are not used
rm -rf ${CWD}/src/sort/nls
# sort manpage
mv ${CWD}/src/sort/sort.1.in ${CWD}/src/sort/sort.1
#####################
# APPLY ANY PATCHES #
#####################
if [ -d ${CWD}/patches/compat ]; then
for patchfile in ${CWD}/patches/compat/*.patch ; do
destfile="$(basename ${patchfile} .patch)"
[ -f "${CWD}/compat/${destfile}.orig" ] && rm -f "${CWD}/compat/${destfile}.orig"
patch -d ${CWD} -p0 -b -z .orig < ${patchfile}
done
fi
if [ -d ${CWD}/patches/src ]; then
cd ${CWD}/patches/src
for subdir in * ; do
[ -d ${subdir} ] || continue
for patchfile in ${CWD}/patches/src/${subdir}/*.patch ; do
destfile="$(basename ${patchfile} .patch)"
[ -f "${CWD}/src/${subdir}/${destfile}.orig" ] && rm -f "${CWD}/src/${subdir}/${destfile}.orig"
patch -d ${CWD}/src -p0 -b -z .orig < ${patchfile}
done
done
fi
# Clean up
rm -rf ${TMPDIR}