1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-10-18 19:49:40 +00:00

- Remove a few more scripts from Tools/scripts:

chkdepschain.py: doesn't support pkgng
explicit_lib_depends.sh: doesn't support pkgng
plist: obsolete; searches for /etc/mtree/BSD.local.dist, add @dirrm, doesn't know about man pages in the plist
release: unused and obsolete
resolveportsfromlibs.sh: doesn't support pkgng

Approved by:	portmgr (bapt)
This commit is contained in:
Alex Kozlov 2015-04-10 07:05:45 +00:00
parent 4fa4d8f767
commit c9575fbfdc
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=383695
12 changed files with 0 additions and 1572 deletions

View File

@ -1,320 +0,0 @@
#!/usr/bin/env python
#
# ----------------------------------------------------------------------------
# "THE BEER-WARE LICENSE" (Revision 42, (c) Poul-Henning Kamp):
# Maxim Sobolev <sobomax@FreeBSD.org> wrote this file. As long as you retain
# this notice you can do whatever you want with this stuff. If we meet some
# day, and you think this stuff is worth it, you can buy me a beer in return.
#
# Maxim Sobolev
# ----------------------------------------------------------------------------
#
# $FreeBSD$
#
# MAINTAINER= sobomax@FreeBSD.org <- any unapproved commits to this file are
# highly discouraged!!!
#
import os, os.path, popen2, types, sys, getopt, pickle
# Global constants and semi-constants
PKG_DBDIR = '/var/db/pkg'
PORTSDIR = '/usr/ports'
ROOT_PORTMK = '/usr/share/mk/bsd.port.mk'
PLIST_FILE = '+CONTENTS'
ORIGIN_PREF = '@comment ORIGIN:'
MAKEFILE = 'Makefile'
MAKE = 'make'
ERR_PREF = 'Error:'
WARN_PREF = 'Warning:'
# Global variables
#
# PortInfo cache
picache = {}
# Useful aliases
op_isdir = os.path.isdir
op_join = os.path.join
op_split = os.path.split
op_abspath = os.path.abspath
#
# Query origin of specified installed package.
#
def getorigin(pkg):
plist = op_join(PKG_DBDIR, pkg, PLIST_FILE)
for line in open(plist).xreadlines():
if line.startswith(ORIGIN_PREF):
origin = line[len(ORIGIN_PREF):].strip()
break
else:
raise RuntimeError('%s: no origin recorded' % plist)
return origin
#
# Execute external command and return content of its stdout.
#
def getcmdout(cmdline, filterempty = 1):
pipe = popen2.Popen3(cmdline, 1)
results = pipe.fromchild.readlines()
for stream in (pipe.fromchild, pipe.tochild, pipe.childerr):
stream.close()
if pipe.wait() != 0:
if type(cmdline) is types.StringType:
cmdline = (cmdline)
raise IOError('%s: external command returned non-zero error code' % \
cmdline[0])
if filterempty != 0:
results = filter(lambda line: len(line.strip()) > 0, results)
return results
#
# For a specified path (either dir or makefile) query requested make(1)
# variables and return them as a tuple in exactly the same order as they
# were specified in function call, i.e. querymakevars('foo', 'A', 'B') will
# return a tuple with a first element being the value of A variable, and
# the second one - the value of B.
#
def querymakevars(path, *vars):
if op_isdir(path):
path = op_join(path, MAKEFILE)
dirname, makefile = op_split(path)
cmdline = [MAKE, '-f', makefile]
savedir = os.getcwd()
os.chdir(dirname)
try:
for var in vars:
cmdline.extend(('-V', var))
results = map(lambda line: line.strip(), getcmdout(cmdline, 0))
finally:
os.chdir(savedir)
return tuple(results)
def parsedeps(depstr):
return tuple(map(lambda dep: dep.split(':'), depstr.split()))
#
# For a specified port return either a new instance of the PortInfo class,
# or existing instance from the cache.
#
def getpi(path):
path = op_abspath(path)
if not picache.has_key(path):
picache[path] = PortInfo(path)
return picache[path]
#
# Format text string according to requested constrains. Useful when you have
# to display multi-line, variable width message on terminal.
#
def formatmsg(msg, wrapat = 78, seclindent = 0):
words = msg.split()
result = ''
position = 0
for word in words:
if position + 1 + len(word) > wrapat:
result += '\n' + ' ' * seclindent + word
position = seclindent + len(word)
else:
if position != 0:
result += ' '
position += 1
result += word
position += len(word)
return result
#
# Class that contain main info about the port
#
class PortInfo:
PKGNAME = None
CATEGORIES = None
MAINTAINER = None
BUILD_DEPENDS = None
LIB_DEPENDS = None
RUN_DEPENDS = None
PKGORIGIN = None
# Cached values, to speed-up things
__deps = None
__bt_deps = None
__rt_deps = None
def __init__(self, path):
self.PKGNAME, self.CATEGORIES, self.MAINTAINER, self.BUILD_DEPENDS, \
self.LIB_DEPENDS, self.RUN_DEPENDS, self.PKGORIGIN = \
querymakevars(path, 'PKGNAME', 'CATEGORIES', 'MAINTAINER', \
'BUILD_DEPENDS', 'LIB_DEPENDS', 'RUN_DEPENDS', 'PKGORIGIN')
def __str__(self):
return 'PKGNAME:\t%s\nCATEGORIES:\t%s\nMAINTAINER:\t%s\n' \
'BUILD_DEPENDS:\t%s\nLIB_DEPENDS:\t%s\nRUN_DEPENDS:\t%s\n' \
'PKGORIGIN:\t%s' % (self.PKGNAME, self.CATEGORIES, self.MAINTAINER, \
self.BUILD_DEPENDS, self.LIB_DEPENDS, self.RUN_DEPENDS, \
self.PKGORIGIN)
def getdeps(self):
if self.__deps == None:
result = []
for depstr in self.BUILD_DEPENDS, self.LIB_DEPENDS, \
self.RUN_DEPENDS:
deps = tuple(map(lambda dep: dep[1], parsedeps(depstr)))
result.append(deps)
self.__deps = tuple(result)
return self.__deps
def get_bt_deps(self):
if self.__bt_deps == None:
topdeps = self.getdeps()
topdeps = list(topdeps[0] + topdeps[1])
for dep in topdeps[:]:
botdeps = filter(lambda dep: dep not in topdeps, \
getpi(dep).get_rt_deps())
topdeps.extend(botdeps)
self.__bt_deps = tuple(topdeps)
return self.__bt_deps
def get_rt_deps(self):
if self.__rt_deps == None:
topdeps = self.getdeps()
topdeps = list(topdeps[1] + topdeps[2])
for dep in topdeps[:]:
botdeps = filter(lambda dep: dep not in topdeps, \
getpi(dep).get_rt_deps())
topdeps.extend(botdeps)
self.__rt_deps = tuple(topdeps)
return self.__rt_deps
def write_msg(*message):
if type(message) == types.StringType:
message = message,
message = tuple(filter(lambda line: line != None, message))
sys.stderr.writelines(message)
#
# Print optional message and usage information and exit with specified exit
# code.
#
def usage(code, msg = None):
myname = os.path.basename(sys.argv[0])
if msg != None:
msg = str(msg) + '\n'
write_msg(msg, "Usage: %s [-rb] [-l|L cachefile] [-s cachefile]\n" % \
myname)
sys.exit(code)
def main():
global picache
# Parse command line arguments
try:
opts, args = getopt.getopt(sys.argv[1:], 'erbl:L:s:')
except getopt.GetoptError, msg:
usage(2, msg)
if len(args) > 0 or len(opts) == 0 :
usage(2)
cachefile = None
chk_bt_deps = 0
chk_rt_deps = 0
warn_as_err = 0
for o, a in opts:
if o == '-b':
chk_bt_deps = 1
elif o == '-r':
chk_rt_deps = 1
elif o in ('-l', '-L'):
# Try to load saved PortInfo cache
try:
picache = pickle.load(open(a))
except:
picache = {}
try:
if o == '-L':
os.unlink(a)
except:
pass
elif o == '-s':
cachefile = a
elif o == '-e':
warn_as_err = 1
# Load origins of all installed packages
instpkgs = os.listdir(PKG_DBDIR)
instpkgs = filter(lambda pkg: op_isdir(op_join(PKG_DBDIR, pkg)), instpkgs)
origins = {}
for pkg in instpkgs:
origins[pkg] = getorigin(pkg)
# Resolve dependencies for the current port
info = getpi(os.getcwd())
deps = []
if chk_bt_deps != 0:
deps.extend(filter(lambda d: d not in deps, info.get_bt_deps()))
if chk_rt_deps != 0:
deps.extend(filter(lambda d: d not in deps, info.get_rt_deps()))
# Perform validation
nerrs = 0
nwarns = 0
if warn_as_err == 0:
warn_pref = WARN_PREF
else:
warn_pref = ERR_PREF
err_pref = ERR_PREF
for dep in deps:
pi = getpi(dep)
if pi.PKGORIGIN not in origins.values():
print formatmsg(seclindent = 7 * 0, msg = \
'%s package %s (%s) belongs to dependency chain, but ' \
'isn\'t installed.' % (err_pref, pi.PKGNAME, pi.PKGORIGIN))
nerrs += 1
elif pi.PKGNAME not in origins.keys():
for instpkg in origins.keys():
if origins[instpkg] == pi.PKGORIGIN:
break
print formatmsg(seclindent = 9 * 0, msg = \
'%s package %s (%s) belongs to dependency chain, but ' \
'package %s is installed instead. Perhaps it\'s an older ' \
'version - update is highly recommended.' % (warn_pref, \
pi.PKGNAME, pi.PKGORIGIN, instpkg))
nwarns += 1
# Save PortInfo cache if requested
if cachefile != None:
try:
pickle.dump(picache, open(cachefile, 'w'))
except:
pass
if warn_as_err != 0:
nerrs += nwarns
return nerrs
PORTSDIR, PKG_DBDIR = querymakevars(ROOT_PORTMK, 'PORTSDIR', 'PKG_DBDIR')
if __name__ == '__main__':
try:
sys.exit(main())
except KeyboardInterrupt:
pass

View File

@ -1,160 +0,0 @@
#!/bin/sh
#
# Copyright (C) 2007 Alexander Leidinger <netchild@FreeBSD.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 AUTHOR AND CONTRIBUTORS ``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 AUTHOR OR CONTRIBUTORS 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.
#
# $FreeBSD$
#
# The purpose of this script is to give the real dependency list of a
# currently installed port.
#
print_usage() {
echo "Usage: $0 [-b base ...] port_name ..."
echo "Example: $0 -b /usr/local -b /space/porttest gnome-vfs-2.18.1_2"
}
args=$(getopt b:h $@)
if [ $? -ne 0 ]; then
print_usage
exit 2
fi
set -- ${args}
for arg; do
case "${arg}" in
-b)
bases="${bases} -b $2"
shift; shift
;;
-h)
print_usage
exit 0
;;
--)
shift
break
;;
esac
done
if [ -z "$1" ]; then
print_usage
exit 2
fi
if [ -z "${PORTSDIR}" ]; then
PORTSDIR=$(make -f /etc/make.conf -V PORTSDIR)
fi
if [ -z "${PORTSDIR}" -o ! -d "${PORTSDIR}" ]; then
PORTSDIR=/usr/ports
fi
if [ -z "${PKG_DBDIR} ]; then
PKG_DBDIR=$(make -f /etc/make.conf -V PKG_DBDIR)
fi
if [ -z "${PKG_DBDIR} -o ! -d "${PKG_DBDIR}" ]; then
PKG_DBDIR=/var/db/pkg
fi
libtool=$(which libtool 2>/dev/null)
if [ -x ${libtool} ]; then
libtool_deplibs=$(grep link_all_deplibs ${libtool} | head -1 | \
cut -d = -f 2)
if [ "X${libtool_deplibs}" != Xno ]; then
echo WARNING: your libtool records dependencies recursively, you can not trust the following output. | fmt
fi
fi
for i in $@; do
if [ -d "${i}" ]; then
current_port="${i}"
else
if [ -d "${PKG_DBDIR}/${i}" ]; then
current_port="${PKG_DBDIR}/${i}"
fi
fi
if [ ! -f ${current_port}/+CONTENTS ]; then
echo $i is not a valid port
continue
fi
myorigin=$(awk -F : '/@comment ORIGIN:/ {print $2}' \
${current_port}/+CONTENTS)
awk '
/^@cwd / {
CWD=$2;
if (CWD == ".") {
exit 0;
}
}
/^s*bin\// {
printf "%s/%s\n", CWD, $1;
}
/^lib\// {
printf "%s/%s\n", CWD, $1;
}
' < ${current_port}/+CONTENTS | \
xargs ${PORTSDIR}/Tools/scripts/neededlibs.sh | \
xargs ${PORTSDIR}/Tools/scripts/resolveportsfromlibs.sh ${bases} | \
egrep -v "(\(${myorigin}\)|${myorigin})\$"
done | sort -u
exit 0
# NOT YET: untested, just an outline of what needs to be done
awk ' /USE_GNOME+=/ {
if (have_gnome != 1) {
use_gnome = sprintf("%s", $2);
} else {
use_gnome = sprintf("%s %s", use_gnome, $2);
have_gnome = 1;
}
}
/USE_XORG+=/ {
if (have_gnome != 1) {
use_gnome = sprintf("%s", $2);
} else {
use_gnome = sprintf("%s %s", use_gnome, $2);
have_gnome = 1;
}
}
END {
if (have_gnome == 1) {
printf("USE_GNOME= %s\n", have_gnome);
}
if (have_xorg == 1) {
printf("USE_XORG= %s\n", have_xorg);
}
}'

View File

@ -1,149 +0,0 @@
#!/usr/local/bin/ruby
# pkg-plist generator by Brian Fundakowski Feldman <green@FreeBSD.org>
# (public domain)
# $FreeBSD$
class Plist
def initialize(no_manpages = true, mtree = [])
@no_manpages = no_manpages
@mtree = mtree
self
end
def make(dir)
@root = dir.to_s + '/'
imake('', 0, '')
end
private
def imake(dir, level, prevwd)
thiswd = prevwd + dir # always ends in '/'
rootedwd = @root + thiswd
subs = []
Dir.foreach(rootedwd) {|dirent|
next if dirent =~ /^\.\.?$/
if test(?d, rootedwd + dirent)
subs.concat(imake(dirent + '/', level + 1, thiswd))
else
if thiswd !~ /^man\// || !@no_manpages
subs.push(thiswd + dirent)
end
end
}
thiswd.chop!
# Strip mtree-created directories
if level > 0 && !@mtree.find {|x| x == thiswd}
subs.push('@dirrm ' + thiswd)
end
return subs
end
end
class Mtree
def initialize(strip = 1)
@paths = []
@curlevel = []
@strip = strip.to_i
@curline = ''
@global_settings = {}
self
end
def parse_line(line)
line.chomp!
if line.empty? || line[0, 1] == '#'
return
end
if line[-1, 1] == "\\"
@curline.concat(line[0..-2])
return
end
line = @curline + line
@curline = ''
case line[/\S.+/]
when /^\/(\S+)/
case $1
when 'set'
$'.split.each {|setting|
key, value, = setting.split(/=/)
@global_settings[key] = value
}
when 'unset'
$'.split.each {|setting| @global_settings.delete(setting)}
else
raise "invalid command \"#{$1}\""
end
when '..'
if @curlevel.pop.nil?
raise '".." with no previous directory'
end
else
spline = line.split()
path = spline[0]
settings = @global_settings.dup
if spline.size > 1
spline[1..-1].each {|setting|
key, value, = setting.split(/=/)
settings[key] = value
}
end
@paths.push(@curlevel + [path])
if settings['type'] == nil || settings['type'] == 'dir'
@curlevel.push(path)
end
end
self
end
def Mtree.read(filename)
m = Mtree.new
open(filename, 'r') {|file|
file.each_line {|line| m.parse_line(line)}
}
m
end
def paths(strip = @strip)
@paths.collect {|path| path[strip..-1].join('/')}
end
end
if __FILE__ == $0
def usage
$stderr.print <<-USAGE_EOF
usage: #{$0} [-Md] [-m mtree] somepath
Generate a pkg-plist to stdout given a previously empty somepath which
a port has been installed into (PREFIX=somepath). The mtree file is
consulted to prevent base directories from being added to the plist.
The -M argument allows manpages to be added to the plist.
The -d argument puts all @dirrm commands at the end of the plist.
USAGE_EOF
exit 1
end
require 'optparse'
begin
params = ARGV.getopts('Md', 'm:')
rescue OptionParser::ParseError => e
$stderr.puts e
usage
end
if ARGV.size != 1
usage
end
mtree = params['m'] || '/etc/mtree/BSD.local.dist'
pl = Plist.new(!params['M'], Mtree.read(mtree).paths).make(ARGV[0])
if params['d']
plnotdirrm = []
pldirrm = []
pl.each {|ent|
if ent =~ /^@dirrm /
pldirrm.push(ent)
else
plnotdirrm.push(ent)
end
plnotdirrm.sort!
pldirrm.sort!
pl = plnotdirrm + pldirrm.reverse
}
else
pl.sort!
end
puts(pl.join("\n"))
end

View File

@ -1,48 +0,0 @@
# $FreeBSD$
#
# The purpose of this Makefile is to setup a standardized environment
# for making package splits. Basically, for each split the organization
# looks like this:
#
# src/release/scripts
# ports/Tools/scripts/release
# RELEASE (e.g. 4.6-RELEASE or 4.6-RC1)
# symlinks to scripts required
# directories used by scripts
# config files
#
# The desire is to provide the scripts with the environment they
# expect while preserving the ability to cvs update them.
RELEASE?=
SRCSCRIPTDIR?= /usr/src/release/scripts
SRCSCRIPTS= print-cdrom-packages.sh
PORTSCRIPTS!= echo *.pl *.sh
FORCE?= no
PWD!= pwd
all:
@if [ -z "${RELEASE}" ]; then \
echo "Release must be specified, i.e.:"; \
echo " make RELEASE=4.6-RELEASE"; \
exit 1; \
fi
@if [ -d "${RELEASE}" -a "${FORCE}" = "no" ]; then \
echo "The release directory ${RELEASE} already exists."; \
echo "To force setup type:"; \
echo " make RELEASE=${RELEASE} FORCE=yes"; \
exit 1; \
fi
# We *could* use mkdir -p, but being explicit helps.
mkdir ${RELEASE}
.for SUBDIR in disc1 disc3 gen
mkdir ${RELEASE}/${SUBDIR}
.endfor
.for SCRIPT in ${PORTSCRIPTS}
cd ${RELEASE} && ln -s ../${SCRIPT} .
.endfor
.for SRCSCRIPT in ${SRCSCRIPTS}
cd ${RELEASE} && ln -s ${SRCSCRIPTDIR}/${SRCSCRIPT} .
@echo "Done."
.endfor
cd ${RELEASE} && ln -s ../config .

View File

@ -1,26 +0,0 @@
$FreeBSD$
This directory contains the scripts that are used to break up the packages
for a given release, so that they fit on a particular 4 CD set. They rely
on src/release/scripts/print-cdrom-packages.sh to give preference for
particular packages to be located on particular CDs.
The approximate procedure is:
1) CVSROOT/avail lockout
2) cvs rtag RELEASE_4_5_0 ports
PWD=`pwd`
1) cd $PWD && cvs co -d srcscripts src/release/scripts
OR
cd $PWD/srcscripts && cvs up -dP
2) cd $PWD && cvs co -d releng ports/Tools/scripts/release
OR
cd $PWD/releng && cvs up -dP
3) cd $PWD/releng
4) make RELEASE=4.6-RELEASE SRCSCRIPTDIR=${PWD}/srcscripts
5) cd 4.6-RELEASE
6) ./doit.sh <path to ports/packages to split>
[ answer prompts and stuff as it appears ]
More documentation to come later.

View File

@ -1,15 +0,0 @@
#!/usr/bin/perl
# $FreeBSD$
die "$0 <pkgdir> <indexfile>\n" if ($#ARGV != 1);
$pkg_dir = shift(@ARGV);
while (<>) {
chomp;
@f = split(/\|/);
@deps = split(/\s+/, $f[8]);
foreach (@deps) {
print "$_\n" if (! -f "$pkg_dir/$_.tgz");
}
}

View File

@ -1,16 +0,0 @@
# $FreeBSD$
#
# disc information
#
# Format:
#disc_name packages_OK distfiles_OK available_space
disc1 1 0 435000000
disc2 1 0 0
disc3 1 0 650000000
disc4 1 0 650000000
disc5 1 1 0
disc6 1 1 0
disc7 1 1 0
disc8 1 1 0
disc9 1 1 0
disca 1 1 0

View File

@ -1,136 +0,0 @@
#!/bin/sh
# $FreeBSD$
pathtoports=$1
dir=`dirname $0`
if [ "X$dir" = "X." ]; then
dir=`pwd`
fi
##############################################################################
#
# Tweak these parameters to match your configuration and make sure to check
# that the disc information in config is correct.
#
# You'll also want to place a recent copy of print-cdrom-packages.sh in the
# $scripts directory.
#
ports="$dir/ports"
dists="$ports/distfiles"
logs="$dir/gen"
pkgs="$ports/packages/All"
scripts="$dir"
xdep_re="^XFree86-3.3.6_1[0-9]$"
#indexfile="INDEX-5"
indexfile="INDEX"
#
##############################################################################
test -d $logs || mkdir -p $logs
if [ ! -d "$ports" ]; then
if [ -z "$pathtoports" ]; then
echo "Missing path to ports/packages toree to process for setup.sh."
exit 1
fi
$scripts/setup.sh $pathtoports
echo ""
echo "Make sure you tweak $dir/config to suit your needs."
echo ""
fi
if [ ! -f "$logs/restricted.sh" ]; then
echo "===> restricted list generation started at $(date)"
(cd $ports; PORTSDIR=$ports make ECHO_MSG=/usr/bin/true \
clean-restricted-list > $logs/restricted.sh)
echo "===> restricted list generation ended at $(date)"
echo $(grep -c '^#' $logs/restricted.sh) "ports in $logs/restricted.sh"
fi
if [ ! -f "$logs/.restricted.done" ]; then
echo "===> cleaning restricted files"
sh $logs/restricted.sh
touch $logs/.restricted.done
fi
if [ ! -f "$logs/cdrom.sh" ]; then
echo "===> cdrom list generation started at $(date)"
(cd $ports; PORTSDIR=$ports make ECHO_MSG=/usr/bin/true \
clean-for-cdrom-list > $logs/cdrom.sh)
echo "===> cdrom list generation ended at $(date)"
echo $(grep -c '^#' $logs/cdrom.sh) "ports in $logs/cdrom.sh"
fi
if [ ! -f "$logs/.cdrom.done" ]; then
echo "===> cleaning non-CDROM-able files"
sh $logs/cdrom.sh
touch $logs/.cdrom.done
fi
if [ ! -f "$logs/$indexfile" ]; then
echo "===> copying INDEX file from $ports/$indexfile"
$scripts/scrubindex.pl $pkgs $ports/$indexfile > $logs/INDEX
$scripts/checkdeps.pl $pkgs $logs/INDEX | sort -u | \
sed -e 's/^/missing dependency: /'
fi
echo -n "Create a list of needed files for each disc? [y] "
read ans
if [ X$ans != Xn -a X$ans != XN ]; then
>$logs/need.ALL
for disc in `cat config | grep -v '#' | sed -e 's/[ ].*//'`; do
echo "disc $disc" >> $logs/need.ALL
$scripts/print-cdrom-packages.sh `echo $disc | sed -e 's/^disc//'` \
$ports | grep -Ev $xdep_re | tee $logs/need.$disc >> $logs/need.ALL
done
fi
echo -n "Populate the discs now? [y] "
read ans
if [ X$ans != Xn -a X$ans != XN ]; then
for disc in `ls -d disc? 2>/dev/null`; do
echo "===> deleting $disc"
rm -rf $disc
done
if [ -d "scratch" ]; then
echo "===> deleting scratch"
rm -rf scratch
fi
echo "Calling oneshot.pl config $logs/need.ALL $logs/INDEX $ports $pkgs/../ $dists"
$scripts/oneshot.pl config $logs/need.ALL $logs/INDEX $ports $pkgs/../ $dists
for disc in `ls -d disc? 2>/dev/null`; do
echo "===> cleaning $disc"
if [ -d "$disc/packages/All" ]; then
$scripts/checkdeps.pl $disc/packages/All $disc/packages/INDEX | \
sort -u | sed -e 's/^/missing package: /'
(
cd $disc/packages/All; \
$scripts/scrubindex.pl . ../INDEX > ../INDEX.new; \
mv ../INDEX.new ../INDEX; \
find . -name '*.tgz' | xargs /sbin/md5 > CHECKSUM.MD5; \
)
fi
du -ck $disc | grep total
done
fi
echo -n "Make sure the 'needed' packages made it on the right disc(s)? [y] "
read ans
if [ X$ans != Xn -a X$ans != XN ]; then
for disc in `ls -d disc? 2>/dev/null`; do
echo "===> checking $disc"
> $logs/have.$disc
if [ -d "$disc/packages/All" ]; then
( cd $disc/packages/All && find . -name '*.tgz' | \
sed -e 's/\.tgz//' -e 's/^\.\///' | sort) > \
$logs/have.$disc
fi
diff -u $logs/have.$disc $logs/need.$disc | grep -e '^\+' | \
grep -v -e '^\+* ' | sed -e 's/\+//' > $logs/missing.$disc
if [ -s $logs/missing.$disc ]; then
echo "===> missing required packages on $disc"
cat $logs/missing.$disc
fi
done
fi

View File

@ -1,425 +0,0 @@
#!/usr/bin/perl
# $FreeBSD$
use File::Basename;
use File::Find;
use File::Path;
my $debug = 1;
my $fake = 0;
my $pkg_ext = "tbz";
my %discs;
my %distfiles;
my %index;
my %unplaced;
sub copyDist($$) {
my $disc = shift;
my $name = shift;
my $distfile = "$disc/distfiles/$name";
my $dir = dirname($distfile);
mkpath($dir);
debugPrint("copying $distfile");
if ($fake) {
system("touch $distfile");
} else {
system("cp $distDir/$name $distfile");
}
}
sub copyPkg($$) {
my $disc = shift;
my $name = shift;
my $pkg = $index{$name};
my $base = $pkg->{base};
my $text = $pkg->{INDEX};
# Copy over the package.
debugPrint("copying $disc/packages/All/$name.$pkg_ext");
mkpath("$disc/packages/All");
if ($fake) {
system("touch $disc/packages/All/$name.$pkg_ext");
} else {
system("cp -f $pkgDir/All/$name.$pkg_ext $disc/packages/All");
}
# Create symlinks in each category.
foreach $cat (@{$pkg->{cats}}) {
debugPrint("creating $disc/packages/$cat/$name.$pkg_ext");
mkpath("$disc/packages/$cat");
symlink("../All/$name.$pkg_ext", "$disc/packages/$cat/$name.$pkg_ext");
}
# If required created the Latest symlink.
mkpath("$disc/packages/Latest");
if ($pkg->{latest}) {
symlink("../All/$name.$pkg_ext", "$disc/packages/Latest/$base.$pkg_ext");
}
# Add the package to INDEX.
open(BAR, ">>$disc/packages/INDEX");
print(BAR "$text\n");
close(BAR);
}
sub debugPrint($) {
my $line = shift;
print STDERR $line . "\n" if $debug;
}
sub addDistfile() {
return if -d;
my $name = $File::Find::name;
my $size = (stat($name))[7];
# Don't record distfiles that are of zero length.
if ($size == 0) {
debugPrint("zero length distfile: $name");
return;
}
$name =~ s!$distDir/!!;
$distfiles{$name} = $size;
}
sub doDistfiles() {
my %clumps;
# Get a list of all the disfiles and their sizes.
find(\&addDistfile, $distDir);
# xxx Need to clump distfiles so that all the ones for a port end up
# xxx on the same disc. For now each distfile is it's own clump. :(
foreach $distfile (sort keys %distfiles) {
my @a = ($distfile);
$clumps{$distfiles{$distfile}} = \@a;
}
# Place as many clumps as we can fit on each disc.
foreach $disc (sort keys %discs) {
next if ! $discs{$disc}->{distFlag};
my $d = $discs{$disc};
my @keys = sort { $a <=> $b } (keys %clumps);
debugPrint("placing distfiles on $disc ...");
while ($d->{avail} > 0) {
my $workDone = 0;
foreach $size (@keys) {
last if ($size > $d->{avail});
placeDist($disc, $size, @{$clumps{$size}});
delete $clumps{$size};
$workDone++;
}
debugPrint("workDone = $workDone");
last if (!$workDone);
}
}
# Put the remaining clumps on the scratch disc.
foreach $size (keys %clumps) {
placeDist('scratch', $size, @{$clumps{$size}});
}
}
sub doPackages() {
# Place as many packages as we can fit on each disc.
foreach $disc (sort keys %discs) {
next if ! $discs{$disc}->{pkgFlag};
my $d = $discs{$disc};
debugPrint("placing packages on $disc ...");
my $d = $discs{$disc};
while ($d->{avail} > 0) {
redoImpact($disc);
my $workDone = 0;
my @keys = sort { $impact{$a} <=> $impact{$b} } (keys %unplaced);
foreach $name (@keys) {
if ($impact{$name} <= $d->{avail}) {
placePkg($disc, $name, 0);
$workDone = 1;
last;
}
}
last if (!$workDone);
}
}
# Put all the unplaced packages on the scratch disc.
redoImpact('scratch');
foreach $name (keys %unplaced) {
debugPrint("uplaced package: $name");
placePkg('scratch', $name, 0);
}
}
sub isLatest($$) {
my ($name, $base) = @_;
my $link = "$pkgDir/Latest/$base.$pkg_ext";
my $pkg = "$pkgDir/All/$name.$pkg_ext";
return 0 if ! -l $link;
my ($dev1, $ino1) = stat($pkg);
my ($dev2, $ino2) = stat($pkg);
return $dev1 == $dev2 && $ino1 == $ino2;
}
sub placeDist($$@) {
my $disc = shift;
my $size = shift;
my @distfiles = @_;
my $d = $discs{$disc};
# Adjust sizes of disc based on the impact of this package.
$d->{used} += $size;
$d->{avail} -= $size;
# Add each of the distfiles to this disc.
foreach $name (@distfiles) {
debugPrint("placing $name on $disc");
$d->{distfiles}->{$name}++;
}
}
sub placeNeeded() {
local *NEEDED;
debugPrint("reading $neededPkgs and placing packages ...");
open(NEEDED, $neededPkgs)
or die "unable to read $neededPkgs: $!\n";
my $disc;
$_ = <NEEDED>;
chomp;
if (/^disc (\w+)/) {
$disc = $1;
} else {
die "invalid first line in $neededPkgs: $_";
}
while (<NEEDED>) {
chomp;
if (/^disc (\w+)/) {
$disc = $1;
next;
}
if (defined($index{$_})) {
placePkg($disc, $_, 1);
} else {
# die "missing needed package: $_";
}
}
close(NEEDED);
}
sub placePkg($$$) {
my $disc = shift;
my $name = shift;
my $nodeps = shift;
debugPrint(" placing $name on $disc");
my $size;
if ($nodeps) {
$size = $index{$name}->{size};
} else {
$size = $impact{$name};
}
# Adjust sizes of disc based on the impact of this package.
my $d = $discs{$disc};
$d->{used} += $size;
$d->{avail} -= $size;
# Remove this package from unplaced and place it on this disc.
delete $unplaced{$name};
$d->{pkgs}->{$name}++;
# Now do the same thing for the dependencies.
return if $nodeps;
foreach (@{$index{$name}->{rdeps}}) {
delete $unplaced{$_};
$d->{pkgs}->{$_}++;
}
}
sub readDiscInfo() {
local *INFO;
# Make sure we have at least disc that will be the place overflow will go.
my $disc = {
'avail' => 0,
'distFlag' => 0,
'distfiles' => {},
'name' => 'scratch',
'pkgFlag' => 0,
'pkgs' => {},
'size' => 0,
'used' => 0
};
$discs{'scratch'} = $disc;
debugPrint("reading $discInfo ...");
open(INFO, $discInfo)
or die "unable to read $discInfo: $!";
while (<INFO>) {
chomp;
next if (/^#/);
my @f = split(/\s+/);
next if (@f != 4);
my $disc = {
'avail' => $f[3],
'distFlag' => $f[2],
'distfiles' => {},
'name' => $f[0],
'pkgFlag' => $f[1],
'pkgs' => {},
'size' => $f[3],
'used' => 0
};
$discs{$f[0]} = $disc;
}
close(INFO);
}
sub readIndex() {
local *INDEX;
debugPrint("reading $indexFilename ...");
open(INDEX, $indexFilename)
or die "unable to read $indexFilename: $!";
while (<INDEX>) {
chomp;
my @f = split(/\|/);
my $name = $f[0];
my $base = $name;
$base =~ s/-[^-]*$//;
my $pkg = {
'INDEX' => $_,
'base' => $base,
'cats' => [split(/\s+/, $f[6])],
'distfiles' => {},
'latest' => isLatest($name, $base),
'name' => $name,
'rdeps' => [split(/\s+/, $f[8])],
'size' => (stat("$pkgDir/All/$name.$pkg_ext"))[7],
};
# debugPrint("adding " . $pkg->{name});
# die "duplicate package: $name" if ($debug && defined($index{$name}));
$index{$name} = $pkg;
$unplaced{$name} = 1;
}
close(INDEX);
}
sub _impact($$) {
my $disc = shift;
my $name = shift;
# Return previously calculated value if we have it.
return $impact{$name} if defined($impact{$name});
my $pkg = $index{$name};
my @rdeps = @{$pkg->{rdeps}};
my $size = $pkg->{size};
# If no dependencies then the impact is the size of this package.
return $impact{$name} = $size if (!@rdeps);
# Otherwise the impact is this package's size plus any dependencies
# that are not already on this disc.
foreach (@rdeps) {
$size += $index{$_}->{size} if !defined($discs{$disc}->{pkgs}->{$_});
}
return $impact{$name} = $size;
}
sub redoImpact($) {
my $disc = shift;
# Reset the impact hashtable.
%impact = undef;
# Calculate the impact for each unplaced package.
foreach $pkg (keys %unplaced) {
$impact{$pkg} = _impact($disc, $pkg);
}
}
MAIN: {
if ($#ARGV != 5) {
die "$0 <disc_info> <needed_pkgs> <INDEX> <ports_dir> <pkg_dir> <dist_dir>";
}
$discInfo = shift(@ARGV);
$neededPkgs = shift(@ARGV);
$indexFilename = shift(@ARGV);
$portsDir = shift(@ARGV);
$pkgDir = shift(@ARGV);
$distDir = shift(@ARGV);
readDiscInfo();
readIndex();
placeNeeded();
# bail if any of the discs have overflowed.
foreach (keys %discs) {
my $avail = $discs{$_}->{avail};
die "disc $_ has overflowed: avail = $avail\n" if ($avail < 0);
print "avail for disc $_ = $avail\n" if ($debug);
}
doPackages();
doDistfiles();
# Now that we know where everything should go. Make it so.
foreach $disc (sort keys %discs) {
debugPrint("copying packages to $disc ...");
foreach $name (keys %{$discs{$disc}->{pkgs}}) {
copyPkg($disc, $name);
}
debugPrint("copying distfiles to $disc ...");
foreach $name (keys %{$discs{$disc}->{distfiles}}) {
copyDist($disc, $name);
}
}
foreach $disc (sort keys %discs) {
debugPrint("$disc: avail = " . $discs{$disc}->{avail});
}
}

View File

@ -1,31 +0,0 @@
#!/usr/bin/perl
# $FreeBSD$
die "$0 <pkgdir> <indexfile>\n" if ($#ARGV != 1);
$xdep = 'XFree86-3\.3\.6_10';
$pkgdir = shift(@ARGV);
#$ext = 'tbz';
$ext = 'tgz';
print STDERR "scrubindex pkgdir: $pkgdir\n";
my $cnt = 0;
LOOP:
while (<>) {
s/$xdep//g;
s/ */ /g;
s/\| /\|/g;
@f = split('\|');
next if (! -f "$pkgdir/$f[0].$ext");
foreach $dep (split(' ', $f[8])) {
next LOOP if (! -f "$pkgdir/$dep.$ext");
}
$cnt++;
print;
}
print STDERR "$cnt lines copied from scrubindex.pl"

View File

@ -1,19 +0,0 @@
#!/bin/sh
# $FreeBSD$
dir=$@
if [ -z $dir ]; then
echo "Usage: $0 <path to dir with ports and packages to split>"
exit 1
fi
if [ ! -d $dir ]; then
echo "Directory not found. Aborting."
exit 1
fi
tar xzvf $dir/ports.tar.gz
cd ports
rm -f distfiles packages
mkdir distfiles packages
(echo "copying packages ..." && cd packages && cp -R $dir/packages/ .)
#(echo "copying distfiles ..." && cd distfiles && cp -R $dir/distfiles/ .)

View File

@ -1,227 +0,0 @@
#!/bin/sh
#
# Copyright (C) 2007 Alexander Leidinger <netchild@FreeBSD.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 AUTHOR AND CONTRIBUTORS ``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 AUTHOR OR CONTRIBUTORS 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.
#
# $FreeBSD$
#
# The purpose of this script is to find the installed port which contains
# the specified libraries.
#
print_usage() {
echo "Usage: $0 [-b base ...] lib_name ..."
echo "Example: $0 -b /usr/local -b /space/porttest libX11.so"
}
which pkg_which >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "pkg_which not found in path (${PATH}), aborting" | fmt
exit 1
fi
args=$(getopt b:h $@)
if [ $? -ne 0 ]; then
print_usage
exit 2
fi
set -- ${args}
for arg; do
case "${arg}" in
-b)
bases="${bases} $2"
shift; shift
;;
-h)
print_usage
exit 0
;;
--)
shift
break
;;
esac
done
if [ -z "$1" ]; then
print_usage
exit 2
fi
if [ -z "${bases}" ]; then
bases=/usr/local
fi
if [ -z "${PORTSDIR}" ]; then
PORTSDIR=$(make -f /etc/make.conf -V PORTSDIR)
fi
if [ -z "${PORTSDIR}" ]; then
PORTSDIR=/usr/ports
fi
if [ ! -d "${PORTSDIR}" ]; then
echo "PORTSDIR = ${PORTSDIR} is not a directory."
exit 1
fi
if [ -z "${PKG_DBDIR}" ]; then
PKG_DBDIR=/var/db/pkg
fi
if [ ! -d "${PKG_DBDIR}" ]; then
echo "PKG_DBDIR = ${PKG_DBDIR} is not a directory."
exit 1
fi
for i in $@; do
result=""
case $i in
libcrypto.so|libssl.so)
echo "USE_OPENSSL= yes"
continue
;;
esac
if [ -e /lib/$i -o -e /usr/lib/$i ]; then
# base system lib, skipping
shift
continue
fi
lib=${i##*/}
lib="$(echo ${lib} | sed -e 's:^lib:: ; s:\.so.*::')"
# I didn't managed to make awk accept a pattern with a '/' inside,
# so don't complain about using grep+awk instead of awk only.
lib_pathname=$(ldconfig -r | grep $i | awk '{print $3}')
origin=unknown
for base in ${bases}; do
port=$(pkg_which "${base}/lib/$i")
if [ -f $PKG_DBDIR/$port/+CONTENTS ]; then
origin=$(grep "@comment ORIGIN:" \
$PKG_DBDIR/$port/+CONTENTS \
| sed -e 's/@comment ORIGIN://')
break
else
continue
fi
done
if [ ${origin} = unknown ]; then
if [ -f ${lib_pathname} ]; then
port=$(pkg_which "${lib_pathname}")
if [ -f $PKG_DBDIR/$port/+CONTENTS ]; then
origin=$(grep "@comment ORIGIN:" \
$PKG_DBDIR/$port/+CONTENTS \
| sed -e 's/@comment ORIGIN://')
else
result="${lib} ($i) not found, unknown origin"
fi
fi
fi
if [ ${origin} != unknown ]; then
category=${origin%/*}
portname=${origin##*/}
XORG="$(egrep ${origin}\$ ${PORTSDIR}/Mk/bsd.xorg.mk \
2>/dev/null | grep _LIB | sed -e 's:_LIB.*::')"
GNOME="$(egrep ${origin}\$ ${PORTSDIR}/Mk/bsd.gnome.mk \
2>/dev/null | grep _LIB | sed -e 's:_LIB.*::')"
EFL="$([ "X$(make ${PORTSDIR}/Mk/bsd.efl.mk -V \
_${portname}_CATEGORY )" = "X${category}" ] && \
echo ${portname})"
GL="$(egrep ${origin}\$ ${PORTSDIR}/Mk/bsd.port.mk \
2>/dev/null | grep _LIB_DEPENDS \
| sed -e 's:_GL_:: ; s:_LIB_DEPENDS.*::')"
fi
if [ -n "${XORG}" ]; then
result="USE_XORG+= ${XORG} (${origin})"
if [ $(echo ${XORG} | wc -w) -ne 1 ]; then
result="${result} # result ambiguous, check yourself: ${lib}"
fi
fi
if [ -n "${GNOME}" ]; then
result="USE_GNOME+= ${GNOME} (${origin})"
if [ $(echo ${GNOME} | wc -w) -ne 1 ]; then
result="${result} # result ambiguous, check yourself: ${lib}"
fi
fi
if [ -n "${EFL}" ]; then
result="USE_EFL+= ${EFL} (${origin})"
fi
if [ -n "${GL}" ]; then
result="USE_GL+= ${GL} (${origin})"
fi
# USE_xxx exceptions, sorting key is the USE_xxx name
# START and STOP are needed for a perfect match
case "START${origin}STOP" in
STARTdevel/famSTOP|STARTdevel/gaminSTOP)
result="USE_FAM= yes (${origin})"
;;
STARTprint/freetypeSTOP)
result="USE_FREETYPE= yes (${origin})"
;;
STARTdevel/gettextSTOP)
result="USE_GETTEXT= yes (${origin})"
;;
STARTconverters/libiconvSTOP)
result="USE_ICONV= yes (${origin})"
;;
STARTnet/openldap*sasl*clientSTOP)
result="USE_OPENLDAP= yes WANT_OPENLDAP_SASL= yes"
;;
STARTnet/openldap*clientSTOP)
result="USE_OPENLDAP= yes (${origin})"
;;
STARTdevel/sdl12STOP)
result="USE_SDL= sdl (${origin})"
;;
/sdl_)
result="USE_SDL= $(echo $origin | sed -e 's:.*/sdl_::g') (${origin})"
;;
esac
if [ -z "${result}" ]; then
result="${lib}:\${PORTSDIR}/${origin}"
fi
echo "${result}"
shift
done | sort -u