Blame SOURCES/oprofile-bz1264443.patch

d5df0a
diff -up oprofile-0.9.9/libpp/profile_spec.cpp.archive oprofile-0.9.9/libpp/profile_spec.cpp
d5df0a
--- oprofile-0.9.9/libpp/profile_spec.cpp.archive	2013-07-29 11:55:06.000000000 -0400
d5df0a
+++ oprofile-0.9.9/libpp/profile_spec.cpp	2016-07-06 11:20:55.076624764 -0400
d5df0a
@@ -102,6 +102,8 @@ void profile_spec::set_image_or_lib_name
d5df0a
 void profile_spec::parse_archive_path(string const & str)
d5df0a
 {
d5df0a
 	archive_path = op_realpath(str);
d5df0a
+	/* Need to force session directory default location in the archive */
d5df0a
+	init_op_config_dirs(OP_SESSION_DIR_DEFAULT);
d5df0a
 }
d5df0a
 
d5df0a
 
d5df0a
diff -up oprofile-0.9.9/pp/oparchive.cpp.archive oprofile-0.9.9/pp/oparchive.cpp
d5df0a
--- oprofile-0.9.9/pp/oparchive.cpp.archive	2013-07-29 11:55:06.000000000 -0400
d5df0a
+++ oprofile-0.9.9/pp/oparchive.cpp	2016-07-06 11:20:55.076624764 -0400
d5df0a
@@ -232,6 +232,19 @@ int oparchive(options::spec const & spec
d5df0a
 		}
d5df0a
 	}
d5df0a
 
d5df0a
+	/* place samples and other related material in easily found default directory */
d5df0a
+	string dest_session_dir = options::outdirectory + string(OP_SESSION_DIR_DEFAULT);
d5df0a
+	string dest_samples_dir = dest_session_dir + string("samples");
d5df0a
+
d5df0a
+	/* dest_session_dir is parent of dest_samples and will also created */
d5df0a
+
d5df0a
+	if (!options::list_files &&
d5df0a
+	    create_path(dest_samples_dir.c_str())) {
d5df0a
+		cerr << "Unable to create directory for "
d5df0a
+		     <<	dest_samples_dir << "." << endl;
d5df0a
+		exit (EXIT_FAILURE);
d5df0a
+	}
d5df0a
+
d5df0a
 	/* copy over each of the sample files */
d5df0a
 	list<string>::iterator sit = sample_files.begin();
d5df0a
 	list<string>::iterator const send = sample_files.end();
d5df0a
@@ -245,9 +258,13 @@ int oparchive(options::spec const & spec
d5df0a
 
d5df0a
 	for (; sit != send; ++sit) {
d5df0a
 		string sample_name = *sit;
d5df0a
+		/* determine the session name of sample file */
d5df0a
+		int offset = sample_name.find('{');
d5df0a
+		string base_samples_dir = sample_name.substr(0, offset-1);
d5df0a
+		string session = basename(base_samples_dir.c_str());
d5df0a
 		/* Get rid of the the archive_path from the name */
d5df0a
-		string sample_base = sample_name.substr(archive_path.size());
d5df0a
-		string sample_archive_file = options::outdirectory + sample_base;
d5df0a
+		string sample_base = sample_name.substr(offset);
d5df0a
+		string sample_archive_file = dest_samples_dir + "/" + session + "/" + sample_base;
d5df0a
 		
d5df0a
 		cverb << vdebug << sample_name << endl;
d5df0a
 		cverb << vdebug << " destp " << sample_archive_file << endl;
d5df0a
@@ -268,19 +285,19 @@ int oparchive(options::spec const & spec
d5df0a
 		cerr << "Unable to to obtain realpath for " << op_session_dir << endl;
d5df0a
 		exit (EXIT_FAILURE);
d5df0a
 	}
d5df0a
-	string abi_name = string(real_session_dir) + "/abi";
d5df0a
-	copy_one_file(image_ok, archive_path + abi_name,
d5df0a
-	              options::outdirectory + abi_name);
d5df0a
+	string abi_name = string(real_session_dir) + string("/abi");
d5df0a
+	string dest_abi_name = dest_session_dir + string("/abi");
d5df0a
+	copy_one_file(image_ok, archive_path + abi_name, dest_abi_name);
d5df0a
 
d5df0a
 	/* copy over the <session-dir>/samples/oprofiled.log file */
d5df0a
-	string log_name = string(real_session_dir) + string("/samples") + "/oprofiled.log";
d5df0a
-	copy_one_file(image_ok, archive_path + log_name,
d5df0a
-	              options::outdirectory + log_name);
d5df0a
+	string log_name = string(real_session_dir) + string("/samples") + string("/oprofiled.log");
d5df0a
+	string dest_log_name = dest_samples_dir + string("/oprofiled.log");
d5df0a
+	copy_one_file(image_ok, archive_path + log_name, dest_log_name);
d5df0a
 
d5df0a
 	/* copy over the <session-dir>/samples/operf.log file */
d5df0a
-	log_name = string(real_session_dir) + string("/samples") + "/operf.log";
d5df0a
-	copy_one_file(image_ok, archive_path + log_name,
d5df0a
-	              options::outdirectory + log_name);
d5df0a
+	log_name = string(real_session_dir) + string("/samples") + string("/operf.log");
d5df0a
+	dest_log_name = dest_samples_dir + string("/operf.log");
d5df0a
+	copy_one_file(image_ok, archive_path + log_name, dest_log_name);
d5df0a
 
d5df0a
 	free(real_session_dir);
d5df0a
 
d5df0a
diff -up oprofile-0.9.9/pp/oparchive_options.cpp.archive oprofile-0.9.9/pp/oparchive_options.cpp
d5df0a
--- oprofile-0.9.9/pp/oparchive_options.cpp.archive	2016-07-06 11:20:55.077624764 -0400
d5df0a
+++ oprofile-0.9.9/pp/oparchive_options.cpp	2016-07-06 11:26:13.968624764 -0400
d5df0a
@@ -124,7 +124,6 @@ void handle_options(options::spec const
d5df0a
 
d5df0a
 	if (strncmp(op_session_dir, "/var/lib/oprofile", strlen("/var/lib/oprofile")))
d5df0a
 		cerr << "NOTE: The sample data in this archive is located at " << op_session_dir << endl
d5df0a
-		     << "instead of the standard location of /var/lib/oprofile.  Hence, when using opreport" << endl
d5df0a
-		     << "and other post-processing tools on this archive, you must pass the following option:" << endl
d5df0a
-		     << "\t--session-dir=" << op_session_dir << endl;
d5df0a
+		     << "and is being moved to the standard location of " << OP_SESSION_DIR_DEFAULT << "."
d5df0a
+		     << endl;
d5df0a
 }