svn commit: r244219 - projects/portbuild/scripts
Mark Linimon
linimon at FreeBSD.org
Fri Dec 14 15:17:54 UTC 2012
Author: linimon (doc,ports committer)
Date: Fri Dec 14 15:17:53 2012
New Revision: 244219
URL: http://svnweb.freebsd.org/changeset/base/244219
Log:
Parameterize uid. Rip out special hard-coding of ports-<arch>.
Modified:
projects/portbuild/scripts/allgohans
Modified: projects/portbuild/scripts/allgohans
==============================================================================
--- projects/portbuild/scripts/allgohans Fri Dec 14 15:12:08 2012 (r244218)
+++ projects/portbuild/scripts/allgohans Fri Dec 14 15:17:53 2012 (r244219)
@@ -5,6 +5,17 @@ pbd=${PORTBUILD_DATA:-/var/portbuild}
. ${pbc}/conf/server.conf
+if [ ! -z "${PORTBUILD_USER}" ]; then
+ uid=${PORTBUILD_USER}
+else
+ uid=ports-${arch}
+fi
+if [ ! -z "${PORTBUILD_GROUP}" ]; then
+ gid=${PORTBUILD_GROUP}
+else
+ gid=${uid}
+fi
+
doarch() {
arch=$1
shift
@@ -31,29 +42,26 @@ doarch() {
# If we need to scp first, the command given in the parameters is the local
# path, which we need to upload first. The command will return the remote
# temporary file, which we can subsequently execute. So this isn't really scp.
- cmdpath=$(su ports-${arch} -c "cat ${cmd} | ${ssh_cmd} ${client_user}@$i 't=\$(mktemp -t ${cmd##*/}); cat >\$t; echo \$t; chmod 755 \$t'")
+ cmdpath=$(su ${uid} -c "cat ${cmd} | ${ssh_cmd} ${client_user}@$i 't=\$(mktemp -t ${cmd##*/}); cat >\$t; echo \$t; chmod 755 \$t'")
case ${cmdpath} in /tmp/*) ;; *) echo "Failed to scp ${cmd} to $i."; return 1;; esac
fi
- lockf -t 60 ${pbd}/${arch}/lockfiles/lock.$i su ports-${arch} -c "${ssh_cmd} ${client_user}@$i ${sudo_cmd} ${cmdpath} $@"
+ lockf -t 60 ${pbd}/${arch}/lockfiles/lock.$i su ${uid} -c "${ssh_cmd} ${client_user}@$i ${sudo_cmd} ${cmdpath} $@"
result=$?
if [ $result -ne 0 ]; then
echo "could not execute command ${cmdpath} $@ on $i: $result"
fi
if [ ${scpfirst} -ne 0 ]; then
- su ports-${arch} -c "${ssh_cmd} ${client_user}@$i 'rm -f ${cmdpath}'"
+ su ${uid} -c "${ssh_cmd} ${client_user}@$i 'rm -f ${cmdpath}'"
fi
done
}
-id=$(whoami)
-if [ "${id}" = "root" ]; then
- arch=$1
- shift
- root=1
-else
- arch=$(echo $id | sed s,ports-,,)
- root=0
+arch=$1
+if [ -z "${arch}" ]; then
+ echo "usage: $0 <arch> [-q] [-scp]"
+ exit 1
fi
+shift
# XXX - Have to convert this to getopt().
if [ "$1" = "-q" ]; then
More information about the svn-src-projects
mailing list