• NetBSD
  • empty local package list

unicorn can't run fsck on /, as file system is mounted read-write on /

Boot into single-user mode, use /rescue/sh as the shell, then run:

fsck -f /

This is standard stuff, mate. Every Unix user should know this.

unicorn the title is the error message. /usr/pkg/pkgdb have all the packages.

You're not explaining this very well, and we can't see what's happening on your system.

  1. Can you upload these 2 files somewhere?

    /var/db/pkgin/sql.log
    /var/db/pkgin/pkg_install-err.log

    (The first one, sql.log, may not exist.)

  2. What're the outputs of these commands:

    ls -l /usr/pkg/pkgdb/*.db /var/db/pkgin/
    cat /usr/pkg/etc/pkgin/repositories.conf
    pkgin list > /tmp/pkgin.log
    pkg_info   > /tmp/pkg_info.log

    Upload the 2 /tmp/*.log files also.

    rvp

    I had those four log files stored in the system, but I can't open firefox, and I can't transfer them to my phone as I can't open ftp application. I can't transfer files using mtp either.I had run fsck, there's no error found.

      unicorn Does git still work? If so create a repo on another machine, clone it on the problem system and commit the files.

      An alternative is katbin-cli but, if you don't already have it installed, there's no help.

      unicorn I can't transfer them to my phone as I can't open ftp application. I can't transfer files using mtp either.

      This is not difficult. You can:

      • Zip all the files up and copy them to a DOS-formatted USB drive, then use another system.
      • Zip everything up (incl. the output of the commands), then use nc to transfer files. You can get nc even on Windoze, I think.
      • Maybe use Emacs? It already has everything else--incl. a browser, so why not a file xfer service too?

        unicorn please use one of the methods suggested by @rvp, @Jay or, myself.

        Don't know about the others but, I'm not looking at logfiles as pictures, sorry.

        unicorn I can use emacs, how to do?

        That was just a joke. 😃

        Try this (even simpler than using emacs):
        Do all steps as root.

        1. Make a directory called /tmp/www, and copy all the files I asked for there.
        mkdir /tmp/www
        cp -a /SOME/PATH/*.log /tmp/www/.
        1. Run httpd. Ctrl-C when finished.
        /usr/libexec/httpd -f -X /tmp/www
        1. Use the IP address of the NetBSD system to xfer files using any browser.
        • Jay likes this.

        unicorn I had run fsck, there's no error found.

        OK, but, if /usr or /var are separate filesystems, then you'll check them also.

        Well, I can see errors in your logs, but, they're mostly from last year:

        sql.log
        [...]
        SQL error at 2022-05-05 02:52:44 CST
           errmsg: statement aborts at 13: [INSERT INTO LOCAL_PROVIDES (PKG_ID, LOCAL_PROVIDES_PKGNAME) VALUES (116,'/usr/pkg/lib/gstreamer-1.0/libgstsubparse.so');] attempt to write a readonly database
            query: INSERT INTO LOCAL_PROVIDES (PKG_ID, LOCAL_PROVIDES_PKGNAME) VALUES (116,'/usr/pkg/lib/gstreamer-1.0/libgstsubparse.so');
        SQL error at 2022-05-05 02:52:44 CST
           errmsg: statement aborts at 13: [INSERT INTO LOCAL_PROVIDES (P
        pkg_install.log
        [...]
        ---May 04 21:32:25: refreshing gdk-pixbuf2-2.42.6nb1...
        g_module_open() failed for /usr/pkg/lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-svg.so: /usr/pkg/lib/libpangoft2-1.0.so.0: Undefined PLT symbol "hb_font_set_synthetic_slant" (symnum = 7)
        [1]   Segmentation fault (core dumped) ${GDK_PIXBUF_QUERY_LOADERS} >${GDK_PIXBUF_LOAD...
        [...]
        ---May 05 02:41:56: refreshing serf-1.3.9nb2...
        pkg_add: Read error for lib/libserf-1.so.1.3.0: Lzma library error: Corrupted input data
        pkg_add: Updating of serf-1.3.9nb2 to serf-1.3.9nb2 failed.
        pkg_add: Remember to run pkg_admin rebuild-tree after fixing this.
        pkg_add: Couldn't remove /usr/pkg/lib/pkgconfig/serf-1.pc: No such file or directory
        pkg_add: 1 package addition failed
        [...]
        ---May 28 18:48:40: refreshing gdk-pixbuf2-2.42.6nb1...
        pkg_delete: Couldn't remove package directory in `/usr/pkg/pkgdb/gdk-pixbuf2-2.42.6nb1'
        pkg_add: command failed: /usr/pkg/sbin/pkg_delete -K /usr/pkg/pkgdb -p /usr/pkg  gdk-pixbuf2-2.42.6nb1
        pkg_add: 1 package addition failed
        ---May 28 18:48:41: refreshing gdbm-1.23...
        pkg_add: /usr/pkg/pkgdb/gdk-pixbuf2-2.42.6nb1/+CONTENTS: No such file or directory
        ---May 28 18:48:41: refreshing gd-2.3.3nb1...
        pkg_add: /usr/pkg/pkgdb/gdk-pixbuf2-2.42.6nb1/+CONTENTS: No such file or directory
        ---May 28 18:48:41: refreshing gcc7-7.5.0nb5...
        [...]

        Many other there...

        More relevent is the output of pkg_info which shows definite corruption:

        [...]
        xfce4-power-manager-4.16.0nb2 Xfce power manager
        py310-expat-3.10.9nb1 /* XPM */
        static char * to

        Right. The easiest thing to do is reinstall after wiping everything:

        rm -rf /var/db/pkgin /usr/pkg
        export PKG_PATH='http://cdn.NetBSD.org/pub/pkgsrc/packages/NetBSD/amd64/10.0/All'
        pkg_add pkgin
        echo 'http://cdn.NetBSD.org/pub/pkgsrc/packages/NetBSD/$arch/10.0/All' > /usr/pkg/etc/pkgin/repositories.conf
        pkgin update
        pkgin install [...]

        Replace 10.0 everywhere with 9.3 or 9.2 or whatever version of NetBSD you have.

        Otherwise, you can try to salvage your current install:

        1. Move old DB out of the way. (You can remove these later...)

          mv /var/db/pkgin /var/db/pkgin.orig
          mv /usr/pkg/pkgdb/pkgdb.byfile.db /usr/pkg/pkgdb/pkgdb.byfile.db.orig
        2. Fix corrupted files.
          Running pkg_info causes it to read the +CONTENTS file in each package directory in /usr/pkg/pkgdb/. You can see this is failing because (at least one of) the files is corrupt:

          py310-expat-3.10.9nb1 /* XPM */
          static char * to

          I suspect that some of the files in /usr/pkg/pkgdb/py310-expat-3.10.9nb1/ are bad. So, download that tarball from here (use correct version please), then extract only the +-files, over-writing the possibly corrupt files in the /usr/pkg/pkgdb/<package name>/ directory.
          Run, pkg_info again, and check for other corrupt packages. Repeat as necessary.

        3. Rebuild database
          When the pkg_info output looks OK, try rebuilding the database:

          pkg_admin rebuild

          If there are any errors here, then note which packages are corrupted, do Step 2 for each of them, then rebuild again until the rebuild succeeds without errors.

        4. Check packages
          By this point the database should be consistent. Now check all the installed package files:

          pkg_admin check

          If any files fail in their checksums, remove the package and reinstall:

          pkgin clean
          pkgin update
          pkgin rm [...]
          pkgin autoremove
          pkgin in [...]

        This should make things reasonably consistent. @pin can chime in with corrections...

          I had run pkgin_admin check, and I get one file failed checksum, but I see some other files also failed checksum,delete all?
          run what commans after deletion?

          • pin replied to this.

            rvp This should make things reasonably consistent. @pin can chime in with corrections...

            I'm AFK until Monday, only mobile access until then. Your suggestion looks perfect. Honestly, when I first saw this, I was afraid it would need a re-install. That's what I would probably do anyway but, your walk through should work. 🥰

            • Jay likes this.

            unicorn As @rvp already suggested,

            If any files fail in their checksums, remove the package and reinstall:

            ...
            pkgin rm [...]
            pkgin autoremove
            pkgin in [...] 

            pkgin upgrade completed but have errors, how to fix it? one package to be installed is newer than currently installed, I choose yes, but after reboot packages to be upgraded are the same as previous. I still can't open firefox.

            termbin

            • rvp replied to this.

              unicorn I can still see a lot of errors in pkg_install.log. For example:

              Could not parse file "/usr/pkg/share/applications/org.xfce.mousepad-settings.desktop": Key file does not have group ?Desktop Entry?
              Could not parse file "/usr/pkg/share/applications/org.xfce.mousepad.desktop": Key file contains line ??PNG? which is not a key-value pair, group, or comment

              This looks like a corrupt file. Did you run fsck -f /usr (if /usr is a separate FS)?

              There are other errors:

              ---Apr 09 07:51:19: refreshing xfce4-settings-4.16.5...
              pkg_add: Unrecognised PLIST command `@B'
              pkg_delete: Couldn't remove /usr/pkg/bin/xfce4-accessibility-settings: No such file or directory
              pkg_delete: Couldn't remove /usr/pkg/bin/xfce4-appearance-settings: No such file or directory
              pkg_delete: Couldn't remove /usr/pkg/bin/xfce4-display-settings: No such file or directory

              This one looks like corrupt +files of the xfce4-settings-4.16.5 package.

              Did you extract and overwrite these files as I said in Step 2? Your package database won't be correct until all these errors are fixed first, and I can't say that they are correct because you haven't shown me the outputs of any of the the commands you ran. Use script for this.

              unicorn but after reboot packages to be upgraded are the same as previous. I still can't open firefox.

              I think it would be easiest now to just wipe everything and re-install... (the commands are right at the beginning of my previous post).

              • Jay likes this.

              pkg_add pkgin

              pkg_add: warning: package pkgin-22.10.0nb1 was built for a platform
              pkg_add: netbsd/x86_64 9.0 (pkg) vs. netbsd/x86_64 9.3(this host)
              pkg_add: unrecognised plist command '@B'
              pkg_add: /usr/pkg/pkgdb/xfce4-settings-4.16.5/+contents: no such file or directory

                unicorn Did you do rm -rf /var/db/pkgin /usr/pkg before that command?

                pin Time for a clean install.

                Ayup.

                  rvp

                  yeah, I run that command before other commands, I also run the command pkg_delete pkgin.

                  I have some data I don't want to lose, any other method I can continue using the current system? any other package management? Where is the port directory? I want to compile packages.