Solved pkg reports all ports orphaned.

I did several searches on this forum and on the internet but didn't find anything to resolve my issue. I am running FreeBSD 11.2-Stable inside of a Jail. I first noticed this issue in 11.0-RELEASE.

pkg version -v reports

Code:
44bsd-csh-20001106_5               ?   orphaned: shells/44bsd-csh
GeoIP-1.6.12                       ?   orphaned: net/GeoIP
ap24-mod_evasive-1.10.1_1          ?   orphaned: www/mod_evasive
ap24-mod_geoip2-1.2.10             ?   orphaned: www/mod_geoip2
ap24-mod_security-2.9.2_2          ?   orphaned: www/mod_security
apache24-2.4.37                    ?   orphaned: www/apache24
apg-2.3.0b_5                       ?   orphaned: security/apg
apr-1.6.5.1.6.1                    ?   orphaned: devel/apr1
ca_root_nss-3.40                   ?   orphaned: security/ca_root_nss
chkrootkit-0.52                    ?   orphaned: security/chkrootkit
curl-7.62.0                        ?   orphaned: ftp/curl
cvsps-2.1_2                        ?   orphaned: devel/cvsps
cyrus-sasl-2.1.26_13               ?   orphaned: security/cyrus-sasl2
db5-5.3.28_7                       ?   orphaned: databases/db5
diffutils-3.6                      ?   orphaned: textproc/diffutils
expat-2.2.6_1                      ?   orphaned: textproc/expat2
freetype2-2.9.1                    ?   orphaned: print/freetype2
gdbm-1.13_1                        ?   orphaned: databases/gdbm
geoipupdate-3.1.1                  ?   orphaned: net/geoipupdate
gettext-runtime-0.19.8.1_1         ?   orphaned: devel/gettext-runtime
git-2.19.1                         ?   orphaned: devel/git
icu-63.1,1                         ?   orphaned: devel/icu
indexinfo-0.3.1                    ?   orphaned: print/indexinfo
jpeg-turbo-2.0.0                   ?   orphaned: graphics/jpeg-turbo
libICE-1.0.9_3,1                   ?   orphaned: x11/libICE
libSM-1.2.3,1                      ?   orphaned: x11/libSM
libX11-1.6.6_1,1                   ?   orphaned: x11/libX11
libXau-1.0.8_5                     ?   orphaned: x11/libXau
libXaw-1.0.13_2,2                  ?   orphaned: x11-toolkits/libXaw
libXdmcp-1.1.2_2                   ?   orphaned: x11/libXdmcp
libXext-1.3.3_3,1                  ?   orphaned: x11/libXext
libXmu-1.1.2_5,1                   ?   orphaned: x11-toolkits/libXmu
libXp-1.0.3_2,1                    ?   orphaned: x11/libXp
libXpm-3.5.12_2                    ?   orphaned: x11/libXpm
libXt-1.1.5_2,1                    ?   orphaned: x11-toolkits/libXt
libedit-3.1.20170329_2,1           ?   orphaned: devel/libedit
libevent-2.1.8_2                   ?   orphaned: devel/libevent
libffi-3.2.1_2                     ?   orphaned: devel/libffi
libiconv-1.14_11                   ?   orphaned: converters/libiconv
libltdl-2.4.6                      ?   orphaned: devel/libltdl
liblz4-1.8.3,1                     ?   orphaned: archivers/liblz4
libmcrypt-2.5.8_3                  ?   orphaned: security/libmcrypt
libnghttp2-1.34.0                  ?   orphaned: www/libnghttp2
libpthread-stubs-0.4               ?   orphaned: devel/libpthread-stubs
libsigsegv-2.12                    ?   orphaned: devel/libsigsegv
libxcb-1.13.1                      ?   orphaned: x11/libxcb
libxml2-2.9.7                      ?   orphaned: textproc/libxml2
libzip-1.5.1                       ?   orphaned: archivers/libzip
logrotate-3.13.0_1                 ?   orphaned: sysutils/logrotate
lsof-4.92.b_1,8                    ?   orphaned: sysutils/lsof
lynis-2.7.0                        ?   orphaned: security/lynis
mod_php56-5.6.38                   ?   orphaned: www/mod_php56
mysql57-client-5.7.24              ?   orphaned: databases/mysql57-client
mysql57-server-5.7.24              ?   orphaned: databases/mysql57-server
oniguruma-6.9.0                    ?   orphaned: devel/oniguruma
openssl-unsafe-1.0.2.20170706      ?   orphaned: security/openssl-unsafe
p5-Authen-Htpasswd-0.171_1         ?   orphaned: security/p5-Authen-Htpasswd
p5-Authen-SASL-2.16_1              ?   orphaned: security/p5-Authen-SASL
p5-CGI-4.40                        ?   orphaned: www/p5-CGI
p5-Class-Accessor-0.51             ?   orphaned: devel/p5-Class-Accessor
p5-Crypt-PasswdMD5-1.40            ?   orphaned: security/p5-Crypt-PasswdMD5
p5-Digest-HMAC-1.03_1              ?   orphaned: security/p5-Digest-HMAC
p5-Digest-SHA1-2.13_1              ?   orphaned: security/p5-Digest-SHA1
p5-Error-0.17027                   ?   orphaned: lang/p5-Error
p5-File-Tail-1.3                   ?   orphaned: devel/p5-File-Tail
p5-GSSAPI-0.28_1                   ?   orphaned: security/p5-GSSAPI
p5-HTML-Parser-3.72                ?   orphaned: www/p5-HTML-Parser
p5-HTML-Tagset-3.20_1              ?   orphaned: www/p5-HTML-Tagset
p5-IO-LockedFile-0.23_1            ?   orphaned: devel/p5-IO-LockedFile
p5-IO-Socket-INET6-2.72_1          ?   orphaned: net/p5-IO-Socket-INET6
p5-IO-Socket-SSL-2.060             ?   orphaned: security/p5-IO-Socket-SSL
p5-Mozilla-CA-20180117             ?   orphaned: www/p5-Mozilla-CA
p5-Net-SSLeay-1.85                 ?   orphaned: security/p5-Net-SSLeay
p5-Socket6-0.29                    ?   orphaned: net/p5-Socket6
pcre-8.42                          ?   orphaned: devel/pcre
pecl-APCu4-4.0.11_1                ?   orphaned: devel/pecl-APCu4
perl5-5.26.2_1                     ?   orphaned: lang/perl5.26
php-suhosin-0.9.38_3               ?   orphaned: security/php-suhosin
php56-5.6.38                       ?   orphaned: lang/php56
php56-bcmath-5.6.38                ?   orphaned: math/php56-bcmath
php56-bz2-5.6.38                   ?   orphaned: archivers/php56-bz2
php56-ctype-5.6.38                 ?   orphaned: textproc/php56-ctype
php56-curl-5.6.38                  ?   orphaned: ftp/php56-curl
php56-dom-5.6.38                   ?   orphaned: textproc/php56-dom
php56-exif-5.6.38                  ?   orphaned: graphics/php56-exif
php56-filter-5.6.38                ?   orphaned: security/php56-filter
php56-gd-5.6.38                    ?   orphaned: graphics/php56-gd
php56-gettext-5.6.38               ?   orphaned: devel/php56-gettext
php56-hash-5.6.38                  ?   orphaned: security/php56-hash
php56-iconv-5.6.38                 ?   orphaned: converters/php56-iconv
php56-json-5.6.38                  ?   orphaned: devel/php56-json
php56-mbstring-5.6.38              ?   orphaned: converters/php56-mbstring
php56-mcrypt-5.6.38                ?   orphaned: security/php56-mcrypt
php56-mysql-5.6.38                 ?   orphaned: databases/php56-mysql
php56-mysqli-5.6.38                ?   orphaned: databases/php56-mysqli
php56-opcache-5.6.38               ?   orphaned: www/php56-opcache
php56-openssl-5.6.38_1             ?   orphaned: security/php56-openssl
php56-pecl-intl-3.0.0_16           ?   orphaned: devel/pecl-intl
php56-readline-5.6.38              ?   orphaned: devel/php56-readline
php56-session-5.6.38               ?   orphaned: www/php56-session
php56-sockets-5.6.38               ?   orphaned: net/php56-sockets
php56-xml-5.6.38                   ?   orphaned: textproc/php56-xml
php56-xmlreader-5.6.38             ?   orphaned: textproc/php56-xmlreader
php56-zip-5.6.38                   ?   orphaned: archivers/php56-zip
php56-zlib-5.6.38                  ?   orphaned: archivers/php56-zlib
phpMyAdmin-php56-4.8.3             ?   orphaned: databases/phpmyadmin
pkg-1.10.5_5                       ?   orphaned: ports-mgmt/pkg
png-1.6.35                         ?   orphaned: graphics/png
popt-1.16_2                        ?   orphaned: devel/popt
protobuf-3.5.2_1,1                 ?   orphaned: devel/protobuf
py27-setuptools-40.4.3             ?   orphaned: devel/py-setuptools
py27-sqlite3-2.7.15_7              ?   orphaned: databases/py-sqlite3
pydio-8.0.2                        ?   orphaned: www/pydio
python27-2.7.15                    ?   orphaned: lang/python27
readline-7.0.3_1                   ?   orphaned: devel/readline
serf-1.3.9_3                       ?   orphaned: www/serf
sqlite3-3.25.1_1                   ?   orphaned: databases/sqlite3
sshblock-1.0_1                     ?   orphaned: security/sshblock
sslscan-1.11.11.16                 ?   orphaned: security/sslscan
subversion-1.11.0                  ?   orphaned: devel/subversion
sudo-1.8.25p1                      ?   orphaned: security/sudo
t1lib-5.1.2_4,1                    ?   orphaned: devel/t1lib
utf8proc-2.1.0                     ?   orphaned: textproc/utf8proc
xorgproto-2018.4                   ?   orphaned: x11/xorgproto
yajl-2.1.0                         ?   orphaned: devel/yajl

pkg -vv reports

Code:
Version                 : 1.10.5
PKG_DBDIR = "/var/db/pkg";
PKG_CACHEDIR = "/var/cache/pkg";
PORTSDIR = "/usr/ports";
INDEXDIR = "";
INDEXFILE = "INDEX-11";
HANDLE_RC_SCRIPTS = false;
DEFAULT_ALWAYS_YES = false;
ASSUME_ALWAYS_YES = false;
REPOS_DIR [
    "/etc/pkg/",
    "/usr/local/etc/pkg/repos/",
]
PLIST_KEYWORDS_DIR = "";
SYSLOG = true;
ABI = "FreeBSD:11:amd64";
ALTABI = "freebsd:11:x86:64";
DEVELOPER_MODE = false;
VULNXML_SITE = "http://vuxml.freebsd.org/freebsd/vuln.xml.bz2";
FETCH_RETRY = 3;
PKG_PLUGINS_DIR = "/usr/local/lib/pkg/";
PKG_ENABLE_PLUGINS = true;
PLUGINS [
]
DEBUG_SCRIPTS = false;
PLUGINS_CONF_DIR = "/usr/local/etc/pkg/";
PERMISSIVE = false;
REPO_AUTOUPDATE = true;
NAMESERVER = "";
HTTP_USER_AGENT = "pkg/1.10.5";
EVENT_PIPE = "";
FETCH_TIMEOUT = 30;
UNSET_TIMESTAMP = false;
SSH_RESTRICT_DIR = "";
PKG_ENV {
}
PKG_SSH_ARGS = "";
DEBUG_LEVEL = 0;
ALIAS {
    all-depends = "query %dn-%dv";
    annotations = "info -A";
    build-depends = "info -qd";
    cinfo = "info -Cx";
    comment = "query -i \"%c\"";
    csearch = "search -Cx";
    desc = "query -i \"%e\"";
    download = "fetch";
    iinfo = "info -ix";
    isearch = "search -ix";
    prime-list = "query -e '%a = 0' '%n'";
    prime-origins = "query -e '%a = 0' '%o'";
    leaf = "query -e '%#r == 0' '%n-%v'";
    list = "info -ql";
    noauto = "query -e '%a == 0' '%n-%v'";
    options = "query -i \"%n - %Ok: %Ov\"";
    origin = "info -qo";
    provided-depends = "info -qb";
    raw = "info -R";
    required-depends = "info -qr";
    roptions = "rquery -i \"%n - %Ok: %Ov\"";
    shared-depends = "info -qB";
    show = "info -f -k";
    size = "info -sq";
}
CUDF_SOLVER = "";
SAT_SOLVER = "";
RUN_SCRIPTS = true;
CASE_SENSITIVE_MATCH = false;
LOCK_WAIT = 1;
LOCK_RETRIES = 5;
SQLITE_PROFILE = false;
WORKERS_COUNT = 0;
READ_LOCK = false;
PLIST_ACCEPT_DIRECTORIES = false;
IP_VERSION = 0;
AUTOMERGE = true;
VERSION_SOURCE = "";
CONSERVATIVE_UPGRADE = true;
PKG_CREATE_VERBOSE = false;
AUTOCLEAN = false;
DOT_FILE = "";
REPOSITORIES {
}
VALID_URL_SCHEME [
    "pkg+http",
    "pkg+https",
    "https",
    "http",
    "file",
    "ssh",
    "ftp",
    "ftps",
    "pkg+ssh",
    "pkg+ftp",
    "pkg+ftps",
]
ALLOW_BASE_SHLIBS = false;
WARN_SIZE_LIMIT = 1048576;
METALOG = "";
OSVERSION = 1102000;
IGNORE_OSVERSION = false;


Repositories:
  FreeBSD: {
    url             : "pkg+http://pkg.FreeBSD.org/freebsd:11:x86:64/latest",
    enabled         : yes,
    priority        : 0,
    mirror_type     : "SRV",
    signature_type  : "FINGERPRINTS",
    fingerprints    : "/usr/share/keys/pkg"
  }

/var/db/pkg/local.sqlite reports

Code:
sqlite> .mode column
sqlite> .headers on
sqlite> select id, origin, name, automatic, lockec d, datetime(" tiome   me, 'unipo  xeph och; '), pkg_format_version from packages where automatic - = 0;
id          origin                name         automatic   locked      datetime(time, 'unixepoch')  pkg_format_version
----------  --------------------  -----------  ----------  ----------  ---------------------------  ------------------
101         security/php-suhosin  php-suhosin  0           0           2017-07-20 16:07:27                           
184         devel/pecl-APCu4      pecl-APCu4   0           0           2017-09-28 12:28:52                           
240         www/pydio             pydio        0           0           2018-01-06 02:37:08                           
413         lang/php56            php56        0           0           2018-11-15 07:24:16                           
448         sysutils/lsof         lsof         0           0           2018-11-15 07:24:22                           
458         www/apache24          apache24     0           0           2018-11-15 07:24:25                           
460         ports-mgmt/pkg        pkg          0           0           2018-11-15 07:24:26                           
461         security/sudo         sudo         0           0           2018-11-15 07:24:27                           
462         devel/subversion      subversion   0           0           2018-11-15 07:24:27                           
463         security/sslscan      sslscan      0           0           2018-11-15 07:24:27                           
464         security/sshblock     sshblock     0           0           2018-11-15 07:24:27                           
466         archivers/php56-zlib  php56-zlib   0           0           2018-11-15 07:24:28                           
467         archivers/php56-zip   php56-zip    0           0           2018-11-15 07:24:28                           
468         textproc/php56-xmlre  php56-xmlre  0           0           2018-11-15 07:24:28                           
470         net/php56-sockets     php56-socke  0           0           2018-11-15 07:24:28                           
471         www/php56-session     php56-sessi  0           0           2018-11-15 07:24:28                           
472         devel/php56-readline  php56-readl  0           0           2018-11-15 07:24:28                           
473         devel/pecl-intl       php56-pecl-  0           0           2018-11-15 07:24:28                           
474         security/php56-opens  php56-opens  0           0           2018-11-15 07:24:28                           
475         www/php56-opcache     php56-opcac  0           0           2018-11-15 07:24:28                           
476         databases/php56-mysq  php56-mysql  0           0           2018-11-15 07:24:28                           
477         databases/php56-mysq  php56-mysql  0           0           2018-11-15 07:24:28                           
478         security/php56-mcryp  php56-mcryp  0           0           2018-11-15 07:24:29                           
479         converters/php56-mbs  php56-mbstr  0           0           2018-11-15 07:24:29                           
480         devel/php56-json      php56-json   0           0           2018-11-15 07:24:29                           
481         converters/php56-ico  php56-iconv  0           0           2018-11-15 07:24:30                           
482         security/php56-hash   php56-hash   0           0           2018-11-15 07:24:30                           
483         devel/php56-gettext   php56-gette  0           0           2018-11-15 07:24:30                           
484         graphics/php56-gd     php56-gd     0           0           2018-11-15 07:24:30                           
486         graphics/php56-exif   php56-exif   0           0           2018-11-15 07:24:30                           
487         ftp/php56-curl        php56-curl   0           0           2018-11-15 07:24:30                           
488         textproc/php56-ctype  php56-ctype  0           0           2018-11-15 07:24:30                           
489         archivers/php56-bz2   php56-bz2    0           0           2018-11-15 07:24:30                           
490         math/php56-bcmath     php56-bcmat  0           0           2018-11-15 07:24:30                           
491         security/p5-Authen-H  p5-Authen-H  0           0           2018-11-15 07:24:30                           
492         databases/mysql57-se  mysql57-ser  0           0           2018-11-15 07:24:30                           
493         www/mod_php56         mod_php56    0           0           2018-11-15 07:24:32                           
494         security/lynis        lynis        0           0           2018-11-15 07:24:32                           
495         sysutils/logrotate    logrotate    0           0           2018-11-15 07:24:33                           
496         devel/git             git          0           0           2018-11-15 07:24:33                           
497         net/geoipupdate       geoipupdate  0           0           2018-11-15 07:24:34                           
498         textproc/diffutils    diffutils    0           0           2018-11-15 07:24:34                           
499         security/chkrootkit   chkrootkit   0           0           2018-11-15 07:24:34                           
500         security/apg          apg          0           0           2018-11-15 07:24:34                           
501         www/mod_security      ap24-mod_se  0           0           2018-11-15 07:24:34                           
502         www/mod_geoip2        ap24-mod_ge  0           0           2018-11-15 07:24:34                           
503         www/mod_evasive       ap24-mod_ev  0           0           2018-11-15 07:24:34                           
504         databases/phpmyadmin  phpMyAdmin-  0           0           2018-11-15 07:27:29                           
505         shells/44bsd-csh      44bsd-csh    0           0           2018-11-15 07:44:29

pkg update -f reports
Code:
Updating FreeBSD repository catalogue...
[REDACTED] Fetching meta.txz:   0%
...
[REDACTED] Fetching meta.txz: 100%    944 B   0.9kB/s    00:01   
[REDACTED] Fetching packagesite.txz:   0%
...
[REDACTED] Fetching packagesite.txz: 100%    6 MiB 850.5kB/s    00:08   
Processing entries:   0%
...
Processing entries: 100%
FreeBSD repository update completed. 33415 packages processed.
All repositories are up to date.

Then I again ran pkg version -v with the same list where all packages were orphaned.

So I ran pkg upgrade -f and it reported
Code:
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
Checking for upgrades (125 candidates):   0%
...
Checking for upgrades (125 candidates): 100%
Processing candidates (125 candidates):   0%
...
Processing candidates (125 candidates): 100%
Checking integrity... done (0 conflicting)
The following 122 package(s) will be affected (of 0 checked):

Installed packages to be REINSTALLED:
    pkg-1.10.5_5
    yajl-2.1.0
    xorgproto-2018.4
    utf8proc-2.1.0
    t1lib-5.1.2_4,1
    sudo-1.8.25p1
    subversion-1.11.0
    sslscan-1.11.11.16
    sshblock-1.0_1
    sqlite3-3.25.1_1
    serf-1.3.9_3
    readline-7.0.3_1
    python27-2.7.15
    py27-sqlite3-2.7.15_7
    py27-setuptools-40.4.3
    protobuf-3.5.2_1,1
    popt-1.16_2
    png-1.6.35
    phpMyAdmin-php56-4.8.3
    php56-zlib-5.6.38
    php56-zip-5.6.38
    php56-xmlreader-5.6.38
    php56-xml-5.6.38
    php56-sockets-5.6.38
    php56-session-5.6.38
    php56-readline-5.6.38
    php56-pecl-intl-3.0.0_16
    php56-openssl-5.6.38_1
    php56-opcache-5.6.38
    php56-mysqli-5.6.38
    php56-mysql-5.6.38
    php56-mcrypt-5.6.38
    php56-mbstring-5.6.38
    php56-json-5.6.38
    php56-iconv-5.6.38
    php56-hash-5.6.38
    php56-gettext-5.6.38
    php56-gd-5.6.38
    php56-filter-5.6.38
    php56-exif-5.6.38
    php56-dom-5.6.38
    php56-curl-5.6.38
    php56-ctype-5.6.38
    php56-bz2-5.6.38
    php56-bcmath-5.6.38
    php56-5.6.38
    perl5-5.26.2_1
    pcre-8.42
    p5-Socket6-0.29
    p5-Net-SSLeay-1.85
    p5-Mozilla-CA-20180117
    p5-IO-Socket-SSL-2.060
    p5-IO-Socket-INET6-2.72_1
    p5-IO-LockedFile-0.23_1
    p5-HTML-Tagset-3.20_1
    p5-HTML-Parser-3.72
    p5-GSSAPI-0.28_1
    p5-File-Tail-1.3
    p5-Error-0.17027
    p5-Digest-SHA1-2.13_1
    p5-Digest-HMAC-1.03_1
    p5-Crypt-PasswdMD5-1.40
    p5-Class-Accessor-0.51
    p5-CGI-4.40
    p5-Authen-SASL-2.16_1
    p5-Authen-Htpasswd-0.171_1
    openssl-unsafe-1.0.2.20170706
    oniguruma-6.9.0
    mysql57-server-5.7.24
    mysql57-client-5.7.24
    mod_php56-5.6.38
    lynis-2.7.0
    lsof-4.92.b_1,8
    logrotate-3.13.0_1
    libzip-1.5.1
    libxml2-2.9.7
    libxcb-1.13.1
    libsigsegv-2.12
    libpthread-stubs-0.4
    libnghttp2-1.34.0
    libmcrypt-2.5.8_3
    liblz4-1.8.3,1
    libltdl-2.4.6
    libiconv-1.14_11
    libffi-3.2.1_2
    libevent-2.1.8_2
    libedit-3.1.20170329_2,1
    libXt-1.1.5_2,1
    libXpm-3.5.12_2
    libXp-1.0.3_2,1
    libXmu-1.1.2_5,1
    libXext-1.3.3_3,1
    libXdmcp-1.1.2_2
    libXaw-1.0.13_2,2
    libXau-1.0.8_5
    libX11-1.6.6_1,1
    libSM-1.2.3,1
    libICE-1.0.9_3,1
    jpeg-turbo-2.0.0
    indexinfo-0.3.1
    icu-63.1,1
    git-2.19.1
    gettext-runtime-0.19.8.1_1
    geoipupdate-3.1.1
    gdbm-1.13_1
    freetype2-2.9.1
    expat-2.2.6_1
    diffutils-3.6
    db5-5.3.28_7
    cyrus-sasl-2.1.26_13
    cvsps-2.1_2
    curl-7.62.0
    chkrootkit-0.52
    ca_root_nss-3.40
    apr-1.6.5.1.6.1
    apg-2.3.0b_5
    apache24-2.4.37
    ap24-mod_security-2.9.2_2
    ap24-mod_geoip2-1.2.10
    ap24-mod_evasive-1.10.1_1
    GeoIP-1.6.12
    44bsd-csh-20001106_5

Number of packages to be reinstalled: 122

Proceed with this action? [y/N]: y
after which pkg version -v reports the exact same thing as above... everything orphaned.

Since my phpmyadmin installation was dated, I tried removing that package and installing the latest version using pkg, but it reports that as orphaned as well. Any ideas how to fix this?[/code]
 
The cause of this problem is not so much the removal of the ports directory, but the fact that pkg-version(8) uses the ports database by default (the -P parameter which is implied if you don't specify anything).

You can easily remove the ports directory if you want, just make sure to run pkg version -Rv which will tell pkg to use the repository catalogue instead of the ports index to determine new files.

And if you prefer not having the ports collection installed (saves diskspace) then you can set this as the default behavior using /usr/local/etc/pkg.conf: specify VERSION_SOURCE; set this to R. See pkg.conf(5) for more details on this.
 
The order is something like INDEX file, ports tree, remote repository. You can remove the ports tree if you only use packages, just make sure the whole ports tree is gone. Then it will automatically fall-back to the remote repository.

As hinted by ShelLuser you can use the -P (ports tree), -I (Index file) or -R (remote) switches to force any one of them in case the automatic detection fails for some reason.
 
Back
Top