Re: [Rpm-maint] [rpm-software-management/rpm] How can I find details on the binary representation of the RPM DB? (Discussion #2211)
@jerome-diver, are you referring to https://github.com/knqyf263/go-rpmdb/issues/54, or are you referring to some other SQLite problem with https://github.com/knqyf263/go-rpmdb? -- Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/discussions/2211#discussioncomment-10680936 You are receiving this because you are subscribed to this thread. Message ID: ___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] How can I find details on the binary representation of the RPM DB? (Discussion #2211)
An alternative to linking against librpm and using cgo is to use https://github.com/knqyf263/go-rpmdb. Do this at your own risk - it is possible that at any time, this third-party library could be incompatible with the RPM DB. -- Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/discussions/2211#discussioncomment-10675305 You are receiving this because you are subscribed to this thread. Message ID: ___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
[Rpm-maint] [rpm-software-management/rpm] Is it possible for an RPM package to have no version? (Discussion #2896)
### Context Feel free to skip this context, and go straight to my question. My team has written some software that uses librpm to retrieve the version and release for every RPM package installed on a system (we use `RPMTAG_VERSION` and `RPMTAG_RELEASE` respectively to retrieve this data). The software component on the host sends an event containing this data to a backend service that performs downstream processing on this data in order to meet the requirements of the larger application. We have observed from our backend service's logs that there is a package that has an empty version string, and an empty release string. Specifically, this it the package information in the event our backend service flagged: * Package name: "appdynamics-machine-agent" * Epoch: "0" * Version: "" * Release: "" * `SOURCERPM` value: "appdynamics-machine-agent---src.rpm" * Vendor: "AppDynamics Inc" The client-side software that generates the events has been distributed and is now running in production. We do not have access to the hosts, as the client runs on customer computers. Therefore, we are not free to SSH onto the host and run `rpm -qa --queryformat` to confirm the data in the event matches the data reported by `rpm` on the host itself. ### Some investigation that I have performed I downloaded what I believe to be an RPM installer for the latest version of this package, and installed the package. I noticed that the data reported on the package by `rpm` is different than the data in the event I describe above: ``` $ rpm -qa --queryformat '%{NAME},%{EPOCH},%{VERSION},%{RELEASE},%{SOURCERPM},%{VENDOR}\n' | grep -i appdynamics appdynamics-machine-agent,0,24.1.0.3984,1,appdynamics-machine-agent-24.1.0.3984-1-src.rpm,AppDynamics Inc ``` I believe the reason why the data is different is because I installed using a newer version of the RPM installer than our customer used when they installed the package on their system. I could not find anywhere on the AppDynamics website that I could download any older versions of the RPM installer. I also tried building an RPM installer from a `.spec` file that omits the `Version` property, but I got the error `Version field must be present in package`. Perhaps this is just because omitting the `Version` is no longer legal in my version of `rpmbuild`, which is version 4.11.3. ### Question Was it ever possible, at any point in the history of RPM, for a RPM package to be created without a version or a release? -- Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/discussions/2896 You are receiving this because you are subscribed to this thread. Message ID: ___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
[Rpm-maint] [rpm-software-management/rpm] If I reuse the same rpmtd for multiple headerGet() or rpmtdGetString() calls, would this cause a memory leak? (Discussion #2492)
I have the following C code: ```c // Compile with: // gcc -Wall -Wextra -Werror -Og -g -lrpm -lrpmio mre.c -o e #include #include #include #include #include #include const char* getString(Header h, rpmTag tag, struct rpmtd_s* td) { if (headerGet(h, tag, td, HEADERGET_DEFAULT)) { return rpmtdGetString(td); } return NULL; } int main() { rpmts ts; Header h; rpmdbMatchIterator mi; rpmReadConfigFiles(NULL, NULL); ts = rpmtsCreate(); if (!ts) { return 1; } mi = rpmtsInitIterator(ts, (rpmTag)RPMDBI_PACKAGES, NULL, 0); if (!mi) { rpmtsFree(ts); return 1; } h = rpmdbNextIterator(mi); if (h == NULL) { return 1; } struct rpmtd_s td; const char* s1 = getString(h, RPMTAG_NAME, &td); if (s1 != NULL) printf("Name: [%s]\n", s1); const char* s2 = getString(h, RPMTAG_VERSION, &td); if (s2 != NULL) printf("Version: [%s]\n", s2); // Note that I only free td once after using it twice rpmtdFreeData(&td); rpmdbFreeIterator(mi); rpmtsFree(ts); rpmFreeMacros(NULL); rpmFreeRpmrc(); return 0; } ``` Since I only free the `td` once, even though I use it twice, is it possible there is a memory leak? I am worried that there might be a memory leak since there is an `xmalloc` [here](https://github.com/rpm-software-management/rpm/blob/rpm-4.18.x/lib/rpmtd.c#L12) and a free [here](https://github.com/rpm-software-management/rpm/blob/rpm-4.18.x/lib/rpmtd.c#L41) and [here](https://github.com/rpm-software-management/rpm/blob/rpm-4.18.x/lib/rpmtd.c#L44). I also wonder if in the stack for either `headerGet()` or `rpmtdGetString()` the `td` might have a new memory allocation. If there is a memory leak in my code above, is the way to avoid a memory leak to use a separate `rpmtd`/`struct rpmtd_s` for each call to my `getString()` function? -- Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/discussions/2492 You are receiving this because you are subscribed to this thread. Message ID: ___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] How can I find details on the binary representation of the RPM DB? (Discussion #2211)
I found that, starting with RPM 4.16, RPM uses an SQLite database ([reference](https://fedoraproject.org/wiki/Changes/RPM-4.16#Detailed_Description)). >From querying my local table, I see there are the following tables: ``` sqlite> .tables Basenames Name Sigmd5 Conflictname Obsoletename Suggestname Dirnames Packages Supplementname Enhancename Providename Transfiletriggername Filetriggername Recommendname Triggername Group Requirename InstalltidSha1header ``` I can look at the schemas of individual tables like so: ``` sqlite> .schema Name CREATE TABLE IF NOT EXISTS 'Name' (key 'TEXT' NOT NULL, hnum INTEGER NOT NULL, idx INTEGER NOT NULL, FOREIGN KEY (hnum) REFERENCES 'Packages'(hnum)); CREATE INDEX 'Name_key_idx' ON 'Name'(key ASC); ``` Is there any documentation for what is stored in each table? For example, it seems the `Name` table stores the names of all of the installed RPM packages, and from the schema for this table I can see that it has a foreign `hnum` key for the `Packages` table. But when I look at the `Packages` table, I can't make sense of the data, since it stores blobs: ``` sqlite> .schema Packages CREATE TABLE IF NOT EXISTS 'Packages' (hnum INTEGER PRIMARY KEY AUTOINCREMENT,blob BLOB NOT NULL); sqlite> select * from Packages limit 10; 1| 2| 3| 4| 5| 6| 7| 8| 9| 10| ``` -- Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/discussions/2211#discussioncomment-3775485 You are receiving this because you are subscribed to this thread. Message ID: ___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
[Rpm-maint] [rpm-software-management/rpm] How to detect RPM version without running rpm --version? (Discussion #2213)
How can the RPM version be detected programmatically (in a language like Go or C) using either a file or a system call, without running a subprocess `rpm --version`? For context, I am writing an application that needs to be highly performant, and I want to avoid running child process if at all possible. -- Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/discussions/2213 You are receiving this because you are subscribed to this thread. Message ID: ___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
[Rpm-maint] [rpm-software-management/rpm] How can I find details on the binary representation of the RPM DB? (Discussion #2211)
I am trying to find an RPM version agnostic way to find details on installed software on any Linux distro that uses RPM packages. A co-worker found for one version of RPM that the magic byte array/slice `[]byte{0, 1, 0x43, 0}` works for extracting each installed package from the RPM DB using regex (I don't know which version this works for). However, this does not work for other RPM versions. Is there any documentation for the binary representation of the RPM DB for each RPM version I could look at? If there is no documentation for this, where can I find the relevant part of the source code for the `rpm` binaries? (My thought is if there is no documentation, I could try reading the source code to figure out how I can extract the information I need from the RPM DB for each RPM version.) -- Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/discussions/2211 You are receiving this because you are subscribed to this thread. Message ID: ___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint