Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 200087 Details for
Bug 279915
Shebang line of /usr/bin/emerge is interpreted incorrectly when app-admin/eselect-python-20090801 is installed and Linux <2.6.28 or non-Linux kernel is used
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
wrapper for python
python-wrapper.c (text/plain), 1.95 KB, created by
Jonathan Callen (RETIRED)
on 2009-08-04 01:42:24 UTC
(
hide
)
Description:
wrapper for python
Filename:
MIME Type:
Creator:
Jonathan Callen (RETIRED)
Created:
2009-08-04 01:42:24 UTC
Size:
1.95 KB
patch
obsolete
>/* Copyright 1999-2009 Gentoo Foundation > * Distributed under the terms of the GNU General Public License v2 > */ > >#include <dirent.h> >#include <stdlib.h> >#include <stdio.h> >#include <string.h> >#include <unistd.h> >#include <sys/stat.h> > >#define ENVD_CONFIG "/etc/env.d/python/config" > >int valid_interpreter(const char* name) { > /* name must match exactly "pythonX.Y", where the X is between 2 and 9, > * and Y is between 0 and 9 > */ > if (!name || (strcmp(name, "python") == 0) || (strncmp(name, "python", 6) != 0) || strchr(name, '/') || > strlen(name) != 9 || name[6] < '2' || name[6] > '9' || name[7] != '.' || name[8] < '0' || name[8] > '9') { > return 0; > } > return 1; >} > >const char* find_latest() >{ > int major = -1; > int minor = -1; > DIR* d = opendir("/usr/bin"); > if (!d) > return NULL; > struct dirent *entry; > while (entry = readdir(d)) > { > const char* name = entry->d_name; > if (valid_interpreter(name)) > { > int newmajor = name[7]; > int newminor = name[9]; > /* prefer 2.* to anything later, but otherwise take the latest > * version > */ > if (newmajor == major && newminor > minor || newmajor == '2' && major != '2' || major != '2' && newmajor > major) > { > major = newmajor; > minor = newminor; > } > } > } > if (major > 0 && minor > 0) { > char pattern[10] = "python0.0"; > pattern[7] = major; > pattern[9] = minor; > char *ret = malloc(10); > strncpy(ret, pattern, 10); > return ret; > } > return NULL; >} > >int main(int argc, char** argv) >{ > const char* EPYTHON = getenv("EPYTHON"); > if (!valid_interpreter(EPYTHON)) > { > FILE* f = fopen(ENVD_CONFIG, "r"); > if (f) > { > struct stat st; > fstat(fileno(f), &st); > size_t size = st.st_size; > char* cont = malloc(size + 1); > fgets(cont, size + 1, f); > fclose(f); > size_t len = strlen(cont); > if (len && cont[len - 1] == '\n') > cont[len - 1] = 0; > EPYTHON = cont; > } > } > > if (!valid_interpreter(EPYTHON)) > EPYTHON = find_latest(); > > if (!EPYTHON) > return 127; > > execvp(EPYTHON, argv); > return 127; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 279915
:
199927
|
199932
|
199940
|
200017
|
200027
|
200065
|
200082
|
200087
|
200095
|
200127