Re: sysupgrade(8) and http_proxy

2019-11-05 Thread Steffen Nurpmeso
trondd wrote in <20191105013833.cy2_d%tro...@kagu-tsuchi.com>:
 |Steffen Nurpmeso  wrote:
 |> trondd wrote in <49f29107642e86c17283b0582a9f09f4.squir...@mail.kagu-tsu\
 |> chi.com>:
 |>|On Sun, November 3, 2019 12:02 pm, trondd wrote:
 |>|> On Sun, November 3, 2019 6:27 am, Florian Obser wrote:
 |>|>> On Sun, Nov 03, 2019 at 12:21:59PM +0100, Antoine Jacoutot wrote:
 |>|>>> On Sun, Nov 03, 2019 at 12:16:56PM +0100, Florian Obser wrote:
 |>  ...
 |>|I've tested the diff and it works as expected in my environment.  I don't
 |>|need a username and password for proxy access but it populates the
 |>|rc.firsttime file fine.
 |>|
 |>|The quote() function is actually pretty simple.
 ...
 |> I felt a bit undecided from your first mail on, maybe also because
 |> of your mailer, but wanted to post the all-compatible all-shell
 |> quote of and from Robert Elz here.
 ...
 |> Of course, if in install.sub there is already your quote function,
 |> that surely is preferred.
 ...
 |To clarify, it's not my quote function.  It's been in install.sub since
 |2010 [0] and was used when http_proxy was added there [1].  I figured it
 |was a good idea so pulled it in for sysupgrade as well.
 |
 |[0] http://cvsweb.openbsd.org/src/distrib/miniroot/install.sub?rev=1.628\
 |&content-type=text/x-cvsweb-markup
 |[1] http://cvsweb.openbsd.org/src/distrib/miniroot/install.sub?rev=1.105\
 |8&content-type=text/x-cvsweb-markup

Ok!

--steffen
|
|Der Kragenbaer,The moon bear,
|der holt sich munter   he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)



Re: sysupgrade(8) and http_proxy

2019-11-04 Thread trondd
Steffen Nurpmeso  wrote:

> trondd wrote in <49f29107642e86c17283b0582a9f09f4.squir...@mail.kagu-tsu\
> chi.com>:
>  |On Sun, November 3, 2019 12:02 pm, trondd wrote:
>  |> On Sun, November 3, 2019 6:27 am, Florian Obser wrote:
>  |>> On Sun, Nov 03, 2019 at 12:21:59PM +0100, Antoine Jacoutot wrote:
>  |>>> On Sun, Nov 03, 2019 at 12:16:56PM +0100, Florian Obser wrote:
>  ...
>  |I've tested the diff and it works as expected in my environment.  I don't
>  |need a username and password for proxy access but it populates the
>  |rc.firsttime file fine.
>  |
>  |The quote() function is actually pretty simple.
>  |
>  |quote() (
>  |# Since this is a subshell we won't pollute the calling namespace.
>  |for _a; do
>  |# alias string to Q, does escaping and quoting
>  |alias Q=$_a;
>  |# set variable back to value of alias
>  |_a=$(alias Q);
>  |# print variable, chopping off alias definition
>  |#   no newline, don't substitute the escape sequences
>  |#   we made above
>  |print -rn -- " ${_a#Q=}"
>  |done | sed '1s/ //'
>  |echo
>  |)
> 
> I felt a bit undecided from your first mail on, maybe also because
> of your mailer, but wanted to post the all-compatible all-shell
> quote of and from Robert Elz here.
> 
>   #@ Round trip quote strings in POSIX shell.  E.g.,
>   #@set -- x 'a \ b' "foo'" "\\'b\\a\\r\\" Aä
>   #@printf "%s: <%s><%s><%s><%s><%s>\n" "$#" "${1}" "${2}" "${3}" "$4" 
> "$5"
>   #@saved_parameters=`quote_rndtrip "$@"`
>   #@eval "set -- $saved_parameters"
>   #@printf "%s: <%s><%s><%s><%s><%s>\n" "$#" "${1}" "${2}" "${3}" "$4" 
> "$5"
>   #
>   # 2017 Robert Elz (kre).
> 
> ...
> 
>   # Though slower use a subshell version instead of properly restoring $IFS
>   # and flags, as elder shells may not be able to properly restore flags via
>   # "set +o" as later standardized in POSIX, and it seems overkill to handle
>   # all possible forms of output "set +o" may or may not actually generate.
>   quote__rndtrip() (
>  case "$1" in
>  *\'*) ;;
>  *) printf "'%s'" "$1"; return 0;;
>  esac
>  a="$1" s= e=
>  while case "$a" in
> \'*)  a=${a#?}; s="${s}'";;
> *\')  a=${a%?}; e="${e}'";;
> '')   printf "${s}${e}"; exit 0;;
> *) false;;
> esac
>  do
> continue
>  done
>  IFS=\'
>  set -f
>  set -- $a
>  r="${1}"
>   shift
>  for a
>  do
> r="${r}'\\''${a}"
>  done
>  printf "${s}'%s'${e}" "${r}"
>  exit 0
>   )
> 
>   quote_rndtrip() (
>  j=
>  for i
>  do
> [ -n "$j" ] && printf ' '
> j=' '
> quote__rndtrip "$i"
>  done
>   )
> 
>   quote_string() (
>  j=
>  for i
>  do
> [ -n "$j" ] && printf '\\ '
> j=' '
> quote__rndtrip "$i"
>  done
>   )
> 
> 
>  |$ export "test=fancy ' stuff #and not a comment"
>  |$ ./quote.ksh
>  |$ cat test.out
>  |
>  |export 'http_proxy=fancy '\'' stuff #and not a comment'
>  |
>  |$ export "test=even
>  |> this works #"
>  |$ ./quote.ksh
>  |$ cat test.out
>  |
>  |export 'http_proxy=even
>  |this works #'
> 
> Of course, if in install.sub there is already your quote function,
> that surely is preferred.
> 
> Good night,
> 
> --steffen
> |
> |Der Kragenbaer,The moon bear,
> |der holt sich munter   he cheerfully and one by one
> |einen nach dem anderen runter  wa.ks himself off
> |(By Robert Gernhardt)

To clarify, it's not my quote function.  It's been in install.sub since
2010 [0] and was used when http_proxy was added there [1].  I figured it
was a good idea so pulled it in for sysupgrade as well.

[0] 
http://cvsweb.openbsd.org/src/distrib/miniroot/install.sub?rev=1.628&content-type=text/x-cvsweb-markup
[1] 
http://cvsweb.openbsd.org/src/distrib/miniroot/install.sub?rev=1.1058&content-type=text/x-cvsweb-markup

Tim.



Re: sysupgrade(8) and http_proxy

2019-11-04 Thread Steffen Nurpmeso
trondd wrote in <49f29107642e86c17283b0582a9f09f4.squir...@mail.kagu-tsu\
chi.com>:
 |On Sun, November 3, 2019 12:02 pm, trondd wrote:
 |> On Sun, November 3, 2019 6:27 am, Florian Obser wrote:
 |>> On Sun, Nov 03, 2019 at 12:21:59PM +0100, Antoine Jacoutot wrote:
 |>>> On Sun, Nov 03, 2019 at 12:16:56PM +0100, Florian Obser wrote:
 ...
 |I've tested the diff and it works as expected in my environment.  I don't
 |need a username and password for proxy access but it populates the
 |rc.firsttime file fine.
 |
 |The quote() function is actually pretty simple.
 |
 |quote() (
 |# Since this is a subshell we won't pollute the calling namespace.
 |for _a; do
 |# alias string to Q, does escaping and quoting
 |alias Q=$_a;
 |# set variable back to value of alias
 |_a=$(alias Q);
 |# print variable, chopping off alias definition
 |#   no newline, don't substitute the escape sequences
 |#   we made above
 |print -rn -- " ${_a#Q=}"
 |done | sed '1s/ //'
 |echo
 |)

I felt a bit undecided from your first mail on, maybe also because
of your mailer, but wanted to post the all-compatible all-shell
quote of and from Robert Elz here.

  #@ Round trip quote strings in POSIX shell.  E.g.,
  #@set -- x 'a \ b' "foo'" "\\'b\\a\\r\\" Aä
  #@printf "%s: <%s><%s><%s><%s><%s>\n" "$#" "${1}" "${2}" "${3}" "$4" "$5"
  #@saved_parameters=`quote_rndtrip "$@"`
  #@eval "set -- $saved_parameters"
  #@printf "%s: <%s><%s><%s><%s><%s>\n" "$#" "${1}" "${2}" "${3}" "$4" "$5"
  #
  # 2017 Robert Elz (kre).

...

  # Though slower use a subshell version instead of properly restoring $IFS
  # and flags, as elder shells may not be able to properly restore flags via
  # "set +o" as later standardized in POSIX, and it seems overkill to handle
  # all possible forms of output "set +o" may or may not actually generate.
  quote__rndtrip() (
 case "$1" in
 *\'*) ;;
 *) printf "'%s'" "$1"; return 0;;
 esac
 a="$1" s= e=
 while case "$a" in
\'*)  a=${a#?}; s="${s}'";;
*\')  a=${a%?}; e="${e}'";;
'')   printf "${s}${e}"; exit 0;;
*) false;;
esac
 do
continue
 done
 IFS=\'
 set -f
 set -- $a
 r="${1}"
  shift
 for a
 do
r="${r}'\\''${a}"
 done
 printf "${s}'%s'${e}" "${r}"
 exit 0
  )

  quote_rndtrip() (
 j=
 for i
 do
[ -n "$j" ] && printf ' '
j=' '
quote__rndtrip "$i"
 done
  )

  quote_string() (
 j=
 for i
 do
[ -n "$j" ] && printf '\\ '
j=' '
quote__rndtrip "$i"
 done
  )


 |$ export "test=fancy ' stuff #and not a comment"
 |$ ./quote.ksh
 |$ cat test.out
 |
 |export 'http_proxy=fancy '\'' stuff #and not a comment'
 |
 |$ export "test=even
 |> this works #"
 |$ ./quote.ksh
 |$ cat test.out
 |
 |export 'http_proxy=even
 |this works #'

Of course, if in install.sub there is already your quote function,
that surely is preferred.

Good night,

--steffen
|
|Der Kragenbaer,The moon bear,
|der holt sich munter   he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)



Re: sysupgrade(8) and http_proxy

2019-11-04 Thread trondd
On Sun, November 3, 2019 12:02 pm, trondd wrote:
> On Sun, November 3, 2019 6:27 am, Florian Obser wrote:
>> On Sun, Nov 03, 2019 at 12:21:59PM +0100, Antoine Jacoutot wrote:
>>> On Sun, Nov 03, 2019 at 12:16:56PM +0100, Florian Obser wrote:
>>> > I like it, if someone who is fluent in ksh line noise could please
>>> > verify and commit, that would be awesome, thanks.
>>>
>>> Why not let the installer handle this? It already has code for it.
>>> sysupgrade ony needs to create the proper auto_upgrade.conf containing
>>> the
>>> answer to the proxy question.
>>
>> Right, that is better.
>>
>
> Unless I'm missing something, the installer only asks for a proxy when you
> select 'http' for the sets for a network install which sysupgrade is
> designed to not do.
>
> This would mean changing the installer to ask for a proxy regardless of
> install method.  Which could make sense since the execution of tools in
> rc.firsttime requires internet access regardless of set installation
> method.
>
> I don't know that much of a change is desired, though.
>
> Tim.
>

I've tested the diff and it works as expected in my environment.  I don't
need a username and password for proxy access but it populates the
rc.firsttime file fine.

The quote() function is actually pretty simple.

quote() (
# Since this is a subshell we won't pollute the calling namespace.
for _a; do
# alias string to Q, does escaping and quoting
alias Q=$_a;
# set variable back to value of alias
_a=$(alias Q);
# print variable, chopping off alias definition
#   no newline, don't substitute the escape sequences
#   we made above
print -rn -- " ${_a#Q=}"
done | sed '1s/ //'
echo
)

$ export "test=fancy ' stuff #and not a comment"
$ ./quote.ksh
$ cat test.out

export 'http_proxy=fancy '\'' stuff #and not a comment'

$ export "test=even
> this works #"
$ ./quote.ksh
$ cat test.out

export 'http_proxy=even
this works #'


Tim.


>>>
>>>
>>> >
>>> > On Fri, Nov 01, 2019 at 09:37:04PM -0400, trondd wrote:
>>> > > Anthony Coulter  wrote:
>>> > >
>>> > > > Hello @tech,
>>> > > >
>>> > > > When I manually upgrade OpenBSD using bsd.rd, I have to set
>>> http_proxy
>>> > > > to fetch the file sets. When I reboot after installing, fw_update
>>> > > > succeeds because theinstall script was clever enough to export
>>> > > > http_proxy in /etc/rc.firsttime.
>>> > > >
>>> > > > Unfortunately sysupgrade(8) does not remember that http_proxy was
>>> set
>>> > > > when it fetched the file sets, and so when I run sysupgrade I
>>> have
>>> to
>>> > > > either wait for fw_update to manually time out on first reboot,
>>> or
>>> kill
>>> > > > it manually with ^C.
>>> > > >
>>> > > > Adding the line:
>>> > > >
>>> > > > [ ${http_proxy} ] && echo "export http_proxy=${http_proxy}"
>>> >>/etc/rc.firsttime
>>> > > >
>>> > > > to a spot near the bottom of /usr/sbin/sysupgrade fixes my
>>> fw_update
>>> > > > problem, at least until the upgrade restores all of my files to
>>> their
>>> > > > stock defaults. Is this something we could integrate into the
>>> official
>>> > > > repository?
>>> > > >
>>> > > > Thanks and regards,
>>> > > > Anthony Coulter
>>> > >
>>> > > Here it is in patch form in case there is interest.  This also
>>> pulls
>>> in the
>>> > > quote function from install.sub to make sure a proxy username or
>>> password is
>>> > > quoted properly.  I haven't tested this since I could only use it
>>> at
>>> work.
>>> > >
>>> > > Tim.
>>> > >
>>> > >
>>> > > Index: sysupgrade.sh
>>> > > ===
>>> > > RCS file: /cvs/src/usr.sbin/sysupgrade/sysupgrade.sh,v
>>> > > retrieving revision 1.29
>>> > > diff -u -p -r1.29 sysupgrade.sh
>>> > > --- sysupgrade.sh   26 Oct 2019 04:04:20 -  1.29
>>> > > +++ sysupgrade.sh   2 Nov 2019 00:39:05 -
>>> > > @@ -73,6 +73,16 @@ rmel() {
>>> > > echo -n "$_c"
>>> > >  }
>>> > >
>>> > > +# Prints the supplied parameters properly escaped for future
>>> sh/ksh
>>> parsing.
>>> > > +# Quotes are added if needed, so you should not do that yourself.
>>> > > +quote() (
>>> > > +   # Since this is a subshell we won't pollute the calling
>>> namespace.
>>> > > +   for _a; do
>>> > > +   alias Q=$_a; _a=$(alias Q); print -rn -- " ${_a#Q=}"
>>> > > +   done | sed '1s/ //'
>>> > > +   echo
>>> > > +)
>>> > > +
>>> > >  RELEASE=false
>>> > >  SNAP=false
>>> > >  FORCE=false
>>> > > @@ -199,6 +209,9 @@ if ! ${KEEP}; then
>>> > >  rm -f /home/_sysupgrade/{${CLEAN}}
>>> > >  __EOT
>>> > >  fi
>>> > > +
>>> > > +[[ -n $http_proxy ]] &&
>>> > > +   quote export "http_proxy=$http_proxy" >>/etc/rc.firsttime
>>> > >
>>> > >  install -F -m 700 bsd.rd /bsd.upgrade
>>> > >  sync
>>> > >
>>> >
>>> > --
>>> > I'm not entirely sure you are real.
>>> >
>>>
>>> --
>>> Antoine
>>>
>>
>> --
>> I'm not

Re: sysupgrade(8) and http_proxy

2019-11-03 Thread trondd
On Sun, November 3, 2019 6:27 am, Florian Obser wrote:
> On Sun, Nov 03, 2019 at 12:21:59PM +0100, Antoine Jacoutot wrote:
>> On Sun, Nov 03, 2019 at 12:16:56PM +0100, Florian Obser wrote:
>> > I like it, if someone who is fluent in ksh line noise could please
>> > verify and commit, that would be awesome, thanks.
>>
>> Why not let the installer handle this? It already has code for it.
>> sysupgrade ony needs to create the proper auto_upgrade.conf containing
>> the
>> answer to the proxy question.
>
> Right, that is better.
>

Unless I'm missing something, the installer only asks for a proxy when you
select 'http' for the sets for a network install which sysupgrade is
designed to not do.

This would mean changing the installer to ask for a proxy regardless of
install method.  Which could make sense since the execution of tools in
rc.firsttime requires internet access regardless of set installation
method.

I don't know that much of a change is desired, though.

Tim.

>>
>>
>> >
>> > On Fri, Nov 01, 2019 at 09:37:04PM -0400, trondd wrote:
>> > > Anthony Coulter  wrote:
>> > >
>> > > > Hello @tech,
>> > > >
>> > > > When I manually upgrade OpenBSD using bsd.rd, I have to set
>> http_proxy
>> > > > to fetch the file sets. When I reboot after installing, fw_update
>> > > > succeeds because theinstall script was clever enough to export
>> > > > http_proxy in /etc/rc.firsttime.
>> > > >
>> > > > Unfortunately sysupgrade(8) does not remember that http_proxy was
>> set
>> > > > when it fetched the file sets, and so when I run sysupgrade I have
>> to
>> > > > either wait for fw_update to manually time out on first reboot, or
>> kill
>> > > > it manually with ^C.
>> > > >
>> > > > Adding the line:
>> > > >
>> > > > [ ${http_proxy} ] && echo "export http_proxy=${http_proxy}"
>> >>/etc/rc.firsttime
>> > > >
>> > > > to a spot near the bottom of /usr/sbin/sysupgrade fixes my
>> fw_update
>> > > > problem, at least until the upgrade restores all of my files to
>> their
>> > > > stock defaults. Is this something we could integrate into the
>> official
>> > > > repository?
>> > > >
>> > > > Thanks and regards,
>> > > > Anthony Coulter
>> > >
>> > > Here it is in patch form in case there is interest.  This also pulls
>> in the
>> > > quote function from install.sub to make sure a proxy username or
>> password is
>> > > quoted properly.  I haven't tested this since I could only use it at
>> work.
>> > >
>> > > Tim.
>> > >
>> > >
>> > > Index: sysupgrade.sh
>> > > ===
>> > > RCS file: /cvs/src/usr.sbin/sysupgrade/sysupgrade.sh,v
>> > > retrieving revision 1.29
>> > > diff -u -p -r1.29 sysupgrade.sh
>> > > --- sysupgrade.sh26 Oct 2019 04:04:20 -  1.29
>> > > +++ sysupgrade.sh2 Nov 2019 00:39:05 -
>> > > @@ -73,6 +73,16 @@ rmel() {
>> > >  echo -n "$_c"
>> > >  }
>> > >
>> > > +# Prints the supplied parameters properly escaped for future sh/ksh
>> parsing.
>> > > +# Quotes are added if needed, so you should not do that yourself.
>> > > +quote() (
>> > > +# Since this is a subshell we won't pollute the calling 
>> > > namespace.
>> > > +for _a; do
>> > > +alias Q=$_a; _a=$(alias Q); print -rn -- " ${_a#Q=}"
>> > > +done | sed '1s/ //'
>> > > +echo
>> > > +)
>> > > +
>> > >  RELEASE=false
>> > >  SNAP=false
>> > >  FORCE=false
>> > > @@ -199,6 +209,9 @@ if ! ${KEEP}; then
>> > >  rm -f /home/_sysupgrade/{${CLEAN}}
>> > >  __EOT
>> > >  fi
>> > > +
>> > > +[[ -n $http_proxy ]] &&
>> > > +quote export "http_proxy=$http_proxy" >>/etc/rc.firsttime
>> > >
>> > >  install -F -m 700 bsd.rd /bsd.upgrade
>> > >  sync
>> > >
>> >
>> > --
>> > I'm not entirely sure you are real.
>> >
>>
>> --
>> Antoine
>>
>
> --
> I'm not entirely sure you are real.
>




Re: sysupgrade(8) and http_proxy

2019-11-03 Thread Florian Obser
On Sun, Nov 03, 2019 at 12:21:59PM +0100, Antoine Jacoutot wrote:
> On Sun, Nov 03, 2019 at 12:16:56PM +0100, Florian Obser wrote:
> > I like it, if someone who is fluent in ksh line noise could please
> > verify and commit, that would be awesome, thanks.
> 
> Why not let the installer handle this? It already has code for it.
> sysupgrade ony needs to create the proper auto_upgrade.conf containing the
> answer to the proxy question.

Right, that is better.

> 
> 
> > 
> > On Fri, Nov 01, 2019 at 09:37:04PM -0400, trondd wrote:
> > > Anthony Coulter  wrote:
> > > 
> > > > Hello @tech,
> > > > 
> > > > When I manually upgrade OpenBSD using bsd.rd, I have to set http_proxy
> > > > to fetch the file sets. When I reboot after installing, fw_update
> > > > succeeds because theinstall script was clever enough to export
> > > > http_proxy in /etc/rc.firsttime.
> > > > 
> > > > Unfortunately sysupgrade(8) does not remember that http_proxy was set
> > > > when it fetched the file sets, and so when I run sysupgrade I have to
> > > > either wait for fw_update to manually time out on first reboot, or kill
> > > > it manually with ^C.
> > > > 
> > > > Adding the line:
> > > > 
> > > > [ ${http_proxy} ] && echo "export http_proxy=${http_proxy}" 
> > > > >>/etc/rc.firsttime
> > > > 
> > > > to a spot near the bottom of /usr/sbin/sysupgrade fixes my fw_update
> > > > problem, at least until the upgrade restores all of my files to their
> > > > stock defaults. Is this something we could integrate into the official
> > > > repository?
> > > > 
> > > > Thanks and regards,
> > > > Anthony Coulter
> > > 
> > > Here it is in patch form in case there is interest.  This also pulls in 
> > > the
> > > quote function from install.sub to make sure a proxy username or password 
> > > is
> > > quoted properly.  I haven't tested this since I could only use it at work.
> > > 
> > > Tim.
> > > 
> > > 
> > > Index: sysupgrade.sh
> > > ===
> > > RCS file: /cvs/src/usr.sbin/sysupgrade/sysupgrade.sh,v
> > > retrieving revision 1.29
> > > diff -u -p -r1.29 sysupgrade.sh
> > > --- sysupgrade.sh 26 Oct 2019 04:04:20 -  1.29
> > > +++ sysupgrade.sh 2 Nov 2019 00:39:05 -
> > > @@ -73,6 +73,16 @@ rmel() {
> > >   echo -n "$_c"
> > >  }
> > >  
> > > +# Prints the supplied parameters properly escaped for future sh/ksh 
> > > parsing.
> > > +# Quotes are added if needed, so you should not do that yourself.
> > > +quote() (
> > > + # Since this is a subshell we won't pollute the calling namespace.
> > > + for _a; do
> > > + alias Q=$_a; _a=$(alias Q); print -rn -- " ${_a#Q=}"
> > > + done | sed '1s/ //'
> > > + echo
> > > +)
> > > +
> > >  RELEASE=false
> > >  SNAP=false
> > >  FORCE=false
> > > @@ -199,6 +209,9 @@ if ! ${KEEP}; then
> > >  rm -f /home/_sysupgrade/{${CLEAN}}
> > >  __EOT
> > >  fi
> > > +
> > > +[[ -n $http_proxy ]] &&
> > > + quote export "http_proxy=$http_proxy" >>/etc/rc.firsttime
> > >  
> > >  install -F -m 700 bsd.rd /bsd.upgrade
> > >  sync
> > > 
> > 
> > -- 
> > I'm not entirely sure you are real.
> > 
> 
> -- 
> Antoine
> 

-- 
I'm not entirely sure you are real.



Re: sysupgrade(8) and http_proxy

2019-11-03 Thread Antoine Jacoutot
On Sun, Nov 03, 2019 at 12:16:56PM +0100, Florian Obser wrote:
> I like it, if someone who is fluent in ksh line noise could please
> verify and commit, that would be awesome, thanks.

Why not let the installer handle this? It already has code for it.
sysupgrade ony needs to create the proper auto_upgrade.conf containing the
answer to the proxy question.


> 
> On Fri, Nov 01, 2019 at 09:37:04PM -0400, trondd wrote:
> > Anthony Coulter  wrote:
> > 
> > > Hello @tech,
> > > 
> > > When I manually upgrade OpenBSD using bsd.rd, I have to set http_proxy
> > > to fetch the file sets. When I reboot after installing, fw_update
> > > succeeds because theinstall script was clever enough to export
> > > http_proxy in /etc/rc.firsttime.
> > > 
> > > Unfortunately sysupgrade(8) does not remember that http_proxy was set
> > > when it fetched the file sets, and so when I run sysupgrade I have to
> > > either wait for fw_update to manually time out on first reboot, or kill
> > > it manually with ^C.
> > > 
> > > Adding the line:
> > > 
> > > [ ${http_proxy} ] && echo "export http_proxy=${http_proxy}" 
> > > >>/etc/rc.firsttime
> > > 
> > > to a spot near the bottom of /usr/sbin/sysupgrade fixes my fw_update
> > > problem, at least until the upgrade restores all of my files to their
> > > stock defaults. Is this something we could integrate into the official
> > > repository?
> > > 
> > > Thanks and regards,
> > > Anthony Coulter
> > 
> > Here it is in patch form in case there is interest.  This also pulls in the
> > quote function from install.sub to make sure a proxy username or password is
> > quoted properly.  I haven't tested this since I could only use it at work.
> > 
> > Tim.
> > 
> > 
> > Index: sysupgrade.sh
> > ===
> > RCS file: /cvs/src/usr.sbin/sysupgrade/sysupgrade.sh,v
> > retrieving revision 1.29
> > diff -u -p -r1.29 sysupgrade.sh
> > --- sysupgrade.sh   26 Oct 2019 04:04:20 -  1.29
> > +++ sysupgrade.sh   2 Nov 2019 00:39:05 -
> > @@ -73,6 +73,16 @@ rmel() {
> > echo -n "$_c"
> >  }
> >  
> > +# Prints the supplied parameters properly escaped for future sh/ksh 
> > parsing.
> > +# Quotes are added if needed, so you should not do that yourself.
> > +quote() (
> > +   # Since this is a subshell we won't pollute the calling namespace.
> > +   for _a; do
> > +   alias Q=$_a; _a=$(alias Q); print -rn -- " ${_a#Q=}"
> > +   done | sed '1s/ //'
> > +   echo
> > +)
> > +
> >  RELEASE=false
> >  SNAP=false
> >  FORCE=false
> > @@ -199,6 +209,9 @@ if ! ${KEEP}; then
> >  rm -f /home/_sysupgrade/{${CLEAN}}
> >  __EOT
> >  fi
> > +
> > +[[ -n $http_proxy ]] &&
> > +   quote export "http_proxy=$http_proxy" >>/etc/rc.firsttime
> >  
> >  install -F -m 700 bsd.rd /bsd.upgrade
> >  sync
> > 
> 
> -- 
> I'm not entirely sure you are real.
> 

-- 
Antoine



Re: sysupgrade(8) and http_proxy

2019-11-03 Thread Florian Obser
I like it, if someone who is fluent in ksh line noise could please
verify and commit, that would be awesome, thanks.

On Fri, Nov 01, 2019 at 09:37:04PM -0400, trondd wrote:
> Anthony Coulter  wrote:
> 
> > Hello @tech,
> > 
> > When I manually upgrade OpenBSD using bsd.rd, I have to set http_proxy
> > to fetch the file sets. When I reboot after installing, fw_update
> > succeeds because theinstall script was clever enough to export
> > http_proxy in /etc/rc.firsttime.
> > 
> > Unfortunately sysupgrade(8) does not remember that http_proxy was set
> > when it fetched the file sets, and so when I run sysupgrade I have to
> > either wait for fw_update to manually time out on first reboot, or kill
> > it manually with ^C.
> > 
> > Adding the line:
> > 
> > [ ${http_proxy} ] && echo "export http_proxy=${http_proxy}" 
> > >>/etc/rc.firsttime
> > 
> > to a spot near the bottom of /usr/sbin/sysupgrade fixes my fw_update
> > problem, at least until the upgrade restores all of my files to their
> > stock defaults. Is this something we could integrate into the official
> > repository?
> > 
> > Thanks and regards,
> > Anthony Coulter
> 
> Here it is in patch form in case there is interest.  This also pulls in the
> quote function from install.sub to make sure a proxy username or password is
> quoted properly.  I haven't tested this since I could only use it at work.
> 
> Tim.
> 
> 
> Index: sysupgrade.sh
> ===
> RCS file: /cvs/src/usr.sbin/sysupgrade/sysupgrade.sh,v
> retrieving revision 1.29
> diff -u -p -r1.29 sysupgrade.sh
> --- sysupgrade.sh 26 Oct 2019 04:04:20 -  1.29
> +++ sysupgrade.sh 2 Nov 2019 00:39:05 -
> @@ -73,6 +73,16 @@ rmel() {
>   echo -n "$_c"
>  }
>  
> +# Prints the supplied parameters properly escaped for future sh/ksh parsing.
> +# Quotes are added if needed, so you should not do that yourself.
> +quote() (
> + # Since this is a subshell we won't pollute the calling namespace.
> + for _a; do
> + alias Q=$_a; _a=$(alias Q); print -rn -- " ${_a#Q=}"
> + done | sed '1s/ //'
> + echo
> +)
> +
>  RELEASE=false
>  SNAP=false
>  FORCE=false
> @@ -199,6 +209,9 @@ if ! ${KEEP}; then
>  rm -f /home/_sysupgrade/{${CLEAN}}
>  __EOT
>  fi
> +
> +[[ -n $http_proxy ]] &&
> + quote export "http_proxy=$http_proxy" >>/etc/rc.firsttime
>  
>  install -F -m 700 bsd.rd /bsd.upgrade
>  sync
> 

-- 
I'm not entirely sure you are real.



Re: sysupgrade(8) and http_proxy

2019-11-01 Thread trondd
Anthony Coulter  wrote:

> Hello @tech,
> 
> When I manually upgrade OpenBSD using bsd.rd, I have to set http_proxy
> to fetch the file sets. When I reboot after installing, fw_update
> succeeds because theinstall script was clever enough to export
> http_proxy in /etc/rc.firsttime.
> 
> Unfortunately sysupgrade(8) does not remember that http_proxy was set
> when it fetched the file sets, and so when I run sysupgrade I have to
> either wait for fw_update to manually time out on first reboot, or kill
> it manually with ^C.
> 
> Adding the line:
> 
> [ ${http_proxy} ] && echo "export http_proxy=${http_proxy}" 
> >>/etc/rc.firsttime
> 
> to a spot near the bottom of /usr/sbin/sysupgrade fixes my fw_update
> problem, at least until the upgrade restores all of my files to their
> stock defaults. Is this something we could integrate into the official
> repository?
> 
> Thanks and regards,
> Anthony Coulter

Here it is in patch form in case there is interest.  This also pulls in the
quote function from install.sub to make sure a proxy username or password is
quoted properly.  I haven't tested this since I could only use it at work.

Tim.


Index: sysupgrade.sh
===
RCS file: /cvs/src/usr.sbin/sysupgrade/sysupgrade.sh,v
retrieving revision 1.29
diff -u -p -r1.29 sysupgrade.sh
--- sysupgrade.sh   26 Oct 2019 04:04:20 -  1.29
+++ sysupgrade.sh   2 Nov 2019 00:39:05 -
@@ -73,6 +73,16 @@ rmel() {
echo -n "$_c"
 }
 
+# Prints the supplied parameters properly escaped for future sh/ksh parsing.
+# Quotes are added if needed, so you should not do that yourself.
+quote() (
+   # Since this is a subshell we won't pollute the calling namespace.
+   for _a; do
+   alias Q=$_a; _a=$(alias Q); print -rn -- " ${_a#Q=}"
+   done | sed '1s/ //'
+   echo
+)
+
 RELEASE=false
 SNAP=false
 FORCE=false
@@ -199,6 +209,9 @@ if ! ${KEEP}; then
 rm -f /home/_sysupgrade/{${CLEAN}}
 __EOT
 fi
+
+[[ -n $http_proxy ]] &&
+   quote export "http_proxy=$http_proxy" >>/etc/rc.firsttime
 
 install -F -m 700 bsd.rd /bsd.upgrade
 sync



sysupgrade(8) and http_proxy

2019-11-01 Thread Anthony Coulter
Hello @tech,

When I manually upgrade OpenBSD using bsd.rd, I have to set http_proxy
to fetch the file sets. When I reboot after installing, fw_update
succeeds because theinstall script was clever enough to export
http_proxy in /etc/rc.firsttime.

Unfortunately sysupgrade(8) does not remember that http_proxy was set
when it fetched the file sets, and so when I run sysupgrade I have to
either wait for fw_update to manually time out on first reboot, or kill
it manually with ^C.

Adding the line:

[ ${http_proxy} ] && echo "export http_proxy=${http_proxy}" >>/etc/rc.firsttime

to a spot near the bottom of /usr/sbin/sysupgrade fixes my fw_update
problem, at least until the upgrade restores all of my files to their
stock defaults. Is this something we could integrate into the official
repository?

Thanks and regards,
Anthony Coulter