From owner-freebsd-questions@FreeBSD.ORG Sun Jan 30 23:18:54 2005 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CB8B816A4CE for ; Sun, 30 Jan 2005 23:18:54 +0000 (GMT) Received: from mta9.adelphia.net (mta9.adelphia.net [68.168.78.199]) by mx1.FreeBSD.org (Postfix) with ESMTP id 47F3143D1D for ; Sun, 30 Jan 2005 23:18:54 +0000 (GMT) (envelope-from parv@pair.com) Received: from default.chvlva.adelphia.net ([69.160.65.223]) by mta9.adelphia.netESMTP <20050130231853.BBXJ7046.mta9.adelphia.net@default.chvlva.adelphia.net>; Sun, 30 Jan 2005 18:18:53 -0500 Received: by default.chvlva.adelphia.net (Postfix, from userid 1000) id 03D7BB4FC; Sun, 30 Jan 2005 18:18:51 -0500 (EST) Date: Sun, 30 Jan 2005 18:18:51 -0500 From: Parv To: Olivier Certner Message-ID: <20050130231851.GA2311@holestein.holy.cow> Mail-Followup-To: Olivier Certner , freebsd-questions@freebsd.org References: <200501280034.13921.olivier.certner@free.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200501280034.13921.olivier.certner@free.fr> cc: freebsd-questions@freebsd.org Subject: Re: Keep compile options through upgrade X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Jan 2005 23:18:55 -0000 in message <200501280034.13921.olivier.certner@free.fr>, wrote Olivier Certner thusly... > > Is there an easy way to keep/retrieve the options last used to > compile a given port? This could be used with portupgrade to > upgrade to a newer version while retaining the previous build-time > configuration (of course this won't work if the options available > change). I created a shell script, to be run in port's directory, mainly to log the build messages during the port building/packaging. This later evolved to store/view the make command history. It handles most of the make target that i am personally concerned with. Next possible significant improvement would be the use of last used compile options. Currently, i am satisfied w/ 2.5-step manual process: retrieve the last used options, copy; run the script w/ the copied text. Yes, i know about all the wonderful things that the portupgrade can do. Please don't repeat to me. Script follows ... #!/bin/sh -f ## Author: Parv, parv underscore at yahoo dot com ## Modified: Jan 07 2005 ## ## License: Free to use as you please w/ proper credit given. ## Use at your own risk. All responsibility for potential ## damage, loss, etc. is disclaimed. ## ## Purpose: ## - To log the data generated by various commands. ## - To record the current command and retrieve it later # # See also: portupgrade, portmanager # Current port directory dir=$( pwd ) # Generate log file name date_=$( date '+%b-%d_%H%M-%S' ) log="${dir}/log.${date_}" # Generate part of file name for storing command history cmd_suffix=$( printf "$dir" \ | sed -E \ -e 's!^/[-_.[:alnum:]]+/ports[^/]+!!' \ -e 's!/$!!' \ -e 's!/!.!g' \ -e 's!^[^a-zA-Z0-9]!!g' \ ) # File in which to save command history cmd="/path/to/cmd.${cmd_suffix}" show() { # Save/Show command command="make $*" printf "cd %0s && ${command}\n\n" "$dir" >> "$cmd" cat "$cmd" printf "${command}\n#\n" > "$log" } make_rc= make_run() { show "$*" # Execute the target; on failure show last few lines of the log cd "$dir" \ && { nice -n 10 make $@ >> "$log" 2>&1 make_rc=$? } [ $make_rc -ne 0 ] && tail -n 60 "$log" # Try to compress, don't care for errors bzip2 -9 "$log" 2>/dev/null & } target= case $1 in cmd | hist | past | check ) tail -n 4 "${cmd}" ; exit ;; dist*cl* | distclean ) shift; target=distclean ;; clea* | clean ) shift; target=clean ;; get | fetch ) shift; target=fetch ;; expan* | extract ) shift; target=extract ;; conf* | configure ) shift; target=configure ;; dep* | depend ) shift; target=depend ;; build ) shift; target=build ;; install ) shift; target=install ;; pkg | package ) shift; target=package ;; pkgre* | package-recur* ) shift; target=package-recursive ;; dein* | deinstall ) shift; target=deinstall ;; rein* | reinstall ) shift; target=reinstall ;; * ) printf "%s"<<_TARGET_ >&2 Please specify one of the following supported targets .. distclean clean fetch extract configure depend build package package-recursive deinstall reinstall _TARGET_ exit 1 ;; esac # Set the most often used option Batch="" Batch="-DIS_INTERACTIVE" Batch="-DBATCH" make_run "$target" $Batch $@ printf "... done [%s] %s in %s\n" ${make_rc} ${target} "${dir}" >&2 printf "\a" - Parv --