From nobody Tue Aug 30 17:45:32 2022 X-Original-To: freebsd-ports@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MHF8R1PwLz4Zybw for ; Tue, 30 Aug 2022 17:45:43 +0000 (UTC) (envelope-from freebsd@gushi.org) Received: from prime.gushi.org (prime.gushi.org [IPv6:2620:137:6000:10::142]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "prime.gushi.org", Issuer "RapidSSL TLS DV RSA Mixed SHA256 2020 CA-1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MHF8Q2mnpz3GNv for ; Tue, 30 Aug 2022 17:45:42 +0000 (UTC) (envelope-from freebsd@gushi.org) Received: from smtpclient.apple ([12.169.99.98]) (authenticated bits=0) by prime.gushi.org (8.16.1/8.16.1) with ESMTPSA id 27UHjajK039937 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 30 Aug 2022 10:45:37 -0700 (PDT) (envelope-from freebsd@gushi.org) DKIM-Filter: OpenDKIM Filter v2.10.3 prime.gushi.org 27UHjajK039937 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gushi.org; s=prime2014; t=1661881537; bh=3DiOKHqnJDFDF6JTSAnTkBnIc59Nsnoh0vB8LxMpBAw=; h=Subject:From:In-Reply-To:Date:Cc:References:To; z=Subject:=20Re:=20Recover=20from=20a=20corrupt=20pkg=20DB|From:=20 "Dan=20Mahoney=20(Ports)"=20|In-Reply-To:=20<20 220830172613.bl4q3ynadyktstgw@shelly.nomadlogic.org>|Date:=20Tue,= 2030=20Aug=202022=2010:45:32=20-0700|Cc:=20Kevin=20Oberman=20,=0D=0A=20FreeBSD=20Ports=20ML=20|References:=20=0D=0A=20<20220830172613.bl4q3ynadykt stgw@shelly.nomadlogic.org>|To:=20Pete=20Wright=20; b=mYPv6oQlVdIP4RPNsUuB/hJtP+gV156fXE/M6ENdkdVoWLDRI6XOls5ZxXrM0Svv5 JjvBcCah5KqgYM9mklVW76TnjMSgLObOxuAEhzHpRTKQGdW+goX+nld3tj4wQ39qOG AIuOSfXWNorm5ibwwqFIybXrXv2cnb4nDXW3WgAeKWFmZ7uNRLQWOferWC1l8Z3cUr piDRP9ycFr+SjCs4RWlwST53jyH2LQQNmEaCEtvZISuACmBggnOC1IMqE+FgCcouUQ nf4ECNB5/odjhUQ5x6qklSFJZGk6eBqO7fMc2Ff5QOPYktFl+TtRab0h4qZg25xR1c ofITON3+nOhFw== X-Authentication-Warning: prime.gushi.org: Host [12.169.99.98] claimed to be smtpclient.apple Content-Type: text/plain; charset=utf-8 List-Id: Porting software to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-ports List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-ports@freebsd.org X-BeenThere: freebsd-ports@freebsd.org Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Subject: Re: Recover from a corrupt pkg DB From: "Dan Mahoney (Ports)" In-Reply-To: <20220830172613.bl4q3ynadyktstgw@shelly.nomadlogic.org> Date: Tue, 30 Aug 2022 10:45:32 -0700 Cc: Kevin Oberman , FreeBSD Ports ML Content-Transfer-Encoding: quoted-printable Message-Id: <0BDF281F-B485-4EE6-B0A5-698F5B134C99@gushi.org> References: <20220830172613.bl4q3ynadyktstgw@shelly.nomadlogic.org> To: Pete Wright X-Mailer: Apple Mail (2.3696.120.41.1.1) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.2 (prime.gushi.org [149.20.68.142]); Tue, 30 Aug 2022 17:45:38 +0000 (UTC) X-Rspamd-Queue-Id: 4MHF8Q2mnpz3GNv X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gushi.org header.s=prime2014 header.b=mYPv6oQl; dmarc=pass (policy=none) header.from=gushi.org; spf=pass (mx1.freebsd.org: domain of freebsd@gushi.org designates 2620:137:6000:10::142 as permitted sender) smtp.mailfrom=freebsd@gushi.org X-Spamd-Result: default: False [-6.20 / 15.00]; DWL_DNSWL_MED(-2.00)[gushi.org:dkim]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-1.000]; MV_CASE(0.50)[]; RCVD_DKIM_ARC_DNSWL_MED(-0.50)[]; DMARC_POLICY_ALLOW(-0.50)[gushi.org,none]; R_DKIM_ALLOW(-0.20)[gushi.org:s=prime2014]; RCVD_IN_DNSWL_MED(-0.20)[2620:137:6000:10::142:from]; R_SPF_ALLOW(-0.20)[+mx]; MIME_GOOD(-0.10)[text/plain]; FROM_HAS_DN(0.00)[]; MLMMJ_DEST(0.00)[freebsd-ports@freebsd.org]; RCPT_COUNT_THREE(0.00)[3]; FREEMAIL_CC(0.00)[gmail.com,freebsd.org]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; TO_DN_ALL(0.00)[]; HAS_XAW(0.00)[]; ARC_NA(0.00)[]; DKIM_TRACE(0.00)[gushi.org:+]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; ASN(0.00)[asn:393507, ipnet:2620:137:6000::/44, country:US]; RCVD_COUNT_TWO(0.00)[2] X-ThisMailContainsUnwantedMimeParts: N > On Aug 30, 2022, at 10:26 AM, Pete Wright wrote: >=20 > On Tue, Aug 30, 2022 at 09:36:52AM -0700, Kevin Oberman wrote: >> I had a crash while building ffmpeg on a new system. The build had = not >> begun, so I don't think ffmpeg is really an issue. portmaster(8) was >> walking the dependency tree when the system panicked and, after a = reboot >> and full fsck, I get the error: >> pkg: sqlite error while executing PRAGMA user_version; in file >> pkgdb.c:2357: database disk image is malformed So, I don=E2=80=99t know what tools are available in sqlite3 to dump a = malformed db file and reimport it. I think that=E2=80=99s probably = beyond the scope of this, but as I=E2=80=99ve in the past hit pkg = issues, I=E2=80=99ve always wanted to know if there was an online = description of the schema somewhere. (Obviously, you could peruse the = schema on a second non-corrupt system, but that doesn=E2=80=99t describe = how it=E2=80=99s used). >>=20 >> Is there any way to rebuild the DB or, if not, how do I remove it and = start >> from scratch? I mean, this is a *very* brute force approach, but if you know precisely = what packages you had installed, you can always just reinstall pkg and = pkg install -f those packages. >=20 > I ran into a similar issue a while back, I discovered I was able to > recover by using one of the automated backups generated at: > /var/backups/pkg.sql.xz* >=20 > I can't remember the details, but I think it involved replacing > repo-FreeBSD.sqlite in /var/db/pkg/. I=E2=80=99ve dealt with this on another OS that did things far, far = worse (RPM, in the days before Yum). It always stymied me that there = was no online tool that could look at all the files you had in = /usr/local/*, look at checksums of historical packages, and glean a = =E2=80=9Chey, it looks like these are the packages you had installed, = but *these files* are the ones that don=E2=80=99t match any checksum on = record.=E2=80=9D -Dan