> kirby@ reminded that portimport(1) was not updated after portcheck(1) > import. Among other things, it allows to run portimport from custom > directory, which was requested by kirby@ in the first place. > > Any comments/okays on the following patch then?
Improved version, after some input from sthen@. Also includes manual page update. okay? -- zhuk@ Index: man/man1/portimport.1 =================================================================== RCS file: /cvs/ports/infrastructure/man/man1/portimport.1,v retrieving revision 1.2 diff -u -p -r1.2 portimport.1 --- man/man1/portimport.1 11 Apr 2013 15:18:00 -0000 1.2 +++ man/man1/portimport.1 11 Dec 2013 10:02:11 -0000 @@ -22,6 +22,8 @@ .Nd import a new port to the ports cvs repository .Sh SYNOPSIS .Nm +.Op Fl U +.Op Fl p Ar portsdir .Op Fl u Ar username .Sh DESCRIPTION .Nm @@ -33,8 +35,13 @@ repository, avoiding common mistakes. It has to be executed from within the new port's directory. .Pp .Nm -verifies that a minimal directory and file structure for a port is in -place and that no bogus files exist. +calls the +.Xr portcheck 1 +internally to verify that directory and file structure for a port is in +place and that no bogus files exist, and also to detect the +.Ev PKGPATH +for a port. +.Pp The import is done in two steps. In the first step, the .Fl n @@ -49,6 +56,15 @@ of the local ports tree. .Pp The following options are available: .Bl -tag -width Ds +.It Fl p Ar portsdir +Forces the given directory to be treated as ports root directory. +Passed through to +.Xr portcheck 1 . +.It Fl U +Skip checks not useful for already committed stuff when, e.g., when +moving stuff around the tree. +Passed through to +.Xr portcheck 1 . .It Fl u Ar username Set the username used for .Xr ssh 1 , @@ -57,9 +73,12 @@ Defaults to the local username. .El .Sh SEE ALSO .Xr cvs 1 +.Xr portcheck 1 .Sh HISTORY This command is based on the portimport script of Marc Espie, lightly modified by Stuart Henderson and rewritten by Robert Peichaer. +Later, actual checks were moved to a separate utility, +.Xr portcheck 1 . .Sh CAVEATS The .Ev CVSROOT Index: bin/portimport =================================================================== RCS file: /cvs/ports/infrastructure/bin/portimport,v retrieving revision 1.2 diff -u -p -r1.2 portimport --- bin/portimport 11 Apr 2013 15:18:00 -0000 1.2 +++ bin/portimport 11 Dec 2013 10:02:11 -0000 @@ -18,52 +18,54 @@ # Based on Marc Espie's portimport. # sthen: Modified to handle imports from mystuff/ and do a dry run first. # rpe: rewrite based on sthen@'s version +# zhuk: checks and detection of pkgpath moved to portcheck(1) set -e +set -u usage() { - echo "usage: $(basename $0) [-u username]" >&2 + echo "usage: ${0##*/} [-U] [-p portsdir] [-u username]" >&2 exit 1 } user=$(id -un) +portsdir= +portcheck_args= +unset portcheck_args[0] -while getopts "u:" OPT; do +while getopts "p:Uu:" OPT; do case $OPT in - u) user="$OPTARG";; + p) portsdir="$OPTARG" + portcheck_args[${#portcheck_args[@]}]="-p$portsdir";; + U) portcheck_args[${#portcheck_args[@]}]="-U";; + u) user=$OPTARG;; *) usage;; esac done -cvsroot=$u...@cvs.openbsd.org:/cvs -error=false -fulldir=$(pwd) -importname="ports/${fulldir##*/ports/*(mystuff/|openbsd-wip/|p5-ports-wip/)}" -timestamp=$(date '+%Y%m%d') +shift $(($OPTIND - 1)) +(($# > 0)) && usage -err() { echo "$*"; error=true; } +error=false +pkgpath=$(portcheck "${portcheck_args[@]:---}") || error=true +if $error; then + read ans?'Do you want to continue after those errors? [y/N] ' + [[ $ans == +(y|Y) ]] || exit +fi -[[ -f Makefile && -f distinfo && -f pkg/DESCR && -f pkg/PLIST ]] || err "No ports files?" -find . -name .git -print|read i && err "You git!" -find . -name .\*.swp -print|read i && err "Found vim swap file" -find . -name \*.orig -print|read i && err "Found .orig file, ouch" -find . -name typescript -print|read i && err "Found typescript file, ouch" -find . -path ./w-\* -print|read i && err "Please wipe out work directory before importing" -find . -type d -name core -print|read i && err "directory named core found, cvs will ignore it" -find . -type f -name .todo -print|read i && err "devtodo file found" -find . -type d -name CVS -print|read i && err "Some CVS stuff already in there, very funky" -$error && exit 1 +portsdir=${portsdir:-${PWD%"/$pkgpath"}} +timestamp=$(date '+%Y%m%d') +cvsroot=$u...@cvs.openbsd.org:/cvs echo -n "Import would go into: " -cvs -n -d$cvsroot import $importname $user ${user}_$timestamp 2>/dev/null | \ +cvs -n -d$cvsroot import ports/$pkgpath $user ${user}_$timestamp 2>/dev/null | \ grep Makefile | head -1 | awk '{print $2}' | xargs dirname -read ans?'Correct path? [y/n] ' +read ans?'Does this look correct? [y/n] ' if [[ $ans == +(y|Y) ]]; then - cvs -d$cvsroot import $importname $user ${user}_$timestamp - cd /usr/$importname/../ - cvs -d$cvsroot update -AdP ${fulldir##*/} - echo "Don't forget to commit the category Makefile when you're done!" - cd /usr/$importname/../ + cvs -d$cvsroot import ports/$pkgpath $user ${user}_$timestamp + cd "$portsdir/${pkgpath%/*}" + cvs -d$cvsroot update -AdP ${pkgpath##*/} + echo "Don't forget to commit the ${pkgpath%/*}/Makefile when you're done!" pwd fi