# Error "pkg: unknown format pkg, using the default" from pkg during portupgrade



## Terry_Kennedy (Sep 24, 2021)

Every one of several dozen systems with FreeBSD 12-STABLE has been giving this warning when using portupgrade. A web search shows only one hit, and that is in an unrelated question.

Back "in the old days", a `# pkgdb -F` would usually be all that was needed to fix this warning. But doing that now gives:


```
(0:81) hostname:/sysprog/terry# pkgdb -F
pkgdb -F not supported with PKGNG yet. Use 'pkg check' directly.
```

`man pkg-check` doesn't seem to show anything relevant - it is all about fixing problems with package dependencies, not the database itself. Presumably that's the reason for the "Use 'pkg check' directly." handwave instead of specifying the actual command line needed.

Any ideas?


----------



## trev (Sep 24, 2021)

portupgrade(1) is annoying pkg when it creates the backup pkg. This is the portupgrade script source:


```
backquote!(PkgDB::command(:pkg), 'create', '-o', $tmpdir, '-f', $portsdb.pkg_sufx, pkgname)
```



> -f format, --format format
> Set format as the package output format.  It can be
> one of tzst, txz, tbz, tgz or tar which are
> currently the only supported formats.  If an
> invalid or no format is specified txz is assumed.



So it's a problem with the value in the variable $portsdb.pkg_sufx which I determined is "pkg" by changing the backing up message in portupgrade thus:


```
2081c2081
<   progress_message "Backing up the old version"
---
>   progress_message "Backing up the old version - " + $portsdb.pkg_sufx
```

My quick hack solution was simply to edit the script at /usr/local/sbin/portupgrade to remove `'-f', $portsdb.pkg_sufx,` from the two lines in which it occurs.


```
diff portupgrade  /usr/local/sbin/portupgrade

1080c1080
<       system!(PkgDB::command(:pkg), 'create', '-o', $packages_dir, '-f', $portsdb.pkg_sufx, pkgname)
---
>       system!(PkgDB::command(:pkg), 'create', '-o', $packages_dir, pkgname)
2087c2087
<     backquote!(PkgDB::command(:pkg), 'create', '-o', $tmpdir, '-f', $portsdb.pkg_sufx, pkgname)
---
>     backquote!(PkgDB::command(:pkg), 'create', '-o', $tmpdir, pkgname)
```

Caveat Utilitor: It works for me, but be warned, I have never programmed in Ruby.


----------



## Terry_Kennedy (Sep 28, 2021)

trev said:


> portupgrade(1) is annoying pkg when it creates the backup pkg. This is the portupgrade script source:



Ok, thanks. As long as it is just a bug and not indicating some sort of widespread corruption in my pkg database.

Though it does make me wonder "who tests this stuff?"


----------

