blob: e748bdfd850d496ee6ddcf93131c8a9e85a201cd (
plain) (
blame)
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
|
#!/bin/sh
msg () {
echo "$@" 1>&2
}
get_origin () {
grep "^$1" "${index}" | (
IFS="${IFS}|"
while read pkgnamever fullpath trash; do
pkgname="${pkgnamever%-*}"
if [ "${pkgname}" = "$1" ]; then
this_origin="${fullpath#${PORTSDIR}}"
this_origin="${this_origin#/}"
echo "${this_origin}"
break
fi
done
)
}
[ -z "$1" ] && msg "Usage: $0 list_file" && exit 1
: ${FREEBSD_VERSION:="`uname -r | sed 's|^\([0-9]*\).*$|\1|'`"}
: ${PORTSDIR:="/usr/ports"}
index="${PORTSDIR}/INDEX-${FREEBSD_VERSION}"
msg "==> FreeBSD version is ${FREEBSD_VERSION}"
msg "==> FreeBSD ports tree is ${PORTSDIR}"
msg "==> FreeBSD ports index file is ${index}"
exec 3< "$1" # list file
echo "// vim: ft=c: et"
echo ""
echo "// ====================================================================="
echo "// This file maps FreeBSD packages to their ports directories"
echo "// ====================================================================="
echo ""
while read pkgname 0<&3; do
msg "=> Processing package ${pkgname}"
origin="`get_origin ${pkgname}`"
[ -z "${origin}" ] && \
msg "==> Cannot find origin for ${pkgname} in your index file" && \
msg "==> Exit now!" && exit 1
msg "=> Processing package ${pkgname} - ${origin}"
printf "#define %-32s %s\n" "${pkgname}" "${origin}"
done
exec 3<&-
msg "==> Done!"
|