Keep compile options through upgrade

Parv parv at pair.com
Sun Jan 30 15:18:55 PST 2005


in message <200501280034.13921.olivier.certner at 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

--



More information about the freebsd-questions mailing list