pkg

Check-in [5aa88d42b2]
Login

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

Overview
Comment:Pkg cache: Fix symlinks not being updated. Do this atomically with rename(2).
Timelines: family | ancestors | descendants | both | trunk | gsoc2013
Files: files | file ages | folders
SHA1: 5aa88d42b2c53951eb2dceb0ed16660849e05458
User & Date: bryan@shatow.net 2014-06-11 16:50:45
Context
2014-06-11
17:33
Fix pkgdb_load_rdeps by reverting "Avoid deps full scan when loading dependencies." This reverts commit cf47e2c24af23c8f278d9c502fe2923a42f23d33. 1. deps should be joined on p.id=d.package_id rather than origin. Otherwise no results are returned breaking pkg-query %r, pkg-autoremove, etc. 2. Restore uniqueid support [1] Discussed with: bapt [1] Fixes #833 check-in: b295691032 user: bryan@shatow.net tags: trunk, gsoc2013
16:50
Pkg cache: Fix symlinks not being updated. Do this atomically with rename(2). check-in: 5aa88d42b2 user: bryan@shatow.net tags: trunk, gsoc2013
16:33
When fetching outside a TTY still give some feedback if not running in quiet check-in: 7a7b93b651 user: bryan@shatow.net tags: trunk, gsoc2013
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to libpkg/pkg_repo.c.

109
110
111
112
113
114
115
116

117
118
119
120
121
122
123
124
125
...
208
209
210
211
212
213
214










215
216
217
218


219
220
221
222
223
224
225
				cachedir, pkg, pkg, pkg);
	}
}

int
pkg_repo_fetch_package(struct pkg *pkg)
{
	char dest[MAXPATHLEN], link_dest[MAXPATHLEN];

	char url[MAXPATHLEN];
	int fetched = 0;
	char cksum[SHA256_DIGEST_LENGTH * 2 +1];
	int64_t pkgsize;
	struct stat st;
	char *path = NULL;
	const char *packagesite = NULL, *dest_fname = NULL, *ext = NULL;

	int retcode = EPKG_OK;
................................................................................
	if (retcode != EPKG_OK)
		unlink(dest);
	else if (path != NULL) {
		/* Create symlink from full pkgname */
		ext = strrchr(dest, '.');
		pkg_snprintf(link_dest, sizeof(link_dest), "%S/%n-%v%S",
		    path, pkg, pkg, ext ? ext : "");










		if ((dest_fname = strrchr(dest, '/')) != NULL)
			++dest_fname;
		if (symlink(dest_fname, link_dest))
			pkg_emit_errno("symlink", link_dest);


	}

	if (path != NULL)
		free(path);

	return (retcode);
}







|
>

|







 







>
>
>
>
>
>
>
>
>
>


|
|
>
>







109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
...
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
				cachedir, pkg, pkg, pkg);
	}
}

int
pkg_repo_fetch_package(struct pkg *pkg)
{
	char dest[MAXPATHLEN], link_dest[MAXPATHLEN],
	     link_dest_tmp[MAXPATHLEN];
	char url[MAXPATHLEN];
	int sym_fd, fetched = 0;
	char cksum[SHA256_DIGEST_LENGTH * 2 +1];
	int64_t pkgsize;
	struct stat st;
	char *path = NULL;
	const char *packagesite = NULL, *dest_fname = NULL, *ext = NULL;

	int retcode = EPKG_OK;
................................................................................
	if (retcode != EPKG_OK)
		unlink(dest);
	else if (path != NULL) {
		/* Create symlink from full pkgname */
		ext = strrchr(dest, '.');
		pkg_snprintf(link_dest, sizeof(link_dest), "%S/%n-%v%S",
		    path, pkg, pkg, ext ? ext : "");
		/* Create a unique filename, avoiding annoying warning
		 * from more useful mktemp(). */
		snprintf(link_dest_tmp, sizeof(link_dest_tmp), "%s.new",
		    link_dest);
		if ((sym_fd = mkstemp(link_dest_tmp)) == -1)
			pkg_emit_error("mkstemp", link_dest_tmp);
		close(sym_fd);
		if (unlink(link_dest_tmp))
			pkg_emit_errno("unlink", link_dest_tmp);
		/* Trim the path to just the filename. */
		if ((dest_fname = strrchr(dest, '/')) != NULL)
			++dest_fname;
		if (symlink(dest_fname, link_dest_tmp))
			pkg_emit_errno("symlink", link_dest_tmp);
		if (rename(link_dest_tmp, link_dest))
			pkg_emit_errno("rename", link_dest);
	}

	if (path != NULL)
		free(path);

	return (retcode);
}