commit 85deee57f2b5ab6b1a4d8e4cf38ca8a8a7be4744 Author: overweight <5324761+overweight@user.noreply.gitee.com> Date: Mon Sep 30 10:40:45 2019 -0400 Package init diff --git a/LicenseList b/LicenseList new file mode 100644 index 0000000..bcffe7a --- /dev/null +++ b/LicenseList @@ -0,0 +1,26 @@ +In general, GPLv2+ is used by programs, LGPLv2+ is used for +libraries. + +LGPLv2+ with exceptions is used for things that are linked directly +into dynamically linked programs and shared libraries (e.g. crt +files, lib*_nonshared.a). Historically, this exception also applies +to parts of libio. + +GPLv2+ with exceptions is used for parts of the Arm unwinder. + +GFDL is used for the documentation. + +Some other licenses are used in various places (BSD, Inner-Net, +ISC, Public Domain). + +HSRL and FSFAP are only used in test cases, which currently do not +ship in binary RPMs, so they are not listed here. MIT is used for +scripts/install-sh, which does not ship, either. + +GPLv3+ is used by manual/texinfo.tex, which we do not use. + +LGPLv3+ is used by some Hurd code, which we do not build. + +LGPLv2 is used in one place (time/timespec_get.c, by mistake), but +it is not actually compiled, so it does not matter for libraries. + diff --git a/bench.mk b/bench.mk new file mode 100644 index 0000000..dfe46bd --- /dev/null +++ b/bench.mk @@ -0,0 +1,77 @@ +objpfx = $(prefix)/$(ver)/usr/libexec/glibc-benchtests/ + +bench-math := acos acosh asin asinh atan atanh cos cosh exp exp2 ffs ffsll \ + log log2 modf pow rint sin sincos sinh sqrt tan tanh + +bench-pthread := pthread_once + +bench := $(bench-math) $(bench-pthread) + +run-bench := $(prefix)/$(ver)/lib64/ld-linux-x86-64.so.2 --library-path $(prefix)/$(ver)/lib64 $${run} + +# String function benchmarks. +string-bench := bcopy bzero memccpy memchr memcmp memcpy memmem memmove \ + mempcpy memset rawmemchr stpcpy stpncpy strcasecmp strcasestr \ + strcat strchr strchrnul strcmp strcpy strcspn strlen \ + strncasecmp strncat strncmp strncpy strnlen strpbrk strrchr \ + strspn strstr strcpy_chk stpcpy_chk memrchr strsep strtok +string-bench-all := $(string-bench) + +stdlib-bench := strtod + +benchset := $(string-bench-all) $(stdlib-bench) + +bench-malloc := malloc-thread + +binaries-bench := $(addprefix $(objpfx)bench-,$(bench)) +binaries-benchset := $(addprefix $(objpfx)bench-,$(benchset)) +binaries-bench-malloc := $(addprefix $(objpfx)bench-,$(bench-malloc)) + +DETAILED_OPT := + +ifdef DETAILED + DETAILED_OPT := -d +endif + +bench: bench-set bench-func bench-malloc + +bench-set: $(binaries-benchset) + for run in $^; do \ + outfile=$(prefix)/$$(basename $${run}.$(ver).out); \ + echo "Running $${run}"; \ + $(run-bench) > $${outfile}.tmp; \ + mv $${outfile}{.tmp,}; \ + done + +bench-malloc: $(binaries-bench-malloc) + run=$(objpfx)bench-malloc-thread; \ + outfile=$(prefix)/$$(basename $${run}.$(ver).out); \ + for thr in 1 8 16 32; do \ + echo "Running $${run} $${thr}"; \ + $(run-bench) $${thr} > $${outfile}.tmp; \ + mv $${outfile}{.tmp,}; \ + done + +# Build and execute the benchmark functions. This target generates JSON +# formatted bench.out. Each of the programs produce independent JSON output, +# so one could even execute them individually and process it using any JSON +# capable language or tool. +bench-func: $(binaries-bench) + { echo "{\"timing_type\": \"hp-timing\","; \ + echo " \"functions\": {"; \ + for run in $^; do \ + if ! [ "x$${run}" = "x$<" ]; then \ + echo ","; \ + fi; \ + echo "Running $${run}" >&2; \ + $(run-bench) $(DETAILED_OPT); \ + done; \ + echo; \ + echo " }"; \ + echo "}"; } > $(prefix)/bench.$(ver).out-tmp; \ + if [ -f $(prefix)/bench.$(ver).out ]; then \ + mv -f $(prefix)/bench.$(ver).out{,.old}; \ + fi; \ + mv -f $(prefix)/bench.$(ver).out{-tmp,} +# scripts/validate_benchout.py bench.out \ +# scripts/benchout.schema.json diff --git a/build-locale-archive.c b/build-locale-archive.c new file mode 100644 index 0000000..9183972 --- /dev/null +++ b/build-locale-archive.c @@ -0,0 +1,862 @@ +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../locale/hashval.h" +#define __LC_LAST 13 +#include "../locale/locarchive.h" +#include "../crypt/md5.h" + +const char *alias_file = DATADIR "/locale/locale.alias"; +const char *locar_file = PREFIX "/lib/locale/locale-archive"; +const char *tmpl_file = PREFIX "/lib/locale/locale-archive.tmpl"; +const char *loc_path = PREFIX "/lib/locale/"; +/* Flags set by `--verbose` option. */ +int be_quiet = 1; +int verbose = 0; +int max_locarchive_open_retry = 10; +const char *output_prefix; + +/* Endianness should have been taken care of by localedef. We don't need to do + additional swapping. We need this variable exported however, since + locarchive.c uses it to determine if it needs to swap endianness of a value + before writing to or reading from the archive. */ +bool swap_endianness_p = false; + +static const char *locnames[] = + { +#define DEFINE_CATEGORY(category, category_name, items, a) \ + [category] = category_name, +#include "../locale/categories.def" +#undef DEFINE_CATEGORY + }; + +static int +is_prime (unsigned long candidate) +{ + /* No even number and none less than 10 will be passed here. */ + unsigned long int divn = 3; + unsigned long int sq = divn * divn; + + while (sq < candidate && candidate % divn != 0) + { + ++divn; + sq += 4 * divn; + ++divn; + } + + return candidate % divn != 0; +} + +unsigned long +next_prime (unsigned long seed) +{ + /* Make it definitely odd. */ + seed |= 1; + + while (!is_prime (seed)) + seed += 2; + + return seed; +} + +void +error (int status, int errnum, const char *message, ...) +{ + va_list args; + + va_start (args, message); + fflush (stdout); + fprintf (stderr, "%s: ", program_invocation_name); + vfprintf (stderr, message, args); + va_end (args); + if (errnum) + fprintf (stderr, ": %s", strerror (errnum)); + putc ('\n', stderr); + fflush (stderr); + if (status) + exit (errnum == EROFS ? 0 : status); +} + +void * +xmalloc (size_t size) +{ + void *p = malloc (size); + if (p == NULL) + error (EXIT_FAILURE, errno, "could not allocate %zd bytes of memory", size); + return p; +} + +static void +open_tmpl_archive (struct locarhandle *ah) +{ + struct stat64 st; + int fd; + struct locarhead head; + const char *archivefname = ah->fname == NULL ? tmpl_file : ah->fname; + + /* Open the archive. We must have exclusive write access. */ + fd = open64 (archivefname, O_RDONLY); + if (fd == -1) + error (EXIT_FAILURE, errno, "cannot open locale archive template file \"%s\"", + archivefname); + + if (fstat64 (fd, &st) < 0) + error (EXIT_FAILURE, errno, "cannot stat locale archive template file \"%s\"", + archivefname); + + /* Read the header. */ + if (TEMP_FAILURE_RETRY (read (fd, &head, sizeof (head))) != sizeof (head)) + error (EXIT_FAILURE, errno, "cannot read archive header"); + + ah->fd = fd; + ah->mmaped = (head.sumhash_offset + + head.sumhash_size * sizeof (struct sumhashent)); + if (ah->mmaped > (unsigned long) st.st_size) + error (EXIT_FAILURE, 0, "locale archive template file truncated"); + ah->mmaped = st.st_size; + ah->reserved = st.st_size; + + /* Now we know how large the administrative information part is. + Map all of it. */ + ah->addr = mmap64 (NULL, ah->mmaped, PROT_READ, MAP_SHARED, fd, 0); + if (ah->addr == MAP_FAILED) + error (EXIT_FAILURE, errno, "cannot map archive header"); +} + +/* Open the locale archive. */ +extern void open_archive (struct locarhandle *ah, bool readonly); + +/* Close the locale archive. */ +extern void close_archive (struct locarhandle *ah); + +/* Add given locale data to the archive. */ +extern int add_locale_to_archive (struct locarhandle *ah, const char *name, + locale_data_t data, bool replace); + +extern void add_alias (struct locarhandle *ah, const char *alias, + bool replace, const char *oldname, + uint32_t *locrec_offset_p); + +extern struct namehashent * +insert_name (struct locarhandle *ah, + const char *name, size_t name_len, bool replace); + +struct nameent +{ + char *name; + struct locrecent *locrec; +}; + +struct dataent +{ + const unsigned char *sum; + uint32_t file_offset; +}; + +static int +nameentcmp (const void *a, const void *b) +{ + struct locrecent *la = ((const struct nameent *) a)->locrec; + struct locrecent *lb = ((const struct nameent *) b)->locrec; + uint32_t start_a = -1, end_a = 0; + uint32_t start_b = -1, end_b = 0; + int cnt; + + for (cnt = 0; cnt < __LC_LAST; ++cnt) + if (cnt != LC_ALL) + { + if (la->record[cnt].offset < start_a) + start_a = la->record[cnt].offset; + if (la->record[cnt].offset + la->record[cnt].len > end_a) + end_a = la->record[cnt].offset + la->record[cnt].len; + } + assert (start_a != (uint32_t)-1); + assert (end_a != 0); + + for (cnt = 0; cnt < __LC_LAST; ++cnt) + if (cnt != LC_ALL) + { + if (lb->record[cnt].offset < start_b) + start_b = lb->record[cnt].offset; + if (lb->record[cnt].offset + lb->record[cnt].len > end_b) + end_b = lb->record[cnt].offset + lb->record[cnt].len; + } + assert (start_b != (uint32_t)-1); + assert (end_b != 0); + + if (start_a != start_b) + return (int)start_a - (int)start_b; + return (int)end_a - (int)end_b; +} + +static int +dataentcmp (const void *a, const void *b) +{ + if (((const struct dataent *) a)->file_offset + < ((const struct dataent *) b)->file_offset) + return -1; + + if (((const struct dataent *) a)->file_offset + > ((const struct dataent *) b)->file_offset) + return 1; + + return 0; +} + +static int +sumsearchfn (const void *key, const void *ent) +{ + uint32_t keyn = *(uint32_t *)key; + uint32_t entn = ((struct dataent *)ent)->file_offset; + + if (keyn < entn) + return -1; + if (keyn > entn) + return 1; + return 0; +} + +static void +compute_data (struct locarhandle *ah, struct nameent *name, size_t sumused, + struct dataent *files, locale_data_t data) +{ + int cnt; + struct locrecent *locrec = name->locrec; + struct dataent *file; + data[LC_ALL].addr = ((char *) ah->addr) + locrec->record[LC_ALL].offset; + data[LC_ALL].size = locrec->record[LC_ALL].len; + for (cnt = 0; cnt < __LC_LAST; ++cnt) + if (cnt != LC_ALL) + { + data[cnt].addr = ((char *) ah->addr) + locrec->record[cnt].offset; + data[cnt].size = locrec->record[cnt].len; + if (data[cnt].addr >= data[LC_ALL].addr + && data[cnt].addr + data[cnt].size + <= data[LC_ALL].addr + data[LC_ALL].size) + __md5_buffer (data[cnt].addr, data[cnt].size, data[cnt].sum); + else + { + file = bsearch (&locrec->record[cnt].offset, files, sumused, + sizeof (*files), sumsearchfn); + if (file == NULL) + error (EXIT_FAILURE, 0, "inconsistent template file"); + memcpy (data[cnt].sum, file->sum, sizeof (data[cnt].sum)); + } + } +} + +static int +fill_archive (struct locarhandle *tmpl_ah, + const char *fname, + size_t install_langs_count, char *install_langs_list[], + size_t nlist, char *list[], + const char *primary) +{ + struct locarhandle ah; + struct locarhead *head; + int result = 0; + struct nameent *names; + struct namehashent *namehashtab; + size_t cnt, used; + struct dataent *files; + struct sumhashent *sumhashtab; + size_t sumused; + struct locrecent *primary_locrec = NULL; + struct nameent *primary_nameent = NULL; + + head = tmpl_ah->addr; + names = (struct nameent *) malloc (head->namehash_used + * sizeof (struct nameent)); + files = (struct dataent *) malloc (head->sumhash_used + * sizeof (struct dataent)); + if (names == NULL || files == NULL) + error (EXIT_FAILURE, errno, "could not allocate tables"); + + namehashtab = (struct namehashent *) ((char *) tmpl_ah->addr + + head->namehash_offset); + sumhashtab = (struct sumhashent *) ((char *) tmpl_ah->addr + + head->sumhash_offset); + + for (cnt = used = 0; cnt < head->namehash_size; ++cnt) + if (namehashtab[cnt].locrec_offset != 0) + { + char * name; + int i; + assert (used < head->namehash_used); + name = tmpl_ah->addr + namehashtab[cnt].name_offset; + if (install_langs_count == 0) + { + /* Always intstall the entry. */ + names[used].name = name; + names[used++].locrec + = (struct locrecent *) ((char *) tmpl_ah->addr + + namehashtab[cnt].locrec_offset); + } + else + { + /* Only install the entry if the user asked for it via + --install-langs. */ + for (i = 0; i < install_langs_count; i++) + { + /* Add one for "_" and one for the null terminator. */ + size_t len = strlen (install_langs_list[i]) + 2; + char *install_lang = (char *)xmalloc (len); + strcpy (install_lang, install_langs_list[i]); + if (strchr (install_lang, '_') == NULL) + strcat (install_lang, "_"); + if (strncmp (name, install_lang, strlen (install_lang)) == 0) + { + names[used].name = name; + names[used++].locrec + = (struct locrecent *) ((char *)tmpl_ah->addr + + namehashtab[cnt].locrec_offset); + } + free (install_lang); + } + } + } + + /* Sort the names. */ + qsort (names, used, sizeof (struct nameent), nameentcmp); + + for (cnt = sumused = 0; cnt < head->sumhash_size; ++cnt) + if (sumhashtab[cnt].file_offset != 0) + { + assert (sumused < head->sumhash_used); + files[sumused].sum = (const unsigned char *) sumhashtab[cnt].sum; + files[sumused++].file_offset = sumhashtab[cnt].file_offset; + } + + /* Sort by file locations. */ + qsort (files, sumused, sizeof (struct dataent), dataentcmp); + + /* Open the archive. This call never returns if we cannot + successfully open the archive. */ + ah.fname = NULL; + if (fname != NULL) + ah.fname = fname; + open_archive (&ah, false); + + if (primary != NULL) + { + for (cnt = 0; cnt < used; ++cnt) + if (strcmp (names[cnt].name, primary) == 0) + break; + if (cnt < used) + { + locale_data_t data; + + compute_data (tmpl_ah, &names[cnt], sumused, files, data); + result |= add_locale_to_archive (&ah, primary, data, 0); + primary_locrec = names[cnt].locrec; + primary_nameent = &names[cnt]; + } + } + + for (cnt = 0; cnt < used; ++cnt) + if (&names[cnt] == primary_nameent) + continue; + else if ((cnt > 0 && names[cnt - 1].locrec == names[cnt].locrec) + || names[cnt].locrec == primary_locrec) + { + const char *oldname; + struct namehashent *namehashent; + uint32_t locrec_offset; + + if (names[cnt].locrec == primary_locrec) + oldname = primary; + else + oldname = names[cnt - 1].name; + namehashent = insert_name (&ah, oldname, strlen (oldname), true); + assert (namehashent->name_offset != 0); + assert (namehashent->locrec_offset != 0); + locrec_offset = namehashent->locrec_offset; + add_alias (&ah, names[cnt].name, 0, oldname, &locrec_offset); + } + else + { + locale_data_t data; + + compute_data (tmpl_ah, &names[cnt], sumused, files, data); + result |= add_locale_to_archive (&ah, names[cnt].name, data, 0); + } + + while (nlist-- > 0) + { + const char *fname = *list++; + size_t fnamelen = strlen (fname); + struct stat64 st; + DIR *dirp; + struct dirent64 *d; + int seen; + locale_data_t data; + int cnt; + + /* First see whether this really is a directory and whether it + contains all the require locale category files. */ + if (stat64 (fname, &st) < 0) + { + error (0, 0, "stat of \"%s\" failed: %s: ignored", fname, + strerror (errno)); + continue; + } + if (!S_ISDIR (st.st_mode)) + { + error (0, 0, "\"%s\" is no directory; ignored", fname); + continue; + } + + dirp = opendir (fname); + if (dirp == NULL) + { + error (0, 0, "cannot open directory \"%s\": %s: ignored", + fname, strerror (errno)); + continue; + } + + seen = 0; + while ((d = readdir64 (dirp)) != NULL) + { + for (cnt = 0; cnt < __LC_LAST; ++cnt) + if (cnt != LC_ALL) + if (strcmp (d->d_name, locnames[cnt]) == 0) + { + unsigned char d_type; + + /* We have an object of the required name. If it's + a directory we have to look at a file with the + prefix "SYS_". Otherwise we have found what we + are looking for. */ +#ifdef _DIRENT_HAVE_D_TYPE + d_type = d->d_type; + + if (d_type != DT_REG) +#endif + { + char fullname[fnamelen + 2 * strlen (d->d_name) + 7]; + +#ifdef _DIRENT_HAVE_D_TYPE + if (d_type == DT_UNKNOWN) +#endif + { + strcpy (stpcpy (stpcpy (fullname, fname), "/"), + d->d_name); + + if (stat64 (fullname, &st) == -1) + /* We cannot stat the file, ignore it. */ + break; + + d_type = IFTODT (st.st_mode); + } + + if (d_type == DT_DIR) + { + /* We have to do more tests. The file is a + directory and it therefore must contain a + regular file with the same name except a + "SYS_" prefix. */ + char *t = stpcpy (stpcpy (fullname, fname), "/"); + strcpy (stpcpy (stpcpy (t, d->d_name), "/SYS_"), + d->d_name); + + if (stat64 (fullname, &st) == -1) + /* There is no SYS_* file or we cannot + access it. */ + break; + + d_type = IFTODT (st.st_mode); + } + } + + /* If we found a regular file (eventually after + following a symlink) we are successful. */ + if (d_type == DT_REG) + ++seen; + break; + } + } + + closedir (dirp); + + if (seen != __LC_LAST - 1) + { + /* We don't have all locale category files. Ignore the name. */ + error (0, 0, "incomplete set of locale files in \"%s\"", + fname); + continue; + } + + /* Add the files to the archive. To do this we first compute + sizes and the MD5 sums of all the files. */ + for (cnt = 0; cnt < __LC_LAST; ++cnt) + if (cnt != LC_ALL) + { + char fullname[fnamelen + 2 * strlen (locnames[cnt]) + 7]; + int fd; + + strcpy (stpcpy (stpcpy (fullname, fname), "/"), locnames[cnt]); + fd = open64 (fullname, O_RDONLY); + if (fd == -1 || fstat64 (fd, &st) == -1) + { + /* Cannot read the file. */ + if (fd != -1) + close (fd); + break; + } + + if (S_ISDIR (st.st_mode)) + { + char *t; + close (fd); + t = stpcpy (stpcpy (fullname, fname), "/"); + strcpy (stpcpy (stpcpy (t, locnames[cnt]), "/SYS_"), + locnames[cnt]); + + fd = open64 (fullname, O_RDONLY); + if (fd == -1 || fstat64 (fd, &st) == -1 + || !S_ISREG (st.st_mode)) + { + if (fd != -1) + close (fd); + break; + } + } + + /* Map the file. */ + data[cnt].addr = mmap64 (NULL, st.st_size, PROT_READ, MAP_SHARED, + fd, 0); + if (data[cnt].addr == MAP_FAILED) + { + /* Cannot map it. */ + close (fd); + break; + } + + data[cnt].size = st.st_size; + __md5_buffer (data[cnt].addr, st.st_size, data[cnt].sum); + + /* We don't need the file descriptor anymore. */ + close (fd); + } + + if (cnt != __LC_LAST) + { + while (cnt-- > 0) + if (cnt != LC_ALL) + munmap (data[cnt].addr, data[cnt].size); + + error (0, 0, "cannot read all files in \"%s\": ignored", fname); + + continue; + } + + result |= add_locale_to_archive (&ah, basename (fname), data, 0); + + for (cnt = 0; cnt < __LC_LAST; ++cnt) + if (cnt != LC_ALL) + munmap (data[cnt].addr, data[cnt].size); + } + + /* We are done. */ + close_archive (&ah); + + return result; +} + +void usage() +{ + printf ("\ +Usage: build-locale-archive [OPTION]... [TEMPLATE-FILE] [ARCHIVE-FILE]\n\ + Builds a locale archive from a template file.\n\ + Options:\n\ + -h, --help Print this usage message.\n\ + -v, --verbose Verbose execution.\n\ + -l, --install-langs=LIST Only include locales given in LIST into the \n\ + locale archive. LIST is a colon separated list\n\ + of locale prefixes, for example \"de:en:ja\".\n\ + The special argument \"all\" means to install\n\ + all languages and it must be present by itself.\n\ + If \"all\" is present with any other language it\n\ + will be treated as the name of a locale.\n\ + If the --install-langs option is missing, all\n\ + locales are installed. The colon separated list\n\ + can contain any strings matching the beginning of\n\ + locale names.\n\ + If a string does not contain a \"_\", it is added.\n\ + Examples:\n\ + --install-langs=\"en\"\n\ + installs en_US, en_US.iso88591,\n\ + en_US.iso885915, en_US.utf8,\n\ + en_GB ...\n\ + --install-langs=\"en_US.utf8\"\n\ + installs only en_US.utf8.\n\ + --install-langs=\"ko\"\n\ + installs ko_KR, ko_KR.euckr,\n\ + ko_KR.utf8 but *not* kok_IN\n\ + because \"ko\" does not contain\n\ + \"_\" and it is silently added\n\ + --install-langs\"ko:kok\"\n\ + installs ko_KR, ko_KR.euckr,\n\ + ko_KR.utf8, kok_IN, and\n\ + kok_IN.utf8.\n\ + --install-langs=\"POSIX\" will\n\ + installs *no* locales at all\n\ + because POSIX matches none of\n\ + the locales. Actually, any string\n\ + matching nothing will do that.\n\ + POSIX and C will always be\n\ + available because they are\n\ + builtin.\n\ + Aliases are installed as well,\n\ + i.e. --install-langs=\"de\"\n\ + will install not only every locale starting with\n\ + \"de\" but also the aliases \"deutsch\"\n\ + and and \"german\" although the latter does not\n\ + start with \"de\".\n\ +\n\ + If the arguments TEMPLATE-FILE and ARCHIVE-FILE are not given the locations\n\ + where the glibc used expects these files are used by default.\n\ +"); +} + +int main (int argc, char *argv[]) +{ + char path[4096]; + DIR *dirp; + struct dirent64 *d; + struct stat64 st; + char *list[16384], *primary; + char *lang; + int install_langs_count = 0; + int i; + char *install_langs_arg, *ila_start; + char **install_langs_list = NULL; + unsigned int cnt = 0; + struct locarhandle tmpl_ah; + char *new_locar_fname = NULL; + size_t loc_path_len = strlen (loc_path); + + while (1) + { + int c; + + static struct option long_options[] = + { + {"help", no_argument, 0, 'h'}, + {"verbose", no_argument, 0, 'v'}, + {"install-langs", required_argument, 0, 'l'}, + {0, 0, 0, 0} + }; + /* getopt_long stores the option index here. */ + int option_index = 0; + + c = getopt_long (argc, argv, "vhl:", + long_options, &option_index); + + /* Detect the end of the options. */ + if (c == -1) + break; + + switch (c) + { + case 0: + printf ("unknown option %s", long_options[option_index].name); + if (optarg) + printf (" with arg %s", optarg); + printf ("\n"); + usage (); + exit (1); + + case 'v': + verbose = 1; + be_quiet = 0; + break; + + case 'h': + usage (); + exit (0); + + case 'l': + install_langs_arg = ila_start = strdup (optarg); + /* If the argument to --install-lang is "all", do + not limit the list of languages to install and install + them all. We do not support installing a single locale + called "all". */ +#define MAGIC_INSTALL_ALL "all" + if (install_langs_arg != NULL + && install_langs_arg[0] != '\0' + && !(strncmp(install_langs_arg, MAGIC_INSTALL_ALL, + strlen(MAGIC_INSTALL_ALL)) == 0 + && strlen (install_langs_arg) == 3)) + { + /* Count the number of languages we will install. */ + while (true) + { + lang = strtok(install_langs_arg, ":;,"); + if (lang == NULL) + break; + install_langs_count++; + install_langs_arg = NULL; + } + free (ila_start); + + /* Reject an entire string made up of delimiters. */ + if (install_langs_count == 0) + break; + + /* Copy the list. */ + install_langs_list = (char **)xmalloc (sizeof(char *) * install_langs_count); + install_langs_arg = ila_start = strdup (optarg); + install_langs_count = 0; + while (true) + { + lang = strtok(install_langs_arg, ":;,"); + if (lang == NULL) + break; + install_langs_list[install_langs_count] = lang; + install_langs_count++; + install_langs_arg = NULL; + } + } + break; + + case '?': + /* getopt_long already printed an error message. */ + usage (); + exit (0); + + default: + abort (); + } + } + tmpl_ah.fname = NULL; + if (optind < argc) + tmpl_ah.fname = argv[optind]; + if (optind + 1 < argc) + new_locar_fname = argv[optind + 1]; + if (verbose) + { + if (tmpl_ah.fname) + printf("input archive file specified on command line: %s\n", + tmpl_ah.fname); + else + printf("using default input archive file.\n"); + if (new_locar_fname) + printf("output archive file specified on command line: %s\n", + new_locar_fname); + else + printf("using default output archive file.\n"); + } + + dirp = opendir (loc_path); + if (dirp == NULL) + error (EXIT_FAILURE, errno, "cannot open directory \"%s\"", loc_path); + + open_tmpl_archive (&tmpl_ah); + + if (new_locar_fname) + unlink (new_locar_fname); + else + unlink (locar_file); + primary = getenv ("LC_ALL"); + if (primary == NULL) + primary = getenv ("LANG"); + if (primary != NULL) + { + if (strncmp (primary, "ja", 2) != 0 + && strncmp (primary, "ko", 2) != 0 + && strncmp (primary, "zh", 2) != 0) + { + char *ptr = malloc (strlen (primary) + strlen (".utf8") + 1), *p, *q; + /* This leads to invalid locales sometimes: + de_DE.iso885915@euro -> de_DE.utf8@euro */ + if (ptr != NULL) + { + p = ptr; + q = primary; + while (*q && *q != '.' && *q != '@') + *p++ = *q++; + if (*q == '.') + while (*q && *q != '@') + q++; + p = stpcpy (p, ".utf8"); + strcpy (p, q); + primary = ptr; + } + else + primary = NULL; + } + } + + memcpy (path, loc_path, loc_path_len); + + while ((d = readdir64 (dirp)) != NULL) + { + if (strcmp (d->d_name, ".") == 0 || strcmp (d->d_name, "..") == 0) + continue; + if (strchr (d->d_name, '_') == NULL) + continue; + + size_t d_name_len = strlen (d->d_name); + if (loc_path_len + d_name_len + 1 > sizeof (path)) + { + error (0, 0, "too long filename \"%s\"", d->d_name); + continue; + } + + memcpy (path + loc_path_len, d->d_name, d_name_len + 1); + if (stat64 (path, &st) < 0) + { + error (0, errno, "cannot stat \"%s\"", path); + continue; + } + if (! S_ISDIR (st.st_mode)) + continue; + if (cnt == 16384) + { + error (0, 0, "too many directories in \"%s\"", loc_path); + break; + } + list[cnt] = strdup (path); + if (list[cnt] == NULL) + { + error (0, errno, "cannot add file to list \"%s\"", path); + continue; + } + if (primary != NULL && cnt > 0 && strcmp (primary, d->d_name) == 0) + { + char *p = list[0]; + list[0] = list[cnt]; + list[cnt] = p; + } + cnt++; + } + closedir (dirp); + /* Store the archive to the file specified as the second argument on the + command line or the default locale archive. */ + fill_archive (&tmpl_ah, new_locar_fname, + install_langs_count, install_langs_list, + cnt, list, primary); + close_archive (&tmpl_ah); + truncate (tmpl_file, 0); + if (install_langs_count > 0) + { + free (ila_start); + free (install_langs_list); + } + char *tz_argv[] = { "/usr/sbin/tzdata-update", NULL }; + execve (tz_argv[0], (char *const *)tz_argv, (char *const *)&tz_argv[1]); + exit (0); +} diff --git a/glibc-2.28.tar.xz b/glibc-2.28.tar.xz new file mode 100644 index 0000000..f93b330 Binary files /dev/null and b/glibc-2.28.tar.xz differ diff --git a/glibc-bench-compare b/glibc-bench-compare new file mode 100755 index 0000000..84e3aba --- /dev/null +++ b/glibc-bench-compare @@ -0,0 +1,153 @@ +#!/usr/bin/bash +# This script can be invoked as follows: +# +# glibc-bench-compare [options] [BUILD] +# +# Options may be one of the following: +# +# -t The BUILD arguments are task ids and not a version-release string +# -a ARCH Do comparison for ARCH architecture +# +# If any of the above options are given, both BUILD arguments must be given. +# Otherwise, if only one BUILD is specified, then it is compared against the +# installed glibc. + +# Silence the pushd/popd messages +pushd() { + command pushd "$@" > /dev/null 2>&1 +} + +popd() { + command popd "$@" > /dev/null 2>&1 +} + +# Clean up any downloaded files before we exit +trap "rm -rf /tmp/glibc-bench-compare.$BASHPID.*" EXIT + +task=0 +arch=$(uname -i) +options=0 +path=0 +installed= + +# Look for any commandline options +while getopts ":tpa:" opt; do + case $opt in + p) + path=1 + ;; + t) + task=1 + options=1 + echo "Not implemented." + exit 1 + ;; + a) + arch=$OPTARG + options=1 + ;; + *) + ;; + esac +done + +# Done, now shift all option arguments out. +shift $((OPTIND-1)) + +if [ $# -gt 2 ] || [ $# -eq 0 ] || [ $# -lt 2 -a $options -eq 1 ]; then + echo "Usage: $0 [OPTIONS] [new]" + echo + echo "OPTIONS:" + echo -e "\t-t\tCompare two brew tasks" + echo -e "\t-a ARCH\tGet rpms for the ARCH architecture" + echo -e "\t-p\tCompare built rpms in two paths." + echo -e "\t\tThis minimally needs glibc, glibc-common and glibc-benchtests" + exit 1 +fi + +if [ -z $2 ]; then + new="$1" + old=$(rpm --queryformat "%{VERSION}-%{RELEASE}\n" -q glibc | head -1) + installed=$old +else + new="$2" + old="$1" +fi + +decompress_rpms() { + # We were given a path to the rpms. Figure out the version-release and + # decompress the rpms. + if [ -n $1 ]; then + vr=$(rpm --queryformat="%{VERSION}-%{RELEASE}" -qp $1/glibc-2*.rpm | head -1) + mkdir $vr && pushd $vr + fi + + for r in $1*.rpm; do + ( rpm2cpio $r | cpio -di ) > /dev/null + done + + if [ -n $1 ]; then + popd + echo $vr + fi +} + +# Get rpms for a build and decompress them +get_build() { + echo "Processing build $1" + mkdir $1 && pushd $1 + brew buildinfo "glibc-$1" | + sed -n -e "s|/mnt/koji\(.\+$arch.\+\)|http://kojipkgs.fedoraproject.org\1|p" | + while read url; do + echo "Downloading $url" + wget -q $url + done + decompress_rpms + + echo "Removing rpms" + rm -f $1/*.rpm + + popd +} + +# Run benchmarks for a build +run_bench() { + if [ -z $1 ]; then + make DETAILED=1 ver=$installed prefix= -f /usr/libexec/glibc-benchtests/bench.mk bench + else + make DETAILED=1 ver=$1 prefix=$PWD -f $1/usr/libexec/glibc-benchtests/bench.mk bench + fi +} + +# Get absolute paths if needed, since we will change into the working directory +# next. +if [ $path -eq 1 ]; then + old_path=$(realpath $old)/ + new_path=$(realpath $new)/ +fi + +tmpdir=$(mktemp -p /tmp -d glibc-bench-compare.$$.XXXX) +pushd $tmpdir + +# Get both builds. +if [ $path -eq 0 ]; then + if [ -z $installed ]; then + get_build $old + fi + get_build $new +else + old=$(decompress_rpms $old_path) + new=$(decompress_rpms $new_path) +fi + +# make bench for each of those. +if [ -z $installed ]; then + run_bench $old +else + run_bench +fi +run_bench $new + +# Now run the comparison script. +$old/usr/libexec/glibc-benchtests/compare_bench.py $old/usr/libexec/glibc-benchtests/benchout.schema.json \ + bench.$old.out bench.$new.out diff --git a/glibc.spec b/glibc.spec new file mode 100644 index 0000000..915b4d3 --- /dev/null +++ b/glibc.spec @@ -0,0 +1,905 @@ +%global __filter_GLIBC_PRIVATE 1 + +%define rpm_ver_major %(eval "echo `rpm -q rpm |cut -d '-' -f2 |cut -d. -f1`") +%define rpm_ver_minor %(eval "echo `rpm -q rpm |cut -d '-' -f2 |cut -d. -f2`") +%define rpm_version_ge_412 %(eval "if [ %{rpm_ver_major} -gt 4 -o %{rpm_ver_major} -eq 4 -a %{rpm_ver_minor} -ge 12 ]; then echo 1; else echo 0; fi") +############################################################################## +# We support the following options: +# --with/--without, +# * testsuite +# - Running the testsuite. It must run for production builds. +# - Default: Always run the testsuite. +# * benchtests +# - Running and building benchmark subpackage. +# - Default: Always build the benchtests. +# * bootstrap +# - Bootstrapping the package. +# - Default: Not bootstrapping. +# * werror +# - Build with -Werror +# - Default: Enable using -Werror +# * docs +# - Build with documentation and the required dependencies. +# - Default: Always build documentation. +# * valgrind +# - Run smoke tests with valgrind to verify dynamic loader. +# - Default: Always run valgrind tests if there is architecture support. +############################################################################## +%bcond_without testsuite +%bcond_without benchtests +%bcond_with bootstrap +%bcond_without werror +%bcond_without docs + +%ifarch %{valgrind_arches} +%bcond_without valgrind +%else +%bcond_with valgrind +%endif + +%if %{with bootstrap} +%undefine with_benchtests +%undefine with_werror +%undefine with_docs +%undefine with_valgrind +%endif + +%define enablekernel 3.2 +%define target %{_target_cpu}-openEuler-linux +%ifarch %{arm} +%define target %{_target_cpu}-openEuler-linuxeabi +%endif +%define x86_arches %{ix86} x86_64 +%define all_license LGPLv2+ and LGPLv2+ with exceptions and GPLv2+ and GPLv2+ with exceptions and BSD and Inner-Net and ISC and Public Domain and GFDL +%define GCC gcc +%define GXX g++ +############################################################################## +# glibc - The GNU C Library (glibc) core package. +############################################################################## +Name: glibc +Version: 2.28 +Release: 25 +Summary: The GNU libc libraries +License: %{all_license} +URL: http://www.gnu.org/software/glibc/ + +Source0: https://ftp.gnu.org/gnu/glibc/%{name}-%{version}.tar.xz +Source1: build-locale-archive.c +Source2: nscd.conf +Source3: nsswitch.conf +Source4: bench.mk +Source5: glibc-bench-compare +Source6: LicenseList + +Provides: ldconfig rtld(GNU_HASH) bundled(gnulib) + +BuildRequires: audit-libs-devel >= 1.1.3, sed >= 3.95, libcap-devel, gettext +BuildRequires: procps-ng, util-linux, gawk, systemtap-sdt-devel, systemd, python3 +BuildRequires: make >= 4.0, bison >= 2.7, binutils >= 2.30-17, gcc >= 7.2.1-6 + +%if %{without bootstrap} +BuildRequires: gd-devel libpng-devel zlib-devel +%endif + +%if %{with docs} +BuildRequires: texinfo >= 5.0 +%endif + +%if %{without bootstrap} +BuildRequires: libselinux-devel >= 1.33.4-3 +%endif + +%if %{with valgrind} +BuildRequires: valgrind +%endif + +%if 0%{?_enable_debug_packages} +BuildRequires: elfutils >= 0.72 rpm >= 4.2-0.56 +%endif + +%if %{without bootstrap} +%if %{with testsuite} +BuildRequires: gcc-c++ libstdc++-static glibc-devel libidn2 +%endif +%endif + +Requires: glibc-common = %{version}-%{release} +Requires: glibc-langpack = %{version}-%{release} +Requires(pre): basesystem + +%description +The GNU C Library project provides the core libraries for the GNU system and +GNU/Linux systems, as well as many other systems that use Linux as the kernel. +These libraries provide critical APIs including ISO C11, POSIX.1-2008, BSD, +OS-specific APIs and more. These APIs include such foundational facilities as +open, read, write, malloc, printf, getaddrinfo, dlopen, pthread_create, crypt, + login, exit and more. + +############################################################################## +# glibc "common" sub-package +############################################################################## +%package common +Summary: Common binaries and locale data for glibc +Provides: glibc-langpack = %{version}-%{release} + +Provides: glibc-langpack-en = %{version}-%{release} +Provides: glibc-langpack-en%{?_isa} = %{version}-%{release} +Provides: glibc-langpack-zh = %{version}-%{release} +Provides: glibc-langpack-zh%{?_isa} = %{version}-%{release} + +Requires: %{name} = %{version}-%{release} +Requires: tzdata >= 2003a + +%description common +The glibc-common package includes common binaries for the GNU libc +libraries and national language (locale) support. Besides, zh_CN and +en_US are included. + +%transfiletriggerin common -P 2000000 -- /lib /usr/lib /lib64 /usr/lib64 +/sbin/ldconfig +%end + +%transfiletriggerpostun common -P 2000000 -- /lib /usr/lib /lib64 /usr/lib64 +/sbin/ldconfig +%end + +%undefine __brp_ldconfig + +############################################################################## +# glibc "all-langpacks" sub-package +############################################################################## +%package all-langpacks +Summary: All language packs for %{name}. +Requires: %{name} = %{version}-%{release} +Requires: %{name}-common = %{version}-%{release} +Provides: %{name}-langpack = %{version}-%{release} + +%description all-langpacks +The glibc-all-langpacks provides all the glibc-langpacks. Every entry +includes the basic information required to support the corresponding +language in your applications. + +############################################################################## +# glibc "locale-source" sub-package +############################################################################## +%package locale-source +Summary: The sources package of locales +Requires: %{name} = %{version}-%{release} +Requires: %{name}-common = %{version}-%{release} + +%description locale-source +The locale-source package contains all language packs which are built custom +locales + +############################################################################## +# glibc "devel" sub-package +############################################################################## +%package devel +Summary: The devel for %{name} +Requires: %{name} = %{version}-%{release} +Requires: libgcc%{_isa} +Requires(pre): info +Requires(pre): kernel-headers +Requires: kernel-headers >= 2.2.1 +%if 0%{rpm_version_ge_412} +Requires: libxcrypt-devel%{_isa} >= 4.0.0 +Requires: libxcrypt-static%{?_isa} >= 4.0.0 +%endif +BuildRequires: kernel-headers >= 3.2 + +Provides: %{name}-static = %{version}-%{release} +Provides: %{name}-static%{_isa} = %{version}-%{release} +Provides: %{name}-headers = %{version}-%{release} +Provides: %{name}-headers(%{_target_cpu}) +Provides: %{name}-headers%{_isa} = %{version}-%{release} + +Obsoletes: %{name}-static +Obsoletes: %{name}-headers + +%description devel +The glibc-devel package contains the object files necessary for developing +programs which use the standard C libraries. Besides, it contains the +headers. Thus, it is necessory to install glibc-devel if you ned develop programs. + +############################################################################## +# glibc "nscd" sub-package +############################################################################## +%package -n nscd +Summary: Name caching service daemon. +Requires: %{name} = %{version}-%{release} +%if %{without bootstrap} +Requires: libselinux >= 1.17.10-1 +%endif +Requires: audit-libs >= 1.1.3 +Requires(pre): shadow-utils, coreutils +Requires: systemd +Requires(postun): shadow-utils + +%description -n nscd +The nscd package is able to daemon caches name service lookups and improve +the performance with LDAP. + +############################################################################## +# nss modules sub-package +############################################################################## +%package -n nss_modules +Summary: Name Service Switch module using hash-indexed files and Hesiod +Requires: %{name}%{_isa} = %{version}-%{release} +Provides: nss_db = %{version}-%{release} +Provides: nss_db%{_isa} = %{version}-%{release} +Provides: nss_hesiod = %{version}-%{release} +Provides: nss_hesiod%{_isa} = %{version}-%{release} +Obsoletes: nss_db nss_hesiod + +%description -n nss_modules +This package contains nss_db and nss_hesiod. The former uses hash-indexed files +to speed up user, group, service, host name, and other NSS-based lookups.The +latter uses the Domain Name System (DNS) as a source for user, group, and service +information to follow the Hesiod convention of Project Athena. + +############################################################################## +# nss-devel sub-package +############################################################################## +%package nss-devel +Summary: The devel for directly linking NSS service modules +Requires: nss_db%{_isa} = %{version}-%{release} +Requires: nss_hesiod%{_isa} = %{version}-%{release} + +%description nss-devel +This package contains the necessary devel files to compile applications and +libraries which directly link against NSS modules supplied by glibc. This +package is rarely used, and in most cases use the glibc-devel package instead. + +############################################################################## +# libnsl subpackage +############################################################################## +%package -n libnsl +Summary: Public client interface for NIS(YP) and NIS+ +Requires: %{name}%{_isa} = %{version}-%{release} + +%description -n libnsl +The libnsl package contains the public client interface for NIS(YP) and NIS+. +It replaces the NIS library that used to be in glibc. + +############################################################################## +# glibc benchtests sub-package +############################################################################## +%if %{with benchtests} + +%package benchtests +Summary: Build benchmarking binaries and scripts for %{name} + +%description benchtests +This package provides built benchmark binaries and scripts which will be used +to run microbenchmark tests on the system. +%endif + +############################################################################## +# glibc debugutils sub-package +############################################################################## +%package debugutils +Summary: debug files for %{name} +Requires: %{name} = %{version}-%{release} + +Requires: %{name}-debuginfo = %{version}-%{release} +Requires: %{name}-common-debuginfo = %{version}-%{release} +Requires: %{name}-devel-debuginfo = %{version}-%{release} +Requires: nscd-debuginfo = %{version}-%{release} +Requires: nss_modules-debuginfo = %{version}-%{release} +Requires: libnsl-debuginfo = %{version}-%{release} +Requires: %{name}-benchtests-debuginfo = %{version}-%{release} + +Provides: %{name}-debuginfo = %{version}-%{release} +Provides: %{name}-debuginfo%{_isa} = %{version}-%{release} +Provides: %{name}-utils = %{version}-%{release} +Provides: %{name}-utils%{_isa} = %{version}-%{release} + +Obsoletes: %{name}-utils + +%description debugutils +This package provides many static files for debug. Besides, It contain memusage, +a memory usage profiler, mtrace, a memory leak tracer and xtrace, a function +call tracer, all of which is not necessory for you. + +############################################################################## +# glibc help sub-package +############################################################################## +%package help +Summary: The doc and man for %{name} +Buildarch: noarch +Requires: man info + +%description help +This package provides al doc and man files of %{name} + +############################################################################## +# Prepare for the build. +############################################################################## +%prep +%autosetup -n %{name}-%{version} -p1 + +chmod +x benchtests/scripts/*.py scripts/pylint + +find . -type f -size 0 -o -name "*.orig" -exec rm -f {} \; + +touch `find . -name configure` + +touch locale/programs/*-kw.h + +############################################################################## +# Build glibc... +############################################################################## +%build + +BuildFlags="-O2 -g" +reference=" \ + "-Wp,-D_GLIBCXX_ASSERTIONS" \ + "-fasynchronous-unwind-tables" \ + "-fstack-clash-protection" \ + "-funwind-tables" \ + "-m31" \ + "-m32" \ + "-m64" \ + "-march=i686" \ + "-march=x86-64" \ + "-march=z13" \ + "-march=z14" \ + "-march=zEC12" \ + "-mfpmath=sse" \ + "-msse2" \ + "-mstackrealign" \ + "-mtune=generic" \ + "-mtune=z13" \ + "-mtune=z14" \ + "-mtune=zEC12" \ + "-specs=/usr/lib/rpm/openEuler/openEuler-annobin-cc1" " + +for flag in $RPM_OPT_FLAGS $RPM_LD_FLAGS ; do + if echo "$reference" | grep -q -F " $flag " ; then + BuildFlags="$BuildFlags $flag" + fi +done + +%define glibc_make_flags_as ASFLAGS="-g -Wa,--generate-missing-build-notes=yes" +%define glibc_make_flags %{glibc_make_flags_as} + +EnableKernel="--enable-kernel=%{enablekernel}" + +builddir=build-%{target} +rm -rf $builddir +mkdir $builddir +pushd $builddir +../configure CC="%GCC" CXX="%GXX" CFLAGS="$BuildFlags" \ + --prefix=%{_prefix} \ + --with-headers=%{_prefix}/include $EnableKernel \ + --with-nonshared-cflags=-Wp,-D_FORTIFY_SOURCE=2 \ + --enable-bind-now \ + --build=%{target} \ + --enable-stack-protector=strong \ +%ifarch %{x86_arches} + --enable-static-pie \ + --enable-cet \ +%endif + --enable-tunables \ + --enable-systemtap \ +%ifarch %{ix86} + --disable-multi-arch \ +%endif +%if %{without werror} + --disable-werror \ +%endif + --disable-profile \ +%if %{with bootstrap} + --without-selinux \ +%endif +%if 0%{rpm_version_ge_412} + --disable-crypt \ +%endif + || + { cat config.log; false; } + +make %{?_smp_mflags} -O -r %{glibc_make_flags} +popd + +############################################################################## +# Install glibc... +############################################################################## +%install +chmod 644 sysdeps/gnu/errlist.c + +%ifarch riscv64 +for d in $RPM_BUILD_ROOT%{_libdir} $RPM_BUILD_ROOT/%{_lib}; do + mkdir -p $d + (cd $d && ln -sf . lp64d) +done +%endif + +make -j1 install_root=$RPM_BUILD_ROOT install -C build-%{target} + +pushd build-%{target} +make %{?_smp_mflags} -O install_root=$RPM_BUILD_ROOT \ + install-locales -C ../localedata objdir=`pwd` +popd + +rm -f $RPM_BUILD_ROOT/%{_libdir}/libNoVersion* +rm -f $RPM_BUILD_ROOT/%{_lib}/libNoVersion* +rm -f $RPM_BUILD_ROOT/%{_lib}/libnss1-* +rm -f $RPM_BUILD_ROOT/%{_lib}/libnss-*.so.1 +rm -f $RPM_BUILD_ROOT/{usr/,}sbin/sln + +mkdir -p $RPM_BUILD_ROOT/var/cache/ldconfig +truncate -s 0 $RPM_BUILD_ROOT/var/cache/ldconfig/aux-cache + +$RPM_BUILD_ROOT/sbin/ldconfig -N -r $RPM_BUILD_ROOT + +# Install info files +%if %{with docs} +# Move the info files if glibc installed them into the wrong location. +if [ -d $RPM_BUILD_ROOT%{_prefix}/info -a "%{_infodir}" != "%{_prefix}/info" ]; then + mkdir -p $RPM_BUILD_ROOT%{_infodir} + mv -f $RPM_BUILD_ROOT%{_prefix}/info/* $RPM_BUILD_ROOT%{_infodir} + rm -rf $RPM_BUILD_ROOT%{_prefix}/info +fi + +# Compress all of the info files. +gzip -9nvf $RPM_BUILD_ROOT%{_infodir}/libc* + +%else +rm -f $RPM_BUILD_ROOT%{_infodir}/dir +rm -f $RPM_BUILD_ROOT%{_infodir}/libc.info* +%endif + +# Create all-packages libc.lang +olddir=`pwd` +pushd $RPM_BUILD_ROOT%{_prefix}/lib/locale +rm -f locale-archive +$olddir/build-%{target}/elf/ld.so \ + --library-path $olddir/build-%{target}/ \ + $olddir/build-%{target}/locale/localedef \ + --prefix $RPM_BUILD_ROOT --add-to-archive \ + *_* +# Setup the locale-archive template for use by glibc-all-langpacks. +mv locale-archive{,.tmpl} +%{find_lang} libc +popd +mv $RPM_BUILD_ROOT%{_prefix}/lib/locale/libc.lang . + +# Install configuration files for services +install -p -m 644 %{SOURCE3} $RPM_BUILD_ROOT/etc/nsswitch.conf + +mkdir -p $RPM_BUILD_ROOT/etc/default +install -p -m 644 nis/nss $RPM_BUILD_ROOT/etc/default/nss + +# This is for ncsd - in glibc 2.2 +install -m 644 nscd/nscd.conf $RPM_BUILD_ROOT/etc +mkdir -p $RPM_BUILD_ROOT%{_tmpfilesdir} +install -m 644 %{SOURCE2} %{buildroot}%{_tmpfilesdir} +mkdir -p $RPM_BUILD_ROOT/lib/systemd/system +install -m 644 nscd/nscd.service nscd/nscd.socket $RPM_BUILD_ROOT/lib/systemd/system + +# Include ld.so.conf +echo 'include ld.so.conf.d/*.conf' > $RPM_BUILD_ROOT/etc/ld.so.conf +truncate -s 0 $RPM_BUILD_ROOT/etc/ld.so.cache +chmod 644 $RPM_BUILD_ROOT/etc/ld.so.conf +mkdir -p $RPM_BUILD_ROOT/etc/ld.so.conf.d +mkdir -p $RPM_BUILD_ROOT/etc/sysconfig +truncate -s 0 $RPM_BUILD_ROOT/etc/sysconfig/nscd +truncate -s 0 $RPM_BUILD_ROOT/etc/gai.conf + +# Include %{_libdir}/gconv/gconv-modules.cache +truncate -s 0 $RPM_BUILD_ROOT%{_libdir}/gconv/gconv-modules.cache +chmod 644 $RPM_BUILD_ROOT%{_libdir}/gconv/gconv-modules.cache + +# Install the upgrade program +install -m 700 build-%{target}/elf/glibc_post_upgrade \ + $RPM_BUILD_ROOT%{_prefix}/sbin/glibc_post_upgrade.%{_target_cpu} + +# Install debug copies of unstripped static libraries +%if 0%{?_enable_debug_packages} +mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/debug%{_libdir} +cp -a $RPM_BUILD_ROOT%{_libdir}/*.a \ + $RPM_BUILD_ROOT%{_prefix}/lib/debug%{_libdir}/ +rm -f $RPM_BUILD_ROOT%{_prefix}/lib/debug%{_libdir}/*_p.a +%endif + +# Remove any zoneinfo files; they are maintained by tzdata. +rm -rf $RPM_BUILD_ROOT%{_prefix}/share/zoneinfo + +touch -r %{SOURCE0} $RPM_BUILD_ROOT/etc/ld.so.conf +touch -r sunrpc/etc.rpc $RPM_BUILD_ROOT/etc/rpc + +pushd build-%{target} +%GCC -Os -g -static -o build-locale-archive %{SOURCE1} \ + ../build-%{target}/locale/locarchive.o \ + ../build-%{target}/locale/md5.o \ + ../build-%{target}/locale/record-status.o \ + -I. -DDATADIR=\"%{_datadir}\" -DPREFIX=\"%{_prefix}\" \ + -L../build-%{target} \ + -B../build-%{target}/csu/ -lc -lc_nonshared +install -m 700 build-locale-archive $RPM_BUILD_ROOT%{_prefix}/sbin/build-locale-archive +popd + +# Lastly copy some additional documentation for the packages. +rm -rf documentation +mkdir documentation +cp timezone/README documentation/README.timezone +cp posix/gai.conf documentation/ + +%if %{with benchtests} +# Build benchmark binaries. Ignore the output of the benchmark runs. +pushd build-%{target} +make BENCH_DURATION=1 bench-build +popd + +# Copy over benchmark binaries. +mkdir -p $RPM_BUILD_ROOT%{_prefix}/libexec/glibc-benchtests +cp $(find build-%{target}/benchtests -type f -executable) $RPM_BUILD_ROOT%{_prefix}/libexec/glibc-benchtests/ + +#makefile. +for b in %{SOURCE4} %{SOURCE5}; do + cp $b $RPM_BUILD_ROOT%{_prefix}/libexec/glibc-benchtests/ +done + +#comparison scripts. +for i in benchout.schema.json compare_bench.py import_bench.py validate_benchout.py; do + cp benchtests/scripts/$i $RPM_BUILD_ROOT%{_prefix}/libexec/glibc-benchtests/ +done + +%if 0%{?_enable_debug_packages} +pushd locale +ln -s programs/*.gperf . +popd + +pushd iconv +ln -s ../locale/programs/charmap-kw.gperf . +popd + +%if %{with docs} +rm -f $RPM_BUILD_ROOT%{_infodir}/dir +%endif + +truncate -s 0 $RPM_BUILD_ROOT/%{_prefix}/lib/locale/locale-archive +mkdir -p $RPM_BUILD_ROOT/var/{db,run}/nscd +touch $RPM_BUILD_ROOT/var/{db,run}/nscd/{passwd,group,hosts,services} +touch $RPM_BUILD_ROOT/var/run/nscd/{socket,nscd.pid} + +mkdir -p $RPM_BUILD_ROOT%{_libdir} +mv -f $RPM_BUILD_ROOT/%{_lib}/lib{pcprofile,memusage}.so \ + $RPM_BUILD_ROOT%{_libdir} + +# Strip all of the installed object files. +strip -g $RPM_BUILD_ROOT%{_libdir}/*.o + +# Rebuild libpthread.a using --whole-archive to ensure all of libpthread +# is included in a static link. +pushd $RPM_BUILD_ROOT%{_prefix}/%{_lib}/ +%GCC -r -nostdlib -o libpthread.o -Wl,--whole-archive ./libpthread.a +rm libpthread.a +ar rcs libpthread.a libpthread.o +rm libpthread.o +popd + +for i in $RPM_BUILD_ROOT%{_prefix}/bin/{xtrace,memusage}; do +%if %{with bootstrap} + test -w $i || continue +%endif + sed -e 's~=/%{_lib}/libpcprofile.so~=%{_libdir}/libpcprofile.so~' \ + -e 's~=/%{_lib}/libmemusage.so~=%{_libdir}/libmemusage.so~' \ + -e 's~='\''/\\\$LIB/libpcprofile.so~='\''%{_prefix}/\\$LIB/libpcprofile.so~' \ + -e 's~='\''/\\\$LIB/libmemusage.so~='\''%{_prefix}/\\$LIB/libmemusage.so~' \ + -i $i +done +%endif # 0%{?_enable_debug_packages} +%endif # %{with benchtests} +############################################################################## +# Run the glibc testsuite +############################################################################## +%check +%if %{with testsuite} +# Increase timeouts +export TIMEOUTFACTOR=16 +parent=$$ +echo ====================TESTING========================= + +# Default libraries. +pushd build-%{target} +make %{?_smp_mflags} -O check |& tee rpmbuild.check.log >&2 +test -n tests.sum +if ! grep -q '^Summary of test results:$' rpmbuild.check.log ; then + echo "FAIL: test suite build of target: $(basename "$(pwd)")" >& 2 + exit 1 +fi +set +x +grep -v ^PASS: tests.sum > rpmbuild.tests.sum.not-passing || true +if test -n rpmbuild.tests.sum.not-passing ; then + echo ===================FAILED TESTS===================== >&2 + echo "Target: $(basename "$(pwd)")" >& 2 + cat rpmbuild.tests.sum.not-passing >&2 + while read failed_code failed_test ; do + for suffix in out test-result ; do + if test -e "$failed_test.$suffix"; then + echo >&2 + echo "=====$failed_code $failed_test.$suffix=====" >&2 + cat -- "$failed_test.$suffix" >&2 + echo >&2 + fi + done + done &2 +cat misc/tst-syscall-list.out >&2 +set -x +popd + +echo ====================TESTING END===================== +PLTCMD='/^Relocation section .*\(\.rela\?\.plt\|\.rela\.IA_64\.pltoff\)/,/^$/p' +echo ====================PLT RELOCS LD.SO================ +readelf -Wr $RPM_BUILD_ROOT/%{_lib}/ld-*.so | sed -n -e "$PLTCMD" +echo ====================PLT RELOCS LIBC.SO============== +readelf -Wr $RPM_BUILD_ROOT/%{_lib}/libc-*.so | sed -n -e "$PLTCMD" +echo ====================PLT RELOCS END================== + +pushd build-%{target} +LD_SHOW_AUXV=1 elf/ld.so --library-path .:elf:nptl:dlfcn /bin/true + +%if %{with valgrind} +elf/ld.so --library-path .:elf:nptl:dlfcn \ + /usr/bin/valgrind --error-exitcode=1 \ + elf/ld.so --library-path .:elf:nptl:dlfcn /usr/bin/true +%endif +popd + +%endif # %{run_glibc_tests} + +############################################################################## +# Install and uninstall scripts +############################################################################## +%pre -p +-- Check that the running kernel is new enough +required = '%{enablekernel}' +rel = posix.uname("%r") +if rpm.vercmp(rel, required) < 0 then + error("FATAL: kernel too old", 0) +end + +%post -p %{_prefix}/sbin/glibc_post_upgrade.%{_target_cpu} + +%posttrans common -e -p +if posix.stat("%{_prefix}/lib/locale/locale-archive.tmpl", "size") > 0 then + pid = posix.fork() + if pid == 0 then + posix.exec("%{_prefix}/sbin/build-locale-archive", "--install-langs", "%%{_install_langs}") + elseif pid > 0 then + posix.wait(pid) + end +end + +%postun common -p +os.remove("%{_prefix}/lib/locale/locale-archive") + +%pre devel +# this used to be a link and it is causing nightmares now +if [ -L %{_prefix}/include/scsi ] ; then + rm -f %{_prefix}/include/scsi +fi + +%if %{with docs} +%post devel +/sbin/install-info %{_infodir}/libc.info.gz %{_infodir}/dir > /dev/null 2>&1 || : + +%preun devel +if [ "$1" = 0 ]; then + /sbin/install-info --delete %{_infodir}/libc.info.gz %{_infodir}/dir > /dev/null 2>&1 || : +fi +%endif + +%pre -n nscd +getent group nscd >/dev/null || /usr/sbin/groupadd -g 28 -r nscd +getent passwd nscd >/dev/null || + /usr/sbin/useradd -M -o -r -d / -s /sbin/nologin \ + -c "NSCD Daemon" -u 28 -g nscd nscd + +%post -n nscd +%systemd_post nscd.service + +%preun -n nscd +%systemd_preun nscd.service + +%postun -n nscd +if test $1 = 0; then + /usr/sbin/userdel nscd > /dev/null 2>&1 || : +fi +%systemd_postun_with_restart nscd.service + +############################################################################## +# Files list +############################################################################## +%files +%verify(not md5 size mtime) %config(noreplace) /etc/nsswitch.conf +%verify(not md5 size mtime) %config(noreplace) /etc/ld.so.conf +%verify(not md5 size mtime) %config(noreplace) /etc/rpc +%verify(not md5 size mtime) %config(noreplace) /usr/lib64/gconv/gconv-modules +%verify(not md5 size mtime) /usr/lib64/gconv/gconv-modules.cache +%dir /etc/ld.so.conf.d +%dir %{_prefix}/libexec/getconf +%{_prefix}/libexec/getconf/* +%dir %{_libdir}/gconv +%{_libdir}/gconv/*.so +%dir %{_libdir}/audit +%{_libdir}/audit/* +%dir %attr(0700,root,root) /var/cache/ldconfig +%attr(0600,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /var/cache/ldconfig/aux-cache +%attr(0644,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /etc/ld.so.cache +%attr(0644,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /etc/gai.conf +%{_sbindir}/glibc* +%{_sbindir}/iconvconfig +/lib/* +%{_libdir}/libmemusage.so +%{_libdir}/libpcprofile.so +/sbin/ldconfig +/%{_lib}/*.* +%exclude /%{_lib}/libnss_db* +%exclude /%{_lib}/libnss_hesiod* +%exclude /%{_lib}/libnsl* +%exclude /lib/systemd +%license COPYING COPYING.LIB LICENSES + +%files common +%dir %{_prefix}/share/i18n +%dir %{_prefix}/share/i18n/charmaps +%dir %{_prefix}/share/i18n/locales +%attr(0644,root,root) %verify(not md5 size mtime) %{_prefix}/lib/locale/locale-archive.tmpl +%attr(0644,root,root) %verify(not md5 size mtime mode) %ghost %config(missingok,noreplace) %{_prefix}/lib/locale/locale-archive +%{_prefix}/lib/locale/C.utf8 +%{_prefix}/lib/locale/zh_CN.utf8 +%{_prefix}/lib/locale/en_US.utf8 +%{_prefix}/share/locale/zh_CN +%{_prefix}/share/locale/en_GB +%{_prefix}/bin/catchsegv +%{_prefix}/bin/gencat +%{_prefix}/bin/getconf +%{_prefix}/bin/getent +%{_prefix}/bin/iconv +%{_prefix}/bin/ldd +%{_prefix}/bin/locale +%{_prefix}/bin/localedef +%{_prefix}/bin/makedb +%{_prefix}/bin/pldd +%{_prefix}/bin/sotruss +%{_prefix}/bin/sprof +%{_prefix}/bin/tzselect +%dir %attr(755,root,root) /etc/default +%verify(not md5 size mtime) %config(noreplace) /etc/default/nss +%{_prefix}/share/locale/locale.alias +%{_sbindir}/build-locale-archive +%{_sbindir}/zdump +%{_sbindir}/zic + +%files all-langpacks -f libc.lang +%{_prefix}/lib/locale +%exclude %{_prefix}/lib/locale/locale-archive +%exclude %{_prefix}/lib/locale/locale-archive.tmpl +%exclude %{_prefix}/lib/locale/C.utf8 +%exclude %{_prefix}/lib/locale/zh_CN.utf8 +%exclude %{_prefix}/lib/locale/en_US.utf8 +%exclude %{_prefix}/share/locale/zh_CN +%exclude %{_prefix}/share/locale/en_GB + +%files locale-source +%{_prefix}/share/i18n/locales/* +%{_prefix}/share/i18n/charmaps/* + +%files devel +%{_infodir}/* +%{_libdir}/*.a +%{_libdir}/*.o +%{_libdir}/*.so +%{_prefix}/include/*.h +%dir %{_prefix}/include/arpa +%dir %{_prefix}/include/bits +%dir %{_prefix}/include/bits/types +%dir %{_prefix}/include/gnu +%dir %{_prefix}/include/net +%dir %{_prefix}/include/netash +%dir %{_prefix}/include/netatalk +%dir %{_prefix}/include/netax25 +%dir %{_prefix}/include/neteconet +%dir %{_prefix}/include/netinet +%dir %{_prefix}/include/netipx +%dir %{_prefix}/include/netiucv +%dir %{_prefix}/include/netpacket +%dir %{_prefix}/include/netrom +%dir %{_prefix}/include/netrose +%dir %{_prefix}/include/nfs +%dir %{_prefix}/include/protocols +%dir %{_prefix}/include/rpc +%dir %{_prefix}/include/scsi +%dir %{_prefix}/include/sys +%{_prefix}/include/arpa/* +%{_prefix}/include/bits/* +%{_prefix}/include/gnu/* +%{_prefix}/include/net/* +%{_prefix}/include/netash/* +%{_prefix}/include/netatalk/* +%{_prefix}/include/netax25/* +%{_prefix}/include/neteconet/* +%{_prefix}/include/netinet/* +%{_prefix}/include/netipx/* +%{_prefix}/include/netiucv/* +%{_prefix}/include/netpacket/* +%{_prefix}/include/netrom/* +%{_prefix}/include/netrose/* +%{_prefix}/include/nfs/* +%{_prefix}/include/protocols/* +%{_prefix}/include/rpc/* +%{_prefix}/include/scsi/* +%{_prefix}/include/sys/* +%exclude %{_libdir}/libmemusage.so +%exclude %{_libdir}/libpcprofile.so +%exclude %{_libdir}/libnss* + +%files -n nscd +%config(noreplace) /etc/nscd.conf +%dir %attr(0755,root,root) /var/run/nscd +%dir %attr(0755,root,root) /var/db/nscd +/lib/systemd/system/nscd.service +/lib/systemd/system/nscd.socket +%{_tmpfilesdir}/nscd.conf +%attr(0644,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /var/run/nscd/nscd.pid +%attr(0666,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /var/run/nscd/socket +%attr(0600,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /var/run/nscd/passwd +%attr(0600,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /var/run/nscd/group +%attr(0600,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /var/run/nscd/hosts +%attr(0600,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /var/run/nscd/services +%attr(0600,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /var/db/nscd/passwd +%attr(0600,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /var/db/nscd/group +%attr(0600,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /var/db/nscd/hosts +%attr(0600,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /var/db/nscd/services +%ghost %config(missingok,noreplace) /etc/sysconfig/nscd +%{_sbindir}/nscd + +%files -n nss_modules +/var/db/Makefile +/%{_lib}/libnss_db* +/%{_lib}/libnss_hesiod* + +%files nss-devel +%{_libdir}/libnss* + +%files -n libnsl +/%{_lib}/libnsl* + +%if %{with benchtests} +%files benchtests +%{_prefix}/libexec/glibc-benchtests/* +%endif + +%files debugutils +%if %{without bootstrap} +%{_prefix}/bin/memusage +%{_prefix}/bin/memusagestat +%endif +%{_prefix}/bin/mtrace +%{_prefix}/bin/pcprofiledump +%{_prefix}/bin/xtrace +%{_prefix}/lib/debug/usr/bin/*.debug +%{_prefix}/lib/debug/usr/lib64/*.a + + +%files help +#Doc of glibc package +%doc README NEWS INSTALL elf/rtld-debugger-interface.txt + +#Doc of common sub-package +%doc documentation/README.timezone +%doc documentation/gai.conf + +#Doc of nss_modules sub-package +%doc hesiod/README.hesiod + + +%changelog +* Fri Jan 18 2019 openEuler Buildteam - 2.28-25 +- Package init diff --git a/nscd.conf b/nscd.conf new file mode 100644 index 0000000..8a24a78 --- /dev/null +++ b/nscd.conf @@ -0,0 +1 @@ +d /run/nscd 0755 root root diff --git a/nsswitch.conf b/nsswitch.conf new file mode 100644 index 0000000..b49a3b2 --- /dev/null +++ b/nsswitch.conf @@ -0,0 +1,56 @@ +# +# /etc/nsswitch.conf +# +# An example Name Service Switch config file. This file should be +# sorted with the most-used services at the beginning. +# +# The entry '[NOTFOUND=return]' means that the search for an +# entry should stop if the search in the previous entry turned +# up nothing. Note that if the search failed due to some other reason +# (like no NIS server responding) then the search continues with the +# next entry. +# +# Valid entries include: +# +# nisplus Use NIS+ (NIS version 3) +# nis Use NIS (NIS version 2), also called YP +# dns Use DNS (Domain Name Service) +# files Use the local files in /etc +# db Use the pre-processed /var/db files +# compat Use /etc files plus *_compat pseudo-databases +# hesiod Use Hesiod (DNS) for user lookups +# sss Use sssd (System Security Services Daemon) +# [NOTFOUND=return] Stop searching if not found so far +# +# 'sssd' performs its own 'files'-based caching, so it should +# generally come before 'files'. + +# To use 'db', install the nss_db package, and put the 'db' in front +# of 'files' for entries you want to be looked up first in the +# databases, like this: +# +# passwd: db files +# shadow: db files +# group: db files + +passwd: sss files +shadow: files sss +group: sss files + +hosts: files dns myhostname + +bootparams: files + +ethers: files +netmasks: files +networks: files +protocols: files +rpc: files +services: files sss + +netgroup: sss + +publickey: files + +automount: files sss +aliases: files