summaryrefslogtreecommitdiffstats
path: root/meta/packages/oprofile/oprofile/oparchive-list-files.patch
blob: 8d92efead673d5330599f4de7350e5b7513c4f0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
Index: oprofile/pp/oparchive.cpp
===================================================================
--- oprofile.orig/pp/oparchive.cpp
+++ oprofile/pp/oparchive.cpp
@@ -35,6 +35,11 @@ namespace {
 
 void copy_one_file(image_error err, string const & source, string const & dest)
 {
+	if (options::list_files) {
+		cout << source << endl;
+		return;
+	}
+
 	if (!copy_file(source, dest) && err == image_ok) {
 		cerr << "can't copy from " << source << " to " << dest
 		     << " cause: " << strerror(errno) << endl;
@@ -46,7 +51,7 @@ int oparchive(options::spec const & spec
 	handle_options(spec);
 
 	/* Check to see if directory can be created */
-	if (create_path(options::outdirectory.c_str())) {
+	if (!options::list_files && create_path(options::outdirectory.c_str())) {
 		cerr << "Unable to create directory for " 
 		     <<	options::outdirectory << "." << endl;
 		exit (EXIT_FAILURE);
@@ -73,7 +78,8 @@ int oparchive(options::spec const & spec
 
 		cverb << vdebug << exe_name << endl;
 		/* Create directory for executable file. */
-		if (create_path(exe_archive_file.c_str())) {
+		if (!options::list_files
+				&& create_path(exe_archive_file.c_str())) {
 			cerr << "Unable to create directory for "
 			     << exe_archive_file << "." << endl;
 			exit (EXIT_FAILURE);
@@ -100,7 +106,8 @@ int oparchive(options::spec const & spec
 				/* found something copy it over */
 				string dest_debug_dir = options::outdirectory +
 					dirname + "/.debug/";
-				if (create_dir(dest_debug_dir.c_str())) {
+				if (!options::list_files
+						&& create_dir(dest_debug_dir.c_str())) {
 					cerr << "Unable to create directory: "
 					<< dest_debug_dir << "." << endl;
 					exit (EXIT_FAILURE);
@@ -130,7 +137,8 @@ int oparchive(options::spec const & spec
 		
 		cverb << vdebug << (sample_name) << endl;
 		cverb << vdebug << " destp " << sample_archive_file << endl;
-		if (create_path(sample_archive_file.c_str())) {
+		if (!options::list_files
+				&& create_path(sample_archive_file.c_str())) {
 			cerr << "Unable to create directory for "
 			     <<	sample_archive_file << "." << endl;
 			exit (EXIT_FAILURE);
Index: oprofile/pp/oparchive_options.cpp
===================================================================
--- oprofile.orig/pp/oparchive_options.cpp
+++ oprofile/pp/oparchive_options.cpp
@@ -36,6 +36,7 @@ namespace options {
 	bool exclude_dependent;
 	merge_option merge_by;
 	string outdirectory;
+	bool list_files;
 }
 
 
@@ -47,7 +48,9 @@ popt::option options_array[] = {
 	popt::option(options::outdirectory, "output-directory", 'o',
 	             "output to the given directory", "directory"),
 	popt::option(options::exclude_dependent, "exclude-dependent", 'x',
-		     "exclude libs, kernel, and module samples for applications")
+		     "exclude libs, kernel, and module samples for applications"),
+	popt::option(options::list_files, "list-files", 'l',
+		     "just list the files necessary, don't produce the archive")
 };
 
 
@@ -60,7 +63,7 @@ void check_options()
 	using namespace options;
 
 	/* output directory is required */
-	if (outdirectory.size() == 0) {
+	if (outdirectory.size() == 0 && !list_files) {
 		cerr << "Requires --output-directory option." << endl;
 		exit(EXIT_FAILURE);
 	}
Index: oprofile/pp/oparchive_options.h
===================================================================
--- oprofile.orig/pp/oparchive_options.h
+++ oprofile/pp/oparchive_options.h
@@ -22,6 +22,7 @@ namespace options {
 	extern bool exclude_dependent;
 	extern merge_option merge_by;
 	extern std::string outdirectory;
+	extern bool list_files;
 }
 
 /// All the chosen sample files.
Index: oprofile/ChangeLog
===================================================================
--- oprofile.orig/ChangeLog
+++ oprofile/ChangeLog
@@ -1,5 +1,12 @@
 2007-05-09  Richard Purdie  <rpurdie@openedhand.com>
 
+	* oparchive.cpp:
+	* oparchive_options.cpp:
+	* oparchive_options.h: Add --list-files option to list all files that
+	would be handled by oparchive.
+
+2007-05-09  Richard Purdie  <rpurdie@openedhand.com>
+
 	* oprofile/pp/oparchive.cpp: If the debug files have the same name
 	as the original binary, the binary gets overwritten. Add in a .debug
 	directory to avoid this.
Index: oprofile/doc/oparchive.1.in
===================================================================
--- oprofile.orig/doc/oparchive.1.in
+++ oprofile/doc/oparchive.1.in
@@ -50,6 +50,10 @@ Output to the given directory. There is 
 Do not include application-specific images for libraries, kernel modules
 and the kernel. This option only makes sense if the profile session
 used --separate.
+.br
+.TP
+.BI "--list-files / -l"
+Only list the files that would be archived, don't copy them.
 
 .SH ENVIRONMENT
 No special environment variables are recognised by oparchive.