|
71 | 71 | #define NT_ABI_TAG 1
|
72 | 72 | #endif
|
73 | 73 |
|
| 74 | +#define _PATH_UNAME "/usr/bin/uname" |
| 75 | + |
74 | 76 | /* FFR: when we support installing a 32bit package on a 64bit host */
|
75 | 77 | #define _PATH_ELF32_HINTS "/var/run/ld-elf32.so.hints"
|
76 | 78 |
|
@@ -716,32 +718,41 @@ pkg_get_myarch_elfparse(char *dest, size_t sz, int *osversion)
|
716 | 718 | Elf_Data *data;
|
717 | 719 | Elf_Note note;
|
718 | 720 | Elf_Scn *scn = NULL;
|
719 |
| - int fd; |
| 721 | + int fd, i; |
720 | 722 | int version_style = 1;
|
721 | 723 | char *src = NULL;
|
722 | 724 | char *osname;
|
723 | 725 | uint32_t version = 0;
|
724 | 726 | int ret = EPKG_OK;
|
725 | 727 | const char *arch, *abi, *endian_corres_str, *wordsize_corres_str, *fpu;
|
726 |
| - const char *path; |
727 | 728 | char invalid_osname[] = "Unknown";
|
728 | 729 | char *note_os[6] = {"Linux", "GNU", "Solaris", "FreeBSD", "NetBSD", "Syllable"};
|
729 | 730 | char *(*pnote_os)[6] = ¬e_os;
|
730 | 731 | uint32_t gnu_abi_tag[4];
|
731 | 732 |
|
732 |
| - path = getenv("ABI_FILE"); |
733 |
| - if (path == NULL) |
734 |
| - path = _PATH_BSHELL; |
| 733 | + const char *abi_files[] = { |
| 734 | + getenv("ABI_FILE"), |
| 735 | + _PATH_UNAME, |
| 736 | + _PATH_BSHELL, |
| 737 | + }; |
735 | 738 |
|
736 | 739 | if (elf_version(EV_CURRENT) == EV_NONE) {
|
737 | 740 | pkg_emit_error("ELF library initialization failed: %s",
|
738 | 741 | elf_errmsg(-1));
|
739 | 742 | return (EPKG_FATAL);
|
740 | 743 | }
|
741 | 744 |
|
742 |
| - if ((fd = open(path, O_RDONLY)) < 0) { |
743 |
| - pkg_emit_errno("open", _PATH_BSHELL); |
744 |
| - snprintf(dest, sz, "%s", "unknown"); |
| 745 | + for (fd = -1, i = 0; i < nitems(abi_files); i++) { |
| 746 | + if (abi_files[i] == NULL) |
| 747 | + continue; |
| 748 | + if ((fd = open(abi_files[i], O_RDONLY)) >= 0) |
| 749 | + break; |
| 750 | + /* if the ABI_FILE was provided we only care about it */ |
| 751 | + if (i == 0) |
| 752 | + break; |
| 753 | + } |
| 754 | + if (fd == -1) { |
| 755 | + pkg_emit_error("Unable to determine the ABI\n"); |
745 | 756 | return (EPKG_FATAL);
|
746 | 757 | }
|
747 | 758 |
|
|
0 commit comments