comparison host/libcdl/database.cxx @ 163:0d2b193a635f

Merge from eCos master repository on 2001-06-22-17:38:39-BST
author jlarmour
date Fri, 22 Jun 2001 18:18:44 +0000
parents b939e9cada46
children fbfd52cf7976
comparison
equal deleted inserted replaced
162:2395031e7a66 163:0d2b193a635f
70 // ---------------------------------------------------------------------------- 70 // ----------------------------------------------------------------------------
71 // Some test cases may want to read in a file other than 71 // Some test cases may want to read in a file other than
72 // "ecos.db", e.g. to facilitate testing the error conditions. 72 // "ecos.db", e.g. to facilitate testing the error conditions.
73 char* 73 char*
74 CdlPackagesDatabaseBody::database_name = "ecos.db"; 74 CdlPackagesDatabaseBody::database_name = "ecos.db";
75
76 // Should warnings be issued for minor database inconsistencies?
77 bool CdlPackagesDatabaseBody::verbose_mode = false;
75 78
76 // The new_package etc. commands need to store the name of the 79 // The new_package etc. commands need to store the name of the
77 // current package so that subsequent commands can do the right thing. 80 // current package so that subsequent commands can do the right thing.
78 // Using constant strings as the key avoids typo problems. 81 // Using constant strings as the key avoids typo problems.
79 const char* dbparser_pkgname = "::dbparser_pkgname"; 82 const char* dbparser_pkgname = "::dbparser_pkgname";
199 } 202 }
200 if (0 == package.aliases.size()) { 203 if (0 == package.aliases.size()) {
201 CdlParse::report_error(interp, diag_package + pkg_name, "At least one alias should be supplied."); 204 CdlParse::report_error(interp, diag_package + pkg_name, "At least one alias should be supplied.");
202 } 205 }
203 206
204 // Additional checks. Is the package directory actually present. 207 // Additional checks. Is the package directory actually present?
208 // Note that there are scenarios where a package may be listed
209 // in the database but not installed, e.g. an anoncvs checkout
210 // of selected modules.
205 if ("" != package.directory) { 211 if ("" != package.directory) {
206 std::string repo = interp->get_variable(dbparser_component_repository); 212 std::string repo = interp->get_variable(dbparser_component_repository);
207 CYG_ASSERTC("" != repo); 213 CYG_ASSERTC("" != repo);
208 214
209 std::string pkgdir = repo + "/" + package.directory; 215 std::string pkgdir = repo + "/" + package.directory;
210 if (!interp->is_directory(pkgdir)) { 216 if (!interp->is_directory(pkgdir)) {
211 CdlParse::report_warning(interp, diag_package + pkg_name, 217 if (CdlPackagesDatabaseBody::verbose_mode) {
212 std::string("This package is not present in the component repository.\nThere is no directory `") 218 CdlParse::report_warning(interp, diag_package + pkg_name,
213 + pkgdir + "'."); 219 std::string("This package is not present in the component repository.\n"
220 "There is no directory `") + pkgdir + "'.");
221 }
214 package_ok = false; 222 package_ok = false;
215 } else { 223 } else {
216 224
217 // Now look for version subdirectories. There should be at least one. 225 // Now look for version subdirectories. There should be at least one.
218 std::vector<std::string> subdirs; 226 std::vector<std::string> subdirs;
806 } 814 }
807 } 815 }
808 816
809 // Consistency checks. All target-specific packages should 817 // Consistency checks. All target-specific packages should
810 // have the hardware attribute. Also, all the packages should 818 // have the hardware attribute. Also, all the packages should
811 // exist. Problems only result in warnings, to allow for 819 // exist. Problems only result in warnings and only when
812 // somewhat inconsistent repositories e.g. an anoncvs tree. 820 // operating in verbose mode, to allow for somewhat
813 std::vector<std::string>::const_iterator name_i; 821 // inconsistent repositories e.g. an anoncvs tree.
814 std::vector<std::string>::const_iterator name_j; 822 if (CdlPackagesDatabaseBody::verbose_mode) {
815 for (name_i = target_names.begin(); name_i != target_names.end(); name_i++) { 823 std::vector<std::string>::const_iterator name_i;
816 for (name_j = targets[*name_i].packages.begin(); name_j != targets[*name_i].packages.end(); name_j++) { 824 std::vector<std::string>::const_iterator name_j;
817 if (std::find(package_names.begin(), package_names.end(), *name_j) == package_names.end()) { 825 for (name_i = target_names.begin(); name_i != target_names.end(); name_i++) {
818 CdlParse::report_warning(interp, diag_target + *name_i, 826 for (name_j = targets[*name_i].packages.begin(); name_j != targets[*name_i].packages.end(); name_j++) {
819 std::string("This target refers to an unknown package `") + *name_j + "'."); 827 if (std::find(package_names.begin(), package_names.end(), *name_j) == package_names.end()) {
820 } 828 CdlParse::report_warning(interp, diag_target + *name_i,
821 if (!packages[*name_j].hardware) { 829 std::string("This target refers to an unknown package `") + *name_j + "'.");
822 CdlParse::report_warning(interp, diag_target + *name_i, 830 }
823 std::string("This target refers to a package `") + *name_j + 831 if (!packages[*name_j].hardware) {
824 "' that is not hardware-specific."); 832 CdlParse::report_warning(interp, diag_target + *name_i,
833 std::string("This target refers to a package `") + *name_j +
834 "' that is not hardware-specific.");
835 }
825 } 836 }
826 } 837 }
827 } 838 }
828
829 // Now, were there any errors while reading in the database? 839 // Now, were there any errors while reading in the database?
830 // If so it is necessary to throw an exception here, to make sure 840 // If so it is necessary to throw an exception here, to make sure
831 // that things get cleaned up properly. 841 // that things get cleaned up properly.
832 int error_count = CdlParse::get_error_count(interp); 842 int error_count = CdlParse::get_error_count(interp);
833 if (0 != error_count) { 843 if (0 != error_count) {
967 977
968 CYG_REPORT_RETURN(); 978 CYG_REPORT_RETURN();
969 return component_repository; 979 return component_repository;
970 } 980 }
971 981
982 void
983 CdlPackagesDatabaseBody::set_verbose(bool new_mode)
984 {
985 CYG_REPORT_FUNCNAME("CdlPackagesDatabase::set_verbose");
986 CYG_REPORT_FUNCARG1XV(new_mode);
987
988 verbose_mode = new_mode;
989
990 CYG_REPORT_RETURN();
991 }
992
972 //}}} 993 //}}}
973 //{{{ CdlPackagesDatabase:: get package information 994 //{{{ CdlPackagesDatabase:: get package information
974 995
975 // ---------------------------------------------------------------------------- 996 // ----------------------------------------------------------------------------
976 997