- sqlite3_prepare_v2(db, "insert into elflibraries (file,soname) values (?,?)",-1, &ifile, 0);
- sqlite3_bind_text(ifile,1,hash,64,SQLITE_STATIC);
- sqlite3_bind_text(ifile,2,soname,-1,SQLITE_STATIC);
- rc = sqlite3_step(ifile);
- if (rc != SQLITE_DONE) {
- SQLERROR(sqlite3_errmsg(db));
- sqlite3_finalize(ifile);
- fprintf(stderr, "error setting library soname\n");
- return 0;
- }
- sqlite3_finalize(ifile);
- } else {
- fprintf(stderr, "can't find soname\n");
+ if (!run_for_hash(db, "delete from elfneeded where file = ?", hash)) {
+ SQLERP(db, "error clearing elf needed");
+ return 0;
+ }
+
+ hdr = libelf_header(content);
+ /* if lib, set soname */
+ if (libelf_type(content) == ET_DYN) {
+ char *soname = libelf_soname(content);
+ if (soname) {
+ zpm_db_run(zpm, "insert into elflibraries (file,soname) values (%Q,%Q);", hash, soname);
+ if (zpm->error) {
+ return 0;