+
+ case RPMLIST:
+ // Scan a list of packages and versions from "rpm -a".
+ // A similar listing can be created on IRIX 6.5 by using the
+ // command "showprods -3 -n|awk '{printf "%s-%s\n",$2,$3}'|grep -v ^[-=] \
+ // |grep -v Version-Description".
+ //
+ // We have to separate the package name and the version.
+ // The separation is marked by a '-', followed by a digit.
+
+ i = line.index('-');
+ while (!(line[i] == '-' && isdigit(line[i + 1])))
+ {
+ i++;
+ }
+ String package(line(0,i));
+ String version(line(i+1, ~line));
+ String paramid;
+
+ if (verbose)
+ {
+ std::cout << "Package is " << package;
+ std::cout << ", version is " << version << "\n";
+ }
+
+ // Construct a qry to check the package's existance
+
+ String qry = "select paramid from parameter where objectid='";
+ qry += objectid + "' and class='package' and name='";
+ qry += package + "'";
+
+ if (database.Query(qry) == 1)
+ {
+ paramid = database.Field(0, "paramid");
+ qry = "select value from property where paramid='";
+ qry += paramid + "' and name='version'";
+ if (database.Query(qry) == 0)
+ {
+ std::cerr << "Database corruption: Package " << package;
+ std::cerr << " does not have a 'version' property.\n";
+ }
+ else if (database.Field(0, "value") != version)
+ {
+ if (verbose)
+ {
+ std::cout << " Parameter " << package << " has different version\n";
+ }
+ }
+ else
+ {
+ if (verbose)
+ {
+ std::cout << " Parameter " << package << " has not changed.\n";
+ }
+ }
+ }
+ else
+ {
+ String insert_h;
+
+ if (verbose)
+ {
+ std::cout << " Parameter " << package << " does not exist.\n";
+ }
+ // Create a new package parameter, including version property and history record
+
+ insertion = "insert into parameter (objectid, name, class, description) values ('";
+ insertion += objectid + "', '" + package + "', 'package', 'RPM package " + package + "')";
+ if (testmode)
+ {
+ paramid = "0";
+ std::cout << insertion << "\n";
+ }
+ else
+ {
+ database.Query(insertion);
+ qry = "select paramid from parameter where objectid='";
+ qry += objectid + "' and class='package' and name='";
+ qry += package + "'";
+ database.Query(qry);
+ paramid = database.Field(0, "paramid");
+ }
+
+ insertion = "insert into property (paramid, name, value, type) values ('";
+ insertion += paramid + "', 'version', '";
+ insertion += version + "', 'STATIC')";
+ insert_h = "insert into history (paramid, modified, change_nature, changed_property, new_value)";
+ insert_h += " values ('";
+ insert_h += paramid + "', '" + arrival.format() + "', 'CREATED', 'version', '";
+ insert_h += version + "')";
+
+ if (testmode)
+ {
+ std::cout << insertion << "\n" << insert_h << "\n";
+ }
+ else
+ {
+ database.Query(insertion);
+ database.Query(insert_h);
+ }
+ }
+
+ if (verbose)
+ {
+ std::cout << "\n";
+ }
+
+ nr_lines++;
+ break;
+