Elegant way to update a port

Ion-Mihai Tetcu itetcu at FreeBSD.org
Wed Jan 26 18:59:47 UTC 2011


On Wed, 26 Jan 2011 12:31:37 -0600
Paul Schmehl <pschmehl_lists at tx.rr.com> wrote:

> --On January 26, 2011 8:18:18 PM +0200 Ion-Mihai Tetcu
> <itetcu at FreeBSD.org> wrote:
> 
> > On Wed, 26 Jan 2011 10:32:51 -0600
> > Paul Schmehl <pschmehl_lists at tx.rr.com> wrote:
> >
> >> A while ago someone posted a url to a website that explained, step
> >> by step, how to update a port using cvs and a temporary directory
> >> for the updated port.  My google foo apparently isn't very good,
> >> because I can't seem to find it, and I forgot to bookmark it.
> >>
> >> Does anyone know what I'm referring to?  I really like that way of
> >> updating my ports.
> >
> > http://ionut.tetcu.info/FreeBSD//How-to-submit-a-diff.txt
> > Maybe this one?
> 
> Yes!  That was it.  And thank for the wonderful resource.

Glad to be of service :) It also makes my job as a committer easier.

Back before I was a committer, I was keeping my ports in my CVS, and I
was importing the version in ports a vendor branch with something like
this this scripts are really old, and un-maintained, but may they give
you some ideas) :


#!/bin/sh
##############
# $Tecnik: people/itetcu/ports/scripts/imPORT.sh,v 1.11 2008/03/27 12:27:25 itetcu Exp $
#

# $1 should be a module (port)
#

PC=`dirname $0`
echo ${PC}
. ${PC}/PORT.common

echo "====> Checking if you already have $1 in local CVS"

cvs -q ${L_CVS_ROOT} co modules || { MERR="Can't co modules" && merror; }
grep "^$1" modules/modules && STATUS="Import" || STATUS="Initial import"
echo "==> ${STATUS}"

echo "====> Getting $1 from FPT repo"
cvs -q ${R_CVS_ROOT} co $1 || { MERR="Can't co port from FPT" && merror; }
# check for included files
DEPD=$1 && expdep

# get category and PORT* and construct CVS-safe string from them
cd $1

CATEGORY=`make -V CATEGORIES | cut -d' ' -f1`
[ -z ${CATEGORY} ] && { MERR="Can't get teh CATEGORY; problem in Makefile ?" && merror; }
PORTVERSION=`make -V PORTVERSION`
PRT_V_T=`echo ${PORTVERSION} | sed 's/\./_/g`
grep -q '^PORTREVISION' Makefile && \
        PORTREVISION=`make -V PORTREVISION` && PRT_R="__${PORTREVISION}"
grep -q '^PORTEPOCH' Makefile && \
        PORTEPOCH=`make -V PORTEPOCH` && PRT_E=",${PORTEPOCH}" && \
                                        PRT_E_T="-${PORTEPOCH}"

CMT_MSG="${STATUS} from FPT of ${CATEGORY}/$1: $1-${PORTVERSION}${PRT_R}${PRT_E}"
REPO="ports/${CATEGORY}/$1"
REL_TAG="$1-${PRT_V_T}${PRT_R}${PRT_E_T}"
echo "====> ${CMT_MSG}, with tag: ${REL_TAG}"
read -p "Go on [y/n] ?" GOON
if [ "x${GOON}" = "xy" ]; then
        cvs ${L_CVS_ROOT} import -m "${CMT_MSG}" ${REPO} FPT ${REL_TAG} || exit 1
else    exit 1
fi

cd ../

# If doing an initial import we have to add the module and the PRlog
if [ "x${STATUS}" != "xImport" ]; then
        # add the module and invoke user's editor to sort and ci
        echo "$1 ${REPO}" >> modules/modules
        ${EDITOR} modules/modules
        cvs -q ${L_CVS_ROOT} ci -m "$1 --> ${REPO}" modules/modules
        cvs release -d modules
        # Add PRlog file; for this to work:
        #  the dir should be like: people/USER/ports/PRlogs/
        # and local user should match cvs user
        PRlog_DIR="people/`id -un`/ports/PRlogs"
        cvs -q ${L_CVS_ROOT} co ${PRlog_DIR}
        cd ${PRlog_DIR}
        touch $1
        cvs -q ${L_CVS_ROOT} add $1
        cvs -q ${L_CVS_ROOT} ci  -m "Add PRlog file for $1" $1
        cd ../../../../
        cvs -q ${L_CVS_ROOT} release -d ${PRlog_DIR}
fi
cd /tmp
rm -r `dirname ${MTMP}`



 > m tmp/TCVS/people/itetcu/ports/scripts/PORT.common
merror () {
        echo "====> ${MERR}"
        echo "====> Tmp dir: ${MTMP}"
        exit 1
}

# checks and defaults
[ $# -eq 1 ] || exit 1

#if [ "x${HOST}" = "xit.buh.tecnik93.com" ]; then
#       L_CVS_ROOT="-d /home/ncvs"
#else
        export CVS_RSH=ssh
        L_CVS_ROOT="-z 9 -d `id -un`@cvs.tecnik93.com:/home/ncvs"
#fi
R_CVS_ROOT="-z 9 -d itetcu at pcvs.FreeBSD.org:/home/pcvs/"

# our tmp dir
mkdir -p /tmp/CVS/$1/
MTMP=`mktemp -d /tmp/CVS/$1/$1.XXX` || exit 1
#[ -e "/tmp/CVS/$1" ] && MERR="/tmp/CVS/$1 exists, exiting ..." && merror
#mkdir -p /tmp/CVS/$1
echo "tmp dir: ${MTMP}"
cd ${MTMP}

# check to see if this module's Makefile includes something from an other
#  if yes export that module also so the relative path is right
expdep () {
pwd
#echo ${DEPD}
DEP_MODS=`egrep '^\.include' ${DEPD}/Makefile | grep -v "bsd.port" | sed 's,.include "${.CURDIR}/../../,,; s/"//'`
echo ${DEP_MODS}
if [ -n ${DEP_MODS} ]; then
        for dep_mod in ${DEP_MODS}; do
#               DEP_MOD_DIR=`echo ${dep_mod} | sed -E 's,/[a-zA-Z0-9_.-]+$,,'`
                DEP_MOD_DIR=`dirname ${dep_mod}`
                mkdir -p `dirname ${MTMP}`/`dirname ${DEP_MOD_DIR}`
#               cvs -q ${L_CVS_ROOT} ex -Dnow -d `dirname ${MTMP}`/`dirname ${dep_mod}` ports/${dep_mod}
                _O_PWD=`pwd`
#               cd `dirname ${MTMP}`/`dirname ${DEP_MOD_DIR}` && \
                cd ${MTMP}/${DEP_MOD_DIR} .. && \
                        cvs -q ${L_CVS_ROOT} ex -Dnow -d `basename ${DEP_MOD_DIR}` ports/${dep_mod} || \
                        (MERR="Could not export ${dep_mod}" && merror)
                cd ${_O_PWD}
        pwd
        done
fi
}


 > m tmp/TCVS/people/itetcu/ports/scripts/newPR.sh
#!/bin/sh
##############
# $Tecnik: people/itetcu/ports/scripts/newPR.sh,v 1.30 2006/04/25 14:13:27 itetcu Exp $
#

# $1 should be a module (port)
#

clean_up() {
        cd /tmp/CVS
        rm -r ${MTMP}
        exit 1
}

PC=`dirname $0`
if [ "x${PC}" = "x." ]; then
PC=`pwd`/
fi
echo ${PC}
. ${PC}/PORT.common

# compairing the tip of local vendor branch with FPT cvs
#
echo "==> Checking $1 is up-to-date in local vendor branch"

echo "====> Exporting local vendor branch of $1"
cvs -q ${L_CVS_ROOT} ex -d $1_local -rFPT $1 || exit 1
echo "====> Exporting FPT $1"
cvs -q ${R_CVS_ROOT} ex -d $1_FPT -Dnow $1 || exit 1
cvs -q ${R_CVS_ROOT} co -d $1_FPT.co -Dnow $1 || exit 1

echo "===> Checking local vendor branch against FPT...."
if diff -urN -I '^...Tecnik: ports/.* itetcu Exp .'  $1_local $1_FPT; then
        echo "===> All OK, local vendor branch and FPT are the same"
else
        echo "===> Some changes exists, you need to import from FPT first"
        exit 1
fi

### get old pkg version
DEPD=$1_FPT && expdep
cd $1_FPT && \
        PKGNAME_O=`make -VPKGNAME` && \
        PKGVER_O=`make -VPKGNAME | sed "s/$1-//"` && \
cd ../
[ -z ${PKGVER_O} ] && MERR="problem in old Makefile ?" && merror

echo '====> Tagging "FOR_PR"'
cvs ${L_CVS_ROOT} rtag -rHEAD -F "FOR_PR" $1 || (MERR="Can't rtag" && merror)

echo "====> Exporting HEAD of $1"
cvs ${L_CVS_ROOT} ex -rHEAD $1 || (MERR="Can't export" && merror)

### get current pkg version
DEPD=$1 && expdep
cd $1
PKGVER=`make -VPKGNAME | sed "s/$1-//"`
[ -z ${PKGVER} ] && MERR="problem in Makefile ?" && merror
if [ "x${PKGVER_O}" = "x${PKGVER}" ]; then
        DIFF="/home/itetcu/$1.diff"
else
        DIFF="/home/itetcu/${PKGNAME_O}_to_${PKGVER}.diff"
fi
echo; echo "--------------------  PORTLINT -C  -----------------------"; echo;
portlint -C
echo; echo "--------------------  make describe ---------------------------"; echo;
make describe
echo; echo "---------------------------------------------------------------"; echo;
read -p "Go on [y/n] ?" GOON
if [ "x${GOON}" != "xy" ]; then
        clean_up
fi
cd ../

echo "====> Exporting diff in ${DIFF}"
#diff -urN $1_FPT $1 > ${DIFF}
cp -R $1/* $1_FPT.co/
cd $1_FPT.co/
cvs -q ${R_CVS_ROOT} diff -uN > ${DIFF}
cd ../

${PC}/updlogs.sh $1 ${PKGVER}
sh ${PC}/upddiff.sh $1 ${DIFF}
#sh ${PC}/upddiff.sh $1 ${DIFF}.cvs

echo "====> Please enter PR description"
read -p "Go on [y/n] ?" GOON
if [ "x${GOON}" != "xy" ]; then
        clean_up
fi

cvs ${L_CVS_ROOT} co -d $1_PRlog people/itetcu/ports/PRlogs/$1
ee $1_PRlog/$1
cvs ${L_CVS_ROOT} ci -m"`cat $1_PRlog/$1`" $1_PRlog/$1
cat $1_PRlog/$1
#rm -r $1

gtk-send-pr -m -a ${DIFF}




-- 
IOnut - Un^d^dregistered ;) FreeBSD "user"
  "Intellectual Property" is   nowhere near as valuable   as "Intellect"
FreeBSD committer -> itetcu at FreeBSD.org, PGP Key ID 057E9F8B493A297B
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-ports/attachments/20110126/531185a0/signature.pgp


More information about the freebsd-ports mailing list