[27266] users/mww/select
source_changes at macosforge.org
source_changes at macosforge.org
Thu Jul 26 04:32:40 PDT 2007
Revision: 27266
http://trac.macosforge.org/projects/macports/changeset/27266
Author: mww at macports.org
Date: 2007-07-26 04:32:40 -0700 (Thu, 26 Jul 2007)
Log Message:
-----------
version 0.1
Modified Paths:
--------------
users/mww/select/Makefile.in
users/mww/select/configure
users/mww/select/select.8
users/mww/select/select.sh
Added Paths:
-----------
users/mww/select/select-0.1.tar.gz
Modified: users/mww/select/Makefile.in
===================================================================
--- users/mww/select/Makefile.in 2007-07-26 10:10:00 UTC (rev 27265)
+++ users/mww/select/Makefile.in 2007-07-26 11:32:40 UTC (rev 27266)
@@ -1,13 +1,27 @@
prefix=@prefix@
bindir=@prefix@/bin
mandir=@mandir@
+confdir=@prefix@/etc/select/@name@
name=@name@
+version=@version@
+all:
+
install:
install -m 755 -d $(DESTDIR)$(bindir)
install -m 755 -d $(DESTDIR)$(mandir)/man8
- cat select.8 | sed "s|__PREFIX__|$(prefix)|g" | sed "s|__NAME__|$(name)|g" > $(DESTDIR)$(mandir)/man8/$(name)_select.8
+ install -m 755 -d $(DESTDIR)$(confdir)
+ cat select.8 | sed "s|__PREFIX__|$(prefix)|g" | sed "s|__NAME__|$(name)|g" | sed "s|__VERSION__|$(version)|g" > $(DESTDIR)$(mandir)/man8/$(name)_select.8
chmod 444 $(DESTDIR)$(mandir)/man8/$(name)_select.8
- cat select.sh | sed "s|__PREFIX__|$(prefix)|g" | sed "s|__NAME__|$(name)|g" > $(DESTDIR)$(prefix)/bin/$(name)_select
+ cat select.sh | sed "s|__PREFIX__|$(prefix)|g" | sed "s|__NAME__|$(name)|g" | sed "s|__VERSION__|$(version)|g" > $(DESTDIR)$(prefix)/bin/$(name)_select
chmod 755 $(DESTDIR)$(bindir)/$(name)_select
+dist:
+ rm -rf select-$(version)
+ mkdir select-$(version)
+ cp configure Makefile.in select.sh select.8 select-$(version)
+ tar -z -cf select-$(version).tar.gz select-$(version)
+
+clean:
+ rm -f Makefile
+
Modified: users/mww/select/configure
===================================================================
--- users/mww/select/configure 2007-07-26 10:10:00 UTC (rev 27265)
+++ users/mww/select/configure 2007-07-26 11:32:40 UTC (rev 27266)
@@ -1,24 +1,33 @@
#!/bin/sh
rm -f Makefile
+
+# some defaults
+version=0.1
+prefix=/usr/local
+mandir=${prefix}/share/man
+name=gcc
+
for i; do
- echo "i: $i"
- if [ "--prefix" = "$i" ]; then
- shift;
- prefix=${1}
- shift;
- elif [ "--mandir" = "$i" ]; then
- shift;
- mandir=${1}
- shift;
- elif [ "--name" = "$i" ]; then
- shift;
- name=${1}
- shift;
+ opt=$(echo ${i}|sed 's|=.*||g')
+ val=$(echo ${i}|sed 's|.*=||g')
+ if [ "--help" = "${opt}" ]; then
+ echo "Options:"
+ echo "--prefix=PREFIX install in PREFIX"
+ echo "--mandir=MANDIR install manpages in MANDIR"
+ echo "--name=NAME use NAME_select for tool"
+ exit 0
+ elif [ "--prefix" = "${opt}" ]; then
+ prefix=${val}
+ elif [ "--mandir" = "${opt}" ]; then
+ mandir=${val}
+ elif [ "--name" = "${opt}" ]; then
+ name=${val}
fi
done
cat Makefile.in | \
sed "s|@prefix@|${prefix}|g" | \
sed "s|@mandir@|${mandir}|g" | \
+ sed "s|@version@|${version}|g" | \
sed "s|@name@|${name}|g" > Makefile
Added: users/mww/select/select-0.1.tar.gz
===================================================================
(Binary files differ)
Property changes on: users/mww/select/select-0.1.tar.gz
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: users/mww/select/select.8
===================================================================
--- users/mww/select/select.8 2007-07-26 10:10:00 UTC (rev 27265)
+++ users/mww/select/select.8 2007-07-26 11:32:40 UTC (rev 27266)
@@ -28,25 +28,37 @@
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd July 26, 2007
-.Dt @name at _SELECT 8 "MacPorts"
+.Dt __NAME___SELECT 8 "MacPorts"
.Os
.Sh NAME
-.Nm @name at _select
+.Nm __NAME___select
.Nd choose between multiple versions of the same or similar tool
.Sh SYNOPSIS
.Nm
.Op Fl nfrhv
.Op Ar version
+.Op Ar -i path
.Sh DESCRIPTION
.Nm
lets you choose between multiple versions of the same or a similar software
.Pp
.Sh FILES
.Bl -tag -width
-.It Va @prefix@/etc/@name at _select/base
-Base configuration for the software @name@
-.It Va @prefix@/etc/${name}_select/${version}
-Configuration for a specific version of the software ${name}
+.It Va __PREFIX__/etc/select/__NAME__/base
+Base configuration for the software __NAME__. Each line in the file specifies a file that __NAME___select provides by symlinking it to a target file. Paths will all be prefixed by the prefix provided at install time (__PREFIX__ in this case).
+.br
+.Sy Example:
+.Dl bin/foo
+.Dl sbin/bar
+.Dl share/man/man1/foo.1.gz
+.br
+.It Va __PREFIX__/etc/select/__NAME__/${version}
+Configuration for a specific version of the software __NAME__. This provides one possibility to choose from. When this version is selected, all files from the base configuration get symlinked to the corresponding files in the version file. Each line in the base configuration file corresponds to the same line in the version file. If the version cannot provide a target file, the line in the version file has to start with a '-' (The symlink will then be deleted if this version is activated). Lines may start with a '/' for absolut an absolut path. If lines do not start with a '/', they will be prefixed by __PREFIX__.
+.br
+.Sy Example:
+.Dl bin/foo-5.9
+.Dl /sbin/false
+.Dl -
.El
.Sh DIAGNOSTICS
.Ex -std
Modified: users/mww/select/select.sh
===================================================================
--- users/mww/select/select.sh 2007-07-26 10:10:00 UTC (rev 27265)
+++ users/mww/select/select.sh 2007-07-26 11:32:40 UTC (rev 27266)
@@ -2,7 +2,8 @@
#
# $Id: portdestroot.tcl 27199 2007-07-24 09:09:43Z mww at macports.org $
#
-# Copyright (c) 2007, MacPorts Project
+# Copyright (c) 2007 The MacPorts Project
+# Copyright (c) 2007 Markus W. Weissmann <mww at macports.org>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -30,37 +31,44 @@
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
+## configuration time options
PREFIX=__PREFIX__
-NAME=__NAME___select
-CONFPATH=${PREFIX}/etc/${NAME}
-VERSION=0.1
+NAME=__NAME__
+TOOL=${NAME}_select
+CONFPATH=${PREFIX}/etc/select/${NAME}
+VERSION=__VERSION__
+
## GLOBALS
-# dont actually execute
+# dont actually execute, just show what would have been done
noexec=0
# enforce action
force=0
# skip check for required rights
isroot=0
+# perform "install" mode (for initial destroot)
+inst_mode=0
+DESTDIR=""
# print the usage of this tool
usage() {
- echo "usage: ${NAME} [-n] [-f] [-r] [-h] [-v] version"
+ echo "usage: ${TOOL} [-n] [-f] [-r] [-h] [-v] version"
echo ""
- echo "-n Show commands to do selection but do not execute them."
- echo "-f Ensure the links are correct for the specified version"
- echo " even if it maches the current default version."
- echo "-h Display this help info."
- echo "-r Skip test for necessary rights."
- echo "-v Display version of ${0}."
- echo "-l List available options for version."
+ echo "-n Show commands to do selection but do not execute them."
+ echo "-f Ensure the links are correct for the specified version"
+ echo " even if it maches the current default version."
+ echo "-h Display this help info."
+ echo "-r Skip test for necessary rights."
+ echo "-v Display version of ${0}."
+ echo "-l List available options for version."
+ echo "-i path Install mode to perform an initial selection in path."
echo ""
}
# print the version of this tool
version() {
- echo "${NAME} v${VERSION}"
+ echo "${TOOL} v${VERSION}"
}
# list all (currently) available versions
@@ -81,10 +89,20 @@
# perform an action (command) or just display it
action() {
- if [ 1 == ${noexec} ]; then
- echo "${1}"
+ if [ "rm" == ${1} ]; then
+ if [ 1 == ${noexec} ]; then
+ echo "rm -f ${2}"
+ else
+ rm -f ${2}
+ fi
+ elif [ "ln" == ${1} ]; then
+ if [ 1 == ${noexec} ]; then
+ echo "ln -sf ${2} ${3}"
+ else
+ ln -sf ${2} ${3}
+ fi
else
- ${1}
+ return 1
fi
}
@@ -94,15 +112,21 @@
local error=0
local i=1
local empty=0
+ echo "Selecting version \"${1}\" for ${NAME}"
for target in $(cat ${CONFPATH}/base); do
src=$(head -n ${i} ${CONFPATH}/${1} | tail -n 1)
empty=0
# test if line starts with '-' -> dont link, just rm original
if [ "-" == $(echo ${src} | colrm 2) ]; then
- action "rm -f ${PREFIX}${target}"
+ # source is unavailable for this file
+ action "rm" "${DESTDIR}${PREFIX}/${target}"
+ elif [ "/" == $(echo ${src} | colrm 2) ]; then
+ # source has an absolute path
+ action "ln" "${src}" "${DESTDIR}${PREFIX}/${target}"
else
- action "ln -sf \"${PREFIX}${src}\" \"${PREFIX}${target}\""
+ # source has relative path
+ action "ln" "${PREFIX}/${src}" "${DESTDIR}${PREFIX}/${target}"
fi
let "error = error + ${?}"
let "i = i + 1"
@@ -117,7 +141,7 @@
fi
# parse command line args
-args=$(/usr/bin/getopt fhnlrv $*)
+args=$(/usr/bin/getopt i:fhnlrv $*)
set -- ${args}
for i; do
case "${i}" in
@@ -128,20 +152,25 @@
-f)
force=1; shift;;
-l)
- list; exit 0;;
+ list_version; exit 0;;
-r)
isroot=1; shift;;
-v)
version; exit 0;;
+ -i)
+ inst_mode=1; DESTDIR=${2}; shift; shift;;
--)
shift; break;;
esac
done
-#echo "isroot: ${isroot}"
-#echo "noexec: ${noexec}"
-#echo "force: ${force}"
-#echo "arg: ${1}"
+# install mode - bypass all checks and add DESTDIR
+if [ "1" = "${inst_mode}" ]; then
+ echo "install mode: destroot: \"${DESTDIR}\""
+ CONFPATH=${DESTDIR}${CONFPATH}
+ select_version ${1}
+ exit ${?}
+fi
# test if chosen version is available
version_is_valid $1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20070726/0789596b/attachment.html
More information about the macports-changes
mailing list