Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-ports
Path: blob/main/Tools/scripts/chkorigin.sh
18157 views
1
#!/bin/sh -e
2
#
3
# Copyright (c) 2003-2004 Oliver Eikemeier. All rights reserved.
4
#
5
# Redistribution and use in source and binary forms, with or without
6
# modification, are permitted provided that the following conditions are
7
# met:
8
#
9
# 1. Redistributions of source code must retain the above copyright notice
10
# this list of conditions and the following disclaimer.
11
#
12
# 2. Redistributions in binary form must reproduce the above copyright
13
# notice, this list of conditions and the following disclaimer in the
14
# documentation and/or other materials provided with the distribution.
15
#
16
# 3. Neither the name of the author nor the names of its contributors may be
17
# used to endorse or promote products derived from this software without
18
# specific prior written permission.
19
#
20
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
#
31
# MAINTAINER= [email protected]
32
#
33
# PKGORIGIN connects packaged or installed ports to the directory they
34
# originally came from. Although often overlooked, they are extremly
35
# important for tools like pkg_version or portupgrade to work correctly.
36
# Wrong PKGORIGINs are usually caused by a wrong order of CATEGORIES
37
# after a repocopy.
38
#
39
# This tool checks all ports in the ports tree (even those not connected
40
# to the build) for a wrong PKGORIGIN. Run this tool periodically and
41
# after every repocopy and correct errors immediately.
42
#
43
# Usage:
44
# [env PORTSDIR=/usr/ports] chkorigin.sh [category ...]
45
#
46
47
opt_verbose=false
48
opt_quiet=false
49
50
while getopts vq opt; do
51
case "$opt" in
52
q)
53
opt_quiet=true;;
54
v)
55
opt_verbose=true;;
56
?)
57
echo "Usage: $0 [-qv] [category ...]"
58
exit 2;;
59
esac
60
done
61
62
shift $((${OPTIND}-1))
63
64
rc=0
65
66
$opt_quiet || echo "checking categories for ports with a wrong PKGORIGIN"
67
68
cd "${PORTSDIR:=/usr/ports}"
69
if [ $# -gt 0 ]; then
70
CATEGORIES=`echo $@`
71
else
72
CATEGORIES=`echo [a-z]*`
73
fi
74
75
for category in ${CATEGORIES}; do
76
if [ ! -d "${PORTSDIR}/${category}" ]; then continue; fi
77
case "${category}" in
78
CVS) continue ;;
79
Mk) continue ;;
80
Templates) continue ;;
81
Tools) continue ;;
82
distfiles) continue ;;
83
packages) continue ;;
84
esac
85
86
$opt_quiet || echo "==> ${category}"
87
88
cd "${PORTSDIR}/${category}"
89
PORTS=`echo *`
90
91
for port in ${PORTS}; do
92
if [ ! -d "${PORTSDIR}/${category}/${port}" ]; then continue; fi
93
case "${port}" in
94
CVS) continue ;;
95
pkg) continue ;;
96
esac
97
98
$opt_verbose && echo "==> ${category}/${port}"
99
100
cd "${PORTSDIR}/${category}/${port}"
101
PKGORIGIN=`/usr/bin/make -VPKGORIGIN 2>/dev/null || true`
102
103
if [ "${PKGORIGIN}" != "${category}/${port}" ]; then
104
echo "port \"${category}/${port}\" has the wrong PKGORIGIN \"${PKGORIGIN}\""
105
rc=1
106
fi
107
done
108
done
109
110
return ${rc}
111
112