Index: libpkg/pkg_config.c =================================================================== --- libpkg/pkg_config.c (revision 4852) +++ libpkg/pkg_config.c (revision 5658) @@ -73,7 +73,7 @@ const char *desc; }; -static char myabi[BUFSIZ]; +static char myabi[BUFSIZ], myabi_legacy[BUFSIZ]; static struct pkg_repo *repos = NULL; ucl_object_t *config = NULL; @@ -145,6 +145,12 @@ "Override the automatically detected ABI", }, { + PKG_STRING, + "ALTABI", + myabi_legacy, + "Override the automatically detected old-form ABI", + }, + { PKG_BOOL, "DEVELOPER_MODE", "NO", @@ -667,6 +673,7 @@ struct sbuf *ukey = NULL; pkg_get_myarch(myabi, BUFSIZ); + pkg_get_myarch_legacy(myabi_legacy, BUFSIZ); if (parsed != false) { pkg_emit_error("pkg_init() must only be called once"); return (EPKG_FATAL); Property changes on: libpkg/pkg_config.c ___________________________________________________________________ Index: libpkg/pkg_elf.c =================================================================== --- libpkg/pkg_elf.c (revision 4852) +++ libpkg/pkg_elf.c (revision 5658) @@ -584,8 +584,8 @@ #undef MOVE } -int -pkg_get_myarch(char *dest, size_t sz) +static int +pkg_get_myarch_elfparse(char *dest, size_t sz) { Elf *elf = NULL; GElf_Ehdr elfhdr; @@ -668,9 +668,6 @@ else version = le32dec(src); - for (i = 0; osname[i] != '\0'; i++) - osname[i] = (char)tolower(osname[i]); - wordsize_corres_str = elf_corres_to_string(wordsize_corres, (int)elfhdr.e_ident[EI_CLASS]); @@ -805,6 +802,54 @@ } int +pkg_get_myarch_legacy(char *dest, size_t sz) +{ + int i, err; + + err = pkg_get_myarch_elfparse(dest, sz); + if (err) + return (err); + + for (i = 0; i < strlen(dest); i++) + dest[i] = tolower(dest[i]); + + return (0); +} + +int +pkg_get_myarch(char *dest, size_t sz) +{ + struct arch_trans *arch_trans; + char *arch_tweak; + int err; + + err = pkg_get_myarch_elfparse(dest, sz); + if (err) + return (err); + + /* Translate architecture string back to regular OS one */ + arch_tweak = strchr(dest, ':'); + if (arch_tweak == NULL) + return (0); + arch_tweak++; + arch_tweak = strchr(arch_tweak, ':'); + if (arch_tweak == NULL) + return (0); + arch_tweak++; + + for (arch_trans = machine_arch_translation; arch_trans->elftype != NULL; + arch_trans++) { + if (strcmp(arch_tweak, arch_trans->elftype) == 0) { + strlcpy(arch_tweak, arch_trans->archid, + sz - (arch_tweak - dest)); + break; + } + } + + return (0); +} + +int pkg_suggest_arch(struct pkg *pkg, const char *arch, bool isdefault) { bool iswildcard; Property changes on: libpkg/pkg_elf.c ___________________________________________________________________ Index: libpkg/private/elf_tables.h =================================================================== --- libpkg/private/elf_tables.h (revision 4852) +++ libpkg/private/elf_tables.h (revision 5658) @@ -55,7 +55,7 @@ }; static const struct _elf_corres os_corres[] = { - { ELFOSABI_FREEBSD, "freebsd" }, + { ELFOSABI_FREEBSD, "FreeBSD" }, { -1, NULL } }; @@ -68,4 +68,34 @@ #define NT_VERSION 1 #define NT_ARCH 2 +/* All possibilities on FreeBSD as of 5/26/2014 */ +struct arch_trans { + const char *elftype; + const char *archid; +}; + +static struct arch_trans machine_arch_translation[] = { + { "x86:32", "i386" }, + { "x86:64", "amd64" }, + { "powerpc:32", "powerpc" }, + { "powerpc:64", "powerpc64" }, + { "sparc64:64", "sparc64" }, + { "ia64:64", "ia64" }, + /* All the ARM stuff */ + { "arm:32:el:eabi:softfp", "arm" }, + { "arm:32:el:oabi:softfp", "arm" }, + { "arm:32:eb:eabi:softfp", "armeb" }, + { "arm:32:eb:oabi:softfp", "armeb" }, + { "armv6:32:el:eabi:softfp", "armv6" }, + /* And now MIPS */ + { "mips:32:el:o32", "mipsel" }, + { "mips:32:el:n32", "mipsn32el" }, + { "mips:32:eb:o32", "mips" }, + { "mips:32:eb:n32", "mipsn32" }, + { "mips:64:el:n64", "mips64el" }, + { "mips:64:eb:n64", "mips64" }, + + { NULL, NULL } +}; + #endif /* ELF_TABLES_H_ */ Property changes on: libpkg/private/elf_tables.h ___________________________________________________________________ Index: libpkg/utils.c =================================================================== --- libpkg/utils.c (revision 4852) +++ libpkg/utils.c (revision 5658) @@ -482,12 +482,14 @@ bool is_valid_abi(const char *arch, bool emit_error) { - const char *myarch; + const char *myarch, *myarch_legacy; myarch = pkg_object_string(pkg_config_get("ABI")); + myarch_legacy = pkg_object_string(pkg_config_get("ALTABI")); if (fnmatch(arch, myarch, FNM_CASEFOLD) == FNM_NOMATCH && - strncmp(arch, myarch, strlen(myarch)) != 0) { + strncasecmp(arch, myarch, strlen(myarch)) != 0 && + strncasecmp(arch, myarch_legacy, strlen(myarch_legacy)) != 0) { if (emit_error) pkg_emit_error("wrong architecture: %s instead of %s", arch, myarch); Property changes on: libpkg/utils.c ___________________________________________________________________