Bug 188263 - [PATCH] devel/avrdude: properly handle config file
Summary: [PATCH] devel/avrdude: properly handle config file
Status: Closed Not Accepted
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Joerg Wunsch
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-04 18:20 UTC by Dmitry Marakasov
Modified: 2016-08-26 15:00 UTC (History)
2 users (show)

See Also:


Attachments
avrdude-5.11.patch (1.04 KB, patch)
2014-04-04 18:20 UTC, Dmitry Marakasov
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitry Marakasov 2014-04-04 18:20:01 UTC
- Properly handle config file and do not override user settings
- While here, use shorter MASTER_SITES version
- Bump PORTREVISION

Port maintainer (joerg@FreeBSD.org) is cc'd.

Generated with FreeBSD Port Tools 1.00.2014.03.23 (mode: change, diff: SVN)
Comment 1 Edwin Groothuis freebsd_committer 2014-04-04 18:20:06 UTC
Responsible Changed
From-To: freebsd-ports-bugs->joerg

Over to maintainer (via the GNATS Auto Assign Tool)
Comment 2 Joerg Wunsch 2014-04-04 18:27:04 UTC
As Dmitry Marakasov wrote:

> +@unexec if cmp -s %D/etc/avrdude.conf.dist %D/etc/avrdude.conf; then rm -f %D/etc/avrdude.conf; fi
> +etc/avrdude.conf.dist
> +@exec if [ ! -f %B/avrdude.conf ]; then cp -p %D/%F %B/avrdude.conf; fi

I disagree.

avrdude.conf is not supposed to have user-servicable parts inside.  It
is supposed to be in AVRDUDE's domain, so it can be changed whenever
the config file parser changes (which e.g. will happen with the
upgrade to the next major version, 6.x).

The user-extensible part is ~/.avrduderc.

If someone wishes to have a site-specific extension file, we could
probably arrange that (like, ${prefix}/etc/avrdude.conf.local), but
then, please request that to the AVRDUDE project.
-- 
cheers, Joerg               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/
Never trust an operating system you don't have sources for. ;-)
Comment 3 Dmitry Marakasov 2014-04-05 01:34:50 UTC
* Joerg Wunsch (j@uriah.heep.sax.de) wrote:

> > +@unexec if cmp -s %D/etc/avrdude.conf.dist %D/etc/avrdude.conf; then rm -f %D/etc/avrdude.conf; fi
> > +etc/avrdude.conf.dist
> > +@exec if [ ! -f %B/avrdude.conf ]; then cp -p %D/%F %B/avrdude.conf; fi
> 
> I disagree.
> 
> avrdude.conf is not supposed to have user-servicable parts inside.

As far as it is installed into etc, we may not and should not expect
user to know this. Everything in etc is user-changeable and must be
handled appropriately.

Also, you are not right: manpage says in clear text that the file can
be modified:

---
           -C config-file
                   Use the specified config file to load configuration data.
                   This file contains all programmer and part definitions that
                   avrdude knows about.  If you have a programmer or part that
                   avrdude does not know about, you can add it to the config
                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                   file (be sure and submit a patch back to the author so that
                   it can be incorporated for the next version).  See the con-
                   fig file, located at ${PREFIX}/etc/avrdude.conf, which con-
                   tains a description of the format.
---

> it can be changed whenever the config file parser changes

True for each and every config file, but not a reason to not have
configs or to not preserve user changes.

-- 
Dmitry Marakasov   .   55B5 0596 FF1E 8D84 5F56  9510 D35A 80DD F9D2 F77D
amdmi3@amdmi3.ru  ..:  jabber: amdmi3@jabber.ru    http://www.amdmi3.ru
Comment 4 Joerg Wunsch 2014-04-05 09:01:37 UTC
As Dmitry Marakasov wrote:

> As far as it is installed into etc, we may not and should not expect
> user to know this. Everything in etc is user-changeable and must be
> handled appropriately.

Today, I would probably rather install it under ${prefix}/share if I
had to decide anew.  The fact it resides in ${prefix}/etc is merely
historical.

I have added a warning at the top of the file to not manually modify
it.

> Also, you are not right: manpage says in clear text that the file can
> be modified:

I have changed this.  In the next release, this paragraph won't be
there anymore.

Even if FreeBSD decides it wants to run extra circles to not overwrite
it, for everyone else, "make install" in AVRDUDE *will* overwrite that
file, so it's certainly never a good idea to have user modifications
in it.

There's a (relatively new) option to specify an additional config file
using -C +filename which should be used for user overrides.
-- 
cheers, Joerg               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/
Never trust an operating system you don't have sources for. ;-)
Comment 5 Dmitry Marakasov 2014-04-05 12:59:13 UTC
* Joerg Wunsch (j@uriah.heep.sax.de) wrote:

> > As far as it is installed into etc, we may not and should not expect
> > user to know this. Everything in etc is user-changeable and must be
> > handled appropriately.
>=20
> Today, I would probably rather install it under ${prefix}/share if I
> had to decide anew.  The fact it resides in ${prefix}/etc is merely
> historical.

I haven't noticed you're it's developer as well. I'd discourage
from this choice: as I've already mentioned, problem changing config
format affects all software which uses configs, it's the matter of
developer's foresight to chose format extensible enough from
beginning, and that's not a reason to not use configs or to pretend
that config is some kind of constant data, or to limit user in it's
right to change config as he likes. Using .avrduderc won't save
user from changed config format either, by the way.

The correct choice seem to be a warning encouraging user to use dotfile,
but config should still be handled as config.

And since you're developer, here's what I've actually needed custom
config for:

programmer
  id    =3D "five-wires";
  desc  =3D "\"Five wires\" parallel programmer";
  type  =3D par;
  sck   =3D 6;
  mosi  =3D 7;
  reset =3D 9; =20
  miso  =3D 10;
;

That's handmade "=D0=BF=D1=8F=D1=82=D1=8C =D0=BF=D1=80=D0=BE=D0=B2=D0=BE=D0=
=B4=D0=BA=D0=BE=D0=B2" ("five wires") AVR programmer
popular in Russia:

http://www.123avr.com/07.htm
http://www.getchip.net/posts/delaem-lpt-programmator-dlya-avr-mikrokontro=
llerov/
https://www.google.ru/search?q=3D=D0=BF=D1=8F=D1=82=D1=8C+=D0=BF=D1=80=D0=
=BE=D0=B2=D0=BE=D0=B4=D0=BA=D0=BE=D0=B2&tbm=3Disch

http://translate.google.com/#ru/en/=D0=BF=D1=8F=D1=82=D1=8C%20=D0=BF=D1=80=
=D0=BE=D0=B2=D0=BE=D0=B4=D0=BA=D0=BE=D0=B2

(Russian, but see images)

It seems to be similar to stk200, but doesn't use buffer pins.

> > Also, you are not right: manpage says in clear text that the file can
> > be modified:
>=20
> I have changed this.  In the next release, this paragraph won't be
> there anymore.
>=20
> Even if FreeBSD decides it wants to run extra circles to not overwrite
> it, for everyone else, "make install" in AVRDUDE *will* overwrite that
> file, so it's certainly never a good idea to have user modifications
> in it.

Actually, it's the opposite:

--- Makefile.am
install-exec-local: backup-avrdude-conf
...
backup-avrdude-conf:
        @echo "Backing up avrdude.conf in ${DESTDIR}${sysconfdir}"
        @if test -e ${DESTDIR}${sysconfdir}/avrdude.conf; then \
                cp -pR ${DESTDIR}${sysconfdir}/avrdude.conf \
                        ${DESTDIR}${sysconfdir}/avrdude.conf.bak; \
        fi
---

--=20
Dmitry Marakasov   .   55B5 0596 FF1E 8D84 5F56  9510 D35A 80DD F9D2 F77D
amdmi3@amdmi3.ru  ..:  jabber: amdmi3@jabber.ru    http://www.amdmi3.ru