pkg

Check-in [76e860af2f]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:pkg-repo: Only show progress bar when outputting to a TTY
Timelines: family | ancestors | descendants | both | trunk | gsoc2013
Files: files | file ages | folders
SHA1: 76e860af2f1f837b926b0c27a9957d44df520760
User & Date: bryan@shatow.net 2014-06-11 16:04:27
Context
2014-06-11
16:11
Only show event progressbar if stdout is a tty check-in: 7a0d173b26 user: bryan@shatow.net tags: trunk, gsoc2013
16:04
pkg-repo: Only show progress bar when outputting to a TTY check-in: 76e860af2f user: bryan@shatow.net tags: trunk, gsoc2013
15:32
Release 1.3.0 b3 Leaf check-in: a5dad51277 user: bapt@FreeBSD.org tags: trunk, gsoc2013, 1.3.0.b3
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/repo.c.

88
89
90
91
92
93
94


95
96
97
98
99
100
101



102
103
104
105
106
107
108
...
130
131
132
133
134
135
136
137
138




139

140
141
142
143
144
145

146


147
148
149
150
151
152
153
154
exec_repo(int argc, char **argv)
{
	int	 ret;
	int	 pos = 0;
	int	 ch;
	bool	 filelist = false;
	char	*output_dir = NULL;



	struct option longopts[] = {
		{ "list-files", no_argument,		NULL,	'l' },
		{ "output-dir", required_argument,	NULL,	'o' },
		{ "quiet",	no_argument,		NULL,	'q' },
		{ NULL,		0,			NULL,	0   },
	};




	while ((ch = getopt_long(argc, argv, "lo:q", longopts, NULL)) != -1) {
		switch (ch) {
		case 'l':
			filelist = true;
			break;
		case 'o':
................................................................................
	}

	if (output_dir == NULL)
		output_dir = argv[0];

	if (!quiet) {
		printf("Generating repository catalog in %s:  ", argv[0]);
		ret = pkg_create_repo(argv[0], output_dir, filelist, progress, &pos);
	} else




		ret = pkg_create_repo(argv[0], output_dir, filelist, NULL, NULL);


	if (ret != EPKG_OK) {
		printf("Cannot create repository catalogue\n");
		return (EX_IOERR);
	} else {
		if (!quiet)

			printf("\bdone!\n");


	}
	
	if (pkg_finish_repo(output_dir, password_cb, argv + 1, argc - 1,
	    filelist) != EPKG_OK)
		return (EX_DATAERR);

	return (EX_OK);
}







>
>







>
>
>







 







|
|
>
>
>
>
|
>





|
>
|
>
>








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
...
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
exec_repo(int argc, char **argv)
{
	int	 ret;
	int	 pos = 0;
	int	 ch;
	bool	 filelist = false;
	char	*output_dir = NULL;
	void	(*progress_fn)(struct pkg *, void *);
	int	*pos_ptr;

	struct option longopts[] = {
		{ "list-files", no_argument,		NULL,	'l' },
		{ "output-dir", required_argument,	NULL,	'o' },
		{ "quiet",	no_argument,		NULL,	'q' },
		{ NULL,		0,			NULL,	0   },
	};

	progress_fn = NULL;
	pos_ptr = NULL;

	while ((ch = getopt_long(argc, argv, "lo:q", longopts, NULL)) != -1) {
		switch (ch) {
		case 'l':
			filelist = true;
			break;
		case 'o':
................................................................................
	}

	if (output_dir == NULL)
		output_dir = argv[0];

	if (!quiet) {
		printf("Generating repository catalog in %s:  ", argv[0]);
		if (isatty(STDOUT_FILENO)) {
			progress_fn = progress;
			pos_ptr = &pos;
		}
	}

	ret = pkg_create_repo(argv[0], output_dir, filelist, progress_fn,
	    pos_ptr);

	if (ret != EPKG_OK) {
		printf("Cannot create repository catalogue\n");
		return (EX_IOERR);
	} else {
		if (!quiet) {
			if (progress_fn != NULL)
				printf("\b");
			printf("done!\n");
		}
	}
	
	if (pkg_finish_repo(output_dir, password_cb, argv + 1, argc - 1,
	    filelist) != EPKG_OK)
		return (EX_DATAERR);

	return (EX_OK);
}