Sample Header Ad - 728x90

Unix & Linux Stack Exchange

Q&A for users of Linux, FreeBSD and other Unix-like operating systems

Latest Questions

2 votes
1 answers
158 views
Is there a default or recommended directory to store source files ('configure', 'Makefile', etc) of *user* installs?
Suppose I have downloaded the source of some software I want to install *just for myself*, not system-wide; say Emacs or whatever. Typically the source is downloaded zipped, then it's unzipped in some directory. This directory contains files like "Makefile", "LICENSE", "configure", and so on. **Ques...
Suppose I have downloaded the source of some software I want to install *just for myself*, not system-wide; say Emacs or whatever. Typically the source is downloaded zipped, then it's unzipped in some directory. This directory contains files like "Makefile", "LICENSE", "configure", and so on. **Question: where should such a source directory be stored (for future check or use) within one's $HOME directory?** I checked the [XDG Base Directory Specification](https://specifications.freedesktop.org/basedir-spec/latest/) , but I don't manage to recognize any guidelines there – also because I'm a noob and I don't know if such files are considered "data files" or "state files" or other technical denomiations. A lot of (old) questions ask about where to install the local *executables*, for instance [this question](https://askubuntu.com/q/1148/1519798) or [this question](https://unix.stackexchange.com/q/127076/515980) or [this question](https://unix.stackexchange.com/q/316765/515980) (my system Kubuntu 24.04 confirms that ~/.local/bin is a good place, it's added to $PATH by default). Only [this question](https://unix.stackexchange.com/q/362642/515980) asks about the source files, but it seems to refer to system-wide ones, not local-user ones. It seems strange to me to have to save the source in system-wide /usr/src or the like.
pglpm (162 rep)
Aug 6, 2025, 08:52 AM • Last activity: Aug 6, 2025, 09:04 AM
4 votes
1 answers
221 views
Where can I find the source code to language pack templates?
I was curious to dig a little deeper into [this question](https://unix.stackexchange.com/q/797381/) and realised that I don't know where to look for language pack templates. But beyond basic high-level discussion in [locale-gen](https://manpages.debian.org/testing/locales/locale-gen.8.en.html), I'm...
I was curious to dig a little deeper into [this question](https://unix.stackexchange.com/q/797381/) and realised that I don't know where to look for language pack templates. But beyond basic high-level discussion in [locale-gen](https://manpages.debian.org/testing/locales/locale-gen.8.en.html) , I'm at a bit of a loss to know where to look for them. I'm particularly interested to look at how collation rules are constructed and what they look like in practical source code for well known locales such as en_US.utf-8 and en_GB-utf-8. Are these largely shared between distributions? And where are they maintained in source code? *Unfortunately google is giving me complete blanks on this one.*
Philip Couling (20391 rep)
Jun 26, 2025, 02:15 PM • Last activity: Jun 26, 2025, 03:26 PM
18 votes
4 answers
14952 views
Best way to make variables local in a source'd bash script?
I have a bash script that generates a report on the progress of some long-running jobs on the machine. Basically, this parent script loops through a list of child scripts (calling them all with `source`). The child scripts are expected to set a couple of specific variables, which the parent script w...
I have a bash script that generates a report on the progress of some long-running jobs on the machine. Basically, this parent script loops through a list of child scripts (calling them all with source). The child scripts are expected to set a couple of specific variables, which the parent script will then make use of. Today, I discovered a bug where, a variable set by the first child script accidentally got used by the second child script, causing incorrect output. Is there a clean way to prevent these types of bugs from happening? Basically, when I source a child script, there are a couple of specific variables that I want to persist back to the parent script. My parent script resets these specific variables before it sources each new child script, so there are no issues with them. However, some child scripts may have additional arbitrary variables that it uses locally that should not persist back to the parent script. Obviously I could manually unset each of these at the end of the child script, but these seems prone to error if I forget one. Is there a more proper way of sourcing a script, and having only certain variables persist to the script that called source? edit: For sake of clarity, here's a sort of dumbed down version of my parent script: echo "

My jobs

" FILES=~/confs/*.sh for f in $FILES; do # reset variables name="Unnamed job" secsSinceActive="Unknown" statusText="Unknown" # run the script that checks on the job source "$f" # print bit of report echo "

$name

" echo "

Last active: $secsSinceActive seconds ago

" echo "

Status: $statusText

" echo "" And here's what one of the child scripts might look like: name="My awesome job" nowTime=expr $(date +%s) lastActiveTime=expr $(date +%s -r ~/blah.log) secsSinceActive=expr $nowTime - $lastActiveTime currentRaw=$(cat ~/blah.log | grep "Progress" | tail -n 1) if [ -z "$currentRaw" ]; then statusText="Not running" else statusText="In progress" fi The variables $name, $secsSinceActive, and $statusText need to persist back to the parent script, but all the other variables should disappear when the child script terminates.
Hayden Schiff (977 rep)
Jul 30, 2015, 06:21 PM • Last activity: May 28, 2025, 07:57 AM
1 votes
1 answers
45 views
Can you use debuild to only apply patches to source and then exit?
I am trying to build `gcc-6` source package on Raspbian stretch; so I do: ``` apt source gcc-6 cd gcc-6-6.3.0/debian debuild -b -uc -us ``` The `debuild` command starts the full build. Since the build crashes on my platform, what I'd like to run a command, that will unpack the sources and apply the...
I am trying to build gcc-6 source package on Raspbian stretch; so I do:
apt source gcc-6
cd gcc-6-6.3.0/debian
debuild -b -uc -us
The debuild command starts the full build. Since the build crashes on my platform, what I'd like to run a command, that will unpack the sources and apply the Debian patches, but then stop before configuring (so I can apply my own patches) - and then I could continue afterwards with debuild -b -uc -us -nc. Is there a command that would help me do that?
sdbbs (578 rep)
Mar 21, 2025, 02:47 PM • Last activity: Mar 21, 2025, 02:54 PM
1 votes
1 answers
86 views
How to find which Debian package might include a given source file?
I would like to debug my application in `gdb`, however with full sources of some system libraries I might need. For instance, at a certain point in my debug process in `gdb`, I arrive at a situation like: ```none ... (gdb) si 0x00047e28 in std::thread::detach() () (gdb) c Continuing. ... Thread 1 "m...
I would like to debug my application in gdb, however with full sources of some system libraries I might need. For instance, at a certain point in my debug process in gdb, I arrive at a situation like:
...
(gdb) si
0x00047e28 in std::thread::detach() ()
(gdb) c
Continuing.
...
Thread 1 "myProject" received signal SIGABRT, Aborted.
raise (sig=) at ../sysdeps/unix/sysv/linux/raise.c:51
51      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
I am not sure why for std::thread::detach() I do not get a source file suggestion (I have looked it up manually online and found it is in [libstdc++-v3/src/c++11/thread.cc](https://github.com/gcc-mirror/gcc/blob/releases/gcc-6.3.0/libstdc%2B%2B-v3/src/c%2B%2B11/thread.cc)) , but for raise() I do get source file and line ../sysdeps/unix/sysv/linux/raise.c:51. Anyways, for either of these, thread.cc or raise.c, how can I find which *source* package on a given Debian includes them? So I could eventually get them with apt source [package] and provide the path to those files to gdb as described in https://stackoverflow.com/questions/48278881/gdb-complaining-about-missing-raise-c/48287761#48287761 so I could step through source lines (and especially see what underlying function receive as arguments from my code) ... I have tried apt-file, but it seems that it does not work with source packages:
$ apt-file search raise.c
gnulib: /usr/share/gnulib/lib/raise.c
gnulib: /usr/share/gnulib/tests/test-raise.c
` Cool, but none of those look like ../sysdeps/unix/sysv/linux/raise.c?!
$ apt-file search thread.cc
c++-annotations: /usr/share/doc/c++-annotations/examples/yo/threading/examples/functorthread.cc
libglibmm-2.4-doc: /usr/share/doc/libglibmm-2.4-doc/examples/thread/thread.cc
omniorb-doc: /usr/share/doc/omniorb-doc/examples/poa/threading/mainthread.cc
rust-src: /usr/src/rustc-1.24.1/src/libcompiler_builtins/compiler-rt/lib/asan/asan_thread.cc
rust-src: /usr/src/rustc-1.24.1/src/libcompiler_builtins/compiler-rt/lib/lsan/lsan_thread.cc
rust-src: /usr/src/rustc-1.24.1/src/libcompiler_builtins/compiler-rt/lib/msan/msan_thread.cc
rust-src: /usr/src/rustc-1.24.1/src/libcompiler_builtins/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc
rust-src: /usr/src/rustc-1.24.1/src/libcompiler_builtins/compiler-rt/lib/tsan/tests/rtl/tsan_thread.cc
rust-src: /usr/src/rustc-1.24.1/src/libcompiler_builtins/compiler-rt/test/tsan/race_with_finished_thread.cc
rust-src: /usr/src/rustc-1.24.1/src/libcompiler_builtins/compiler-rt/test/tsan/signal_thread.cc
Ok, apt-file again found something, but all of them seem to be false positives, nothing matches the expected libstdc++-v3/src/c++11/thread.cc. So, is there any way to look up source files like this on Debian? Specifically, I'm on Raspbian Stretch on Raspberry Pi 3B+.
sdbbs (578 rep)
Mar 19, 2025, 08:25 PM • Last activity: Mar 20, 2025, 12:34 PM
4 votes
1 answers
296 views
How do I "go back" after installing a locally built package
I have looked around on instruction on how to download debian source package, build them and then installing the resultin deb-file(s), but the one I feel is missing is instruction on how to reverse it and go back to use the official (binary) package(s), as fetched from the debian repository.
I have looked around on instruction on how to download debian source package, build them and then installing the resultin deb-file(s), but the one I feel is missing is instruction on how to reverse it and go back to use the official (binary) package(s), as fetched from the debian repository.
skyking (352 rep)
Nov 8, 2024, 12:14 PM • Last activity: Nov 8, 2024, 12:27 PM
1 votes
1 answers
281 views
How can I build fdupes from source on Ubuntu?
I would like to make a few changes to the fdupes code. I know I can grab the source code from the website - but is there a better way on Ubuntu / Debian? - After getting the source this way where is it stored? - If one wanted to make changes to the code and recompile / install - how is that done? -...
I would like to make a few changes to the fdupes code. I know I can grab the source code from the website - but is there a better way on Ubuntu / Debian? - After getting the source this way where is it stored? - If one wanted to make changes to the code and recompile / install - how is that done? - Is there a good way to manage changes when updates come out?
cwd (46887 rep)
Jun 5, 2013, 11:03 PM • Last activity: Oct 17, 2024, 08:26 AM
94 votes
8 answers
147633 views
Which file compression software for Linux offers the highest size reduction for source code?
I do a ton of file compression. Most of the stuff I am compressing is just code, so I need to use lossless compression. I wondered if there was anything that offers a better size reduction than 7zip. It doesn't matter how long it takes to compress or decompress; size is all that matters. Does anyone...
I do a ton of file compression. Most of the stuff I am compressing is just code, so I need to use lossless compression. I wondered if there was anything that offers a better size reduction than 7zip. It doesn't matter how long it takes to compress or decompress; size is all that matters. Does anyone know how the various tools and compression algorithms available in Linux compare for compressing text? Or is 7zip the best for compressing source code?
Zach (1071 rep)
Jun 5, 2013, 03:13 AM • Last activity: Sep 4, 2024, 03:56 PM
378 votes
8 answers
54084 views
How can I find the implementations of Linux kernel system calls?
I am trying to understand how a function, say `mkdir`, works by looking at the kernel source. This is an attempt to understand the kernel internals and navigate between various functions. I know `mkdir` is defined in `sys/stat.h`. I found the prototype: /* Create a new directory named PATH, with per...
I am trying to understand how a function, say mkdir, works by looking at the kernel source. This is an attempt to understand the kernel internals and navigate between various functions. I know mkdir is defined in sys/stat.h. I found the prototype: /* Create a new directory named PATH, with permission bits MODE. */ extern int mkdir (__const char *__path, __mode_t __mode) __THROW __nonnull ((1)); Now I need to see in which C file this function is implemented. From the source directory, I tried ack "int mkdir" which displayed security/inode.c 103:static int mkdir(struct inode *dir, struct dentry *dentry, int mode) tools/perf/util/util.c 4:int mkdir_p(char *path, mode_t mode) tools/perf/util/util.h 259:int mkdir_p(char *path, mode_t mode); But none of them matches the definition in sys/stat.h. *Questions* 1. Which file has the mkdir implementation? 2. With a function definition like the above, how can I find out which file has the implementation? Is there any pattern which the kernel follows in defining and implementing methods? NOTE: I am using kernel 2.6.36-rc1 .
Navaneeth K N (3998 rep)
Aug 19, 2010, 02:26 PM • Last activity: Aug 16, 2024, 01:13 PM
0 votes
1 answers
246 views
How to get a copy of libdevmapper 1.02.34 or later?
I am trying to update GRUB 2.06 to 2.12 on an Ubuntu 22.04.4 LTS machine, following the instructions in the INSTALL text file included in the tarball (and at the bottom of the post). Reading through the prereqs (included below), I see I need `libdevmapper 1.02.34`. I don't seem to have this file, co...
I am trying to update GRUB 2.06 to 2.12 on an Ubuntu 22.04.4 LTS machine, following the instructions in the INSTALL text file included in the tarball (and at the bottom of the post). Reading through the prereqs (included below), I see I need libdevmapper 1.02.34. I don't seem to have this file, considering later when I run ./configure, ./configure's output ends with:
*******************************************************
GRUB2 will be compiled with following components:
Platform: i386-pc
With devmapper support: No (need libdevmapper header)
With memory debugging: No
With disk cache statistics: No
With boot time statistics: No
efiemu runtime: Yes
grub-mkfont: No (need freetype2 library)
grub-mount: No (need fuse or fuse3 libraries)
starfield theme: No (No build-time grub-mkfont)
With libzfs support: No (need zfs library)
Build-time grub-mkfont: No (need freetype2 library)
Without unifont (no build-time grub-mkfont)
Without liblzma (no support for XZ-compressed mips images) (need lzma library)
With stack smashing protector: No
*******************************************************
**How do I obtain a copy of libdevmapper 1.02.34 or later?** Partial contents of INSTALL:
The Requirements
================

GRUB depends on some software packages installed into your system. If
you don't have any of them, please obtain and install them before
configuring the GRUB.

* GCC 5.1.0 or later
  Experimental support for clang 8.0.0 or later (results in much bigger binaries)
  for i386, x86_64, arm (including thumb), arm64, mips(el), powerpc, sparc64
* GNU Make
* GNU Bison 2.3 or later
* GNU gettext
* GNU binutils 2.9.1.0.23 or later
* Flex 2.5.35 or later
* pkg-config
* GNU patch
* Other standard GNU/Unix tools
* a libc with large file support (e.g. glibc 2.1 or later)

On GNU/Linux, you also need:

 * libdevmapper 1.02.34 or later (recommended)


...more content that I have cut out...


Building the GRUB
=================

The simplest way to compile this package is:

  1. `cd' to the directory containing the package's source code.

  2. Skip this and following step if you use release tarball and proceed to
     step 4. If you want translations type `./linguas.sh'.
  
  3. Type `./bootstrap'.

     The autogen.sh (called by bootstrap) uses python. By default autodetect
     it, but it can be overridden by setting the PYTHON variable.

  4. Type `./configure' to configure the package for your system.
     If you're using `csh' on an old version of System V, you might
     need to type sh ./configure' instead to prevent csh' from trying
     to execute `configure' itself.

     Running `configure' takes awhile.  While running, it prints some
     messages telling which features it is checking for.

  6. Type `make' to compile the package.

  7. Optionally, type `make check' to run any self-tests that come with
     the package. Note that many of the tests require root privileges in
     order to run.

  8. Type `make install' to install the programs and any data files and
     documentation.

  9. Type make html' or make pdf' to generate the html or pdf
     documentation.  Note, these are not built by default.

 10. You can remove the program binaries and object files from the
     source code directory by typing `make clean'.  To also remove the
     files that `configure' created (so you can compile the package for
     a different kind of computer), type `make distclean'.  There is
     also a `make maintainer-clean' target, but that is intended mainly
     for the package's developers.  If you use it, you may have to get
     all sorts of other programs in order to regenerate files that came
     with the distribution.
SuperDialga (95 rep)
Jul 19, 2024, 07:33 PM • Last activity: Jul 23, 2024, 10:48 AM
0 votes
1 answers
64 views
How to save changes to patch files for kernel headers in `include/linux` using `diff`?
I am trying to hack the Linux kernel and added/modified some header files in `include/linux`. However, when I generate patch file using `diff` like: ``` bash diff -uprN -X linux/Documentation/dontdiff \ linux-5.15 linux-srctree > patch.p1 ``` I find changes under `include/linux` not included in `pat...
I am trying to hack the Linux kernel and added/modified some header files in include/linux. However, when I generate patch file using diff like:
bash
diff -uprN -X linux/Documentation/dontdiff \
        linux-5.15 linux-srctree > patch.p1
I find changes under include/linux not included in patch.p1. I then look into dontdiff file and find the following lines (around line 158), which means it excludes include/linux from the patch file.
*lex.*.c
linux
logo_*.c
So why does dontdiff include linux? How to save changes to patch files for headers in include/linux? Thanks a lot.
Kalman (3 rep)
Jul 23, 2024, 03:22 AM • Last activity: Jul 23, 2024, 07:09 AM
0 votes
0 answers
136 views
OpenDKIM Isn't building with OpenSSL correctly
I am trying to build OpenDKIM from source. For some reason, the build is not supporting SHA-256, even when the OpenSSL version I am building with uses SHA-256. How is this possible ? I run: ``` ./configure --with-openssl=/path/to/openssl/ssl ``` Then `make` and `make install` as usual. Checking `ope...
I am trying to build OpenDKIM from source. For some reason, the build is not supporting SHA-256, even when the OpenSSL version I am building with uses SHA-256. How is this possible ? I run:
./configure --with-openssl=/path/to/openssl/ssl
Then make and make install as usual. Checking opendkim -V shows the only supported algorithm is sha1. What is going wrong ? I have tried build with the latest stable OpenDKIM version 2.10.3 and the pre-release 2.11.0. Both have the same error. Is openssl somehow not being correctly linked ? I am really stuck here - any help is appreciated !
user10709800 (73 rep)
Jul 12, 2024, 02:08 PM • Last activity: Jul 14, 2024, 04:56 AM
57 votes
8 answers
46433 views
Where does uname get its information from?
Where does uname really get its information from? I figure this is something that should be straightforward. Unfortunately, I can't find any header containing just that information. Say someone wanted to change the basic output of `uname`/`uname -s` from `Linux` to something else (essentially, renam...
Where does uname really get its information from? I figure this is something that should be straightforward. Unfortunately, I can't find any header containing just that information. Say someone wanted to change the basic output of uname/uname -s from Linux to something else (essentially, renaming the kernel). How would he/she go about doing that the proper way (that is, changing the source)?
user237251 (750 rep)
Jun 13, 2014, 01:56 PM • Last activity: Jun 28, 2024, 03:33 PM
1 votes
1 answers
958 views
Debian script to download source of installed packages fails
I used the next script from askububtu to automate the download of all installed packages in a fresh debian 9.3 LXDE installation. [From here:][1] #!/bin/bash dpkg --get-selections | while read line do package=`echo $line | awk '{print $1}'` mkdir $package cd $package apt-get -q source $package cd .....
I used the next script from askububtu to automate the download of all installed packages in a fresh debian 9.3 LXDE installation. From here: #!/bin/bash dpkg --get-selections | while read line do package=echo $line | awk '{print $1}' mkdir $package cd $package apt-get -q source $package cd .. done My problem is that I get some errors and it downloads a similar but not the wanted package: > sh: 1: dpkg-source: not found > W: Download is performed unsandboxed as root as file > 'libreoffice_5.2.7-1.dsc' couldn't be accessed by user '_apt'. - > pkgAcquire::Run (13: Permission denied) E: Unpack command 'dpkg-source > --no-check -x libreoffice_5.2.7-1.dsc' failed. Reading package lists... Picking 'libreoffice' as source package instead of > 'libreoffice-calc' You can imagine that it downloads 300MB or so every 3-4 minutes (libreoffice) for many times (for almost every dependency of libreoffice)... Does anyone has a better suggestion than that script to automate the source download of the packages used on my system?
koleygr (355 rep)
Feb 10, 2018, 08:02 PM • Last activity: May 22, 2024, 09:09 AM
6 votes
0 answers
4749 views
Could NOT find LLVM (missing: LLVM_DIR)
I'm trying to install darktable from source on Fedora 27. I've installed [all dependencies](https://redmine.darktable.org/projects/darktable/wiki/Building_darktable_22#Fedora-24-and-25), but when I run cmake I got error: -- Could NOT find LLVM (missing: LLVM_DIR) CMake Warning at CMakeLists.txt:381...
I'm trying to install darktable from source on Fedora 27. I've installed [all dependencies](https://redmine.darktable.org/projects/darktable/wiki/Building_darktable_22#Fedora-24-and-25) , but when I run cmake I got error: -- Could NOT find LLVM (missing: LLVM_DIR) CMake Warning at CMakeLists.txt:381 (message): Could not find LLVM 3.9+ What should be the content of this variable. I've tried this: $ whereis llvm llvm: /usr/lib64/llvm $ export LLVM_DIR=/usr/lib64/llvm $ cmake -DCMAKE_INSTALL_PREFIX=/opt/darktable/ .. but got the same error that it can't find llvm. I have llvm version 5.0.2
jcubic (10310 rep)
Aug 10, 2018, 01:04 PM • Last activity: May 7, 2024, 07:06 AM
3 votes
1 answers
1334 views
OpenBSD: Where to seek for the source of programs in the base system?
In OpenBSD, I use `pkg_info -E $(which [cmd])` to be supplied with the name of the package/port to the executable/command `[cmd]`. Having this information I can further look for the source code to the software. However, there are some utilities that seem to be shipped with the base install of OpenBS...
In OpenBSD, I use pkg_info -E $(which [cmd]) to be supplied with the name of the package/port to the executable/command [cmd]. Having this information I can further look for the source code to the software. However, there are some utilities that seem to be shipped with the base install of OpenBSD, such as the netstat utility. Where would I go about finding the source code of such programs?
fraleone (897 rep)
Jan 20, 2020, 11:20 AM • Last activity: Apr 25, 2024, 04:50 PM
21 votes
3 answers
10374 views
common environment variable to set dark or light terminal background
I have written a [number][1] [of][2] [debuggers][3] that all can colorize source code text shown in a terminal session. They all understand that some terminals have a dark background and some have a light background and that of course the colors need to be different depending on the terminal scheme....
I have written a number of debuggers that all can colorize source code text shown in a terminal session. They all understand that some terminals have a dark background and some have a light background and that of course the colors need to be different depending on the terminal scheme. It is annoying to have to set to the other scheme when your terminal doesn't match the default background, so I'd like to find a way to figure this out automatically. Suggestions? (They all support options --highlight={light|dark|plain}) One simple mechanism would be to key off an environment variable. For my shell profiles I've been using DARK_BACKGROUND_COLOR, but If there is already some sort of default name like there is for PAGER, EDITOR, SHELL, HOME, etc. I'd like to use that. Is there such a environment name convention? Other suggestions? *Edit:* Based on the accepted answer and discussion, I have switched from using DARK_BACKGROUND_COLOR to COLORFGBG. Value 15;0 is for a dark background (technically white on black) and 0;15 (technically black on white) is for a light background.
rocky (2018 rep)
Nov 25, 2015, 11:37 AM • Last activity: Mar 16, 2024, 04:35 PM
29 votes
8 answers
27587 views
Running "patch" without generating *.orig and *.rej files
Is it possible to tell `patch` not to generate `.orig` and `.rej` files? I find it extremely annoying that patch creates these.
Is it possible to tell patch not to generate .orig and .rej files? I find it extremely annoying that patch creates these.
TheLegassis (321 rep)
Sep 25, 2012, 06:50 AM • Last activity: Mar 16, 2024, 12:45 PM
10 votes
4 answers
8926 views
Usage of Bang (!) in bash
I am reading the bash source code, and the [BNF grammar][1] for bash would be: ::= | '!' | | '!' | '!' ::= '|' | Does this means `!` command is a kind of pipe too. `! ls` works, however it's the same as `ls`. `! time ls` works too. That's quite different to `|` pipe. How to use `!` in bash? Is it a...
I am reading the bash source code, and the BNF grammar for bash would be: ::= | '!' | | '!' | '!' ::= '|' | Does this means ! command is a kind of pipe too. ! ls works, however it's the same as ls. ! time ls works too. That's quite different to | pipe. How to use ! in bash? Is it a pipe?
frams (566 rep)
Nov 25, 2017, 01:39 PM • Last activity: Mar 14, 2024, 04:07 PM
0 votes
0 answers
263 views
Unexpected syntax error in VERSION file when building gettext
I am trying to build the gettext package from source. When running `make` I receive an error: ``` make[5]: Entering directory '/source/gettext-0.22/gettext-tools/libgettextpo' [..........] libtool: link: gcc -shared -fPIC -DPIC -Wl,--whole-archive ./.libs/libgnu.a -Wl,--no-whole-archive -lc -g -O2 -...
I am trying to build the gettext package from source. When running make I receive an error:
make: Entering directory '/source/gettext-0.22/gettext-tools/libgettextpo'
[..........]
libtool: link:  gcc -shared  -fPIC -DPIC  -Wl,--whole-archive ./.libs/libgnu.a -Wl,--no-whole-archive  -lc  -g -O2   -Wl,-soname -Wl,libgettextpo.so.0 -Wl,-version-script -Wl,.libs/libgettextpo.ver -o .libs/libgettextpo.so.0.5.9
/usr/bin/ld:.libs/libgettextpo.ver:2: syntax error in VERSION script
collect2: error: ld returned 1 exit status
make: *** [Makefile:4012: libgettextpo.la] Error 1
make: Leaving directory '/source/gettext-0.22/gettext-tools/libgettextpo'
[............]
make: *** [Makefile:362: all] Error 2
The error message hinted me at some kind of syntax error on line 2 in one specific file, so I proceeded to check the mentioned file:
root:/source/gettext-0.22# cat gettext-tools/libgettextpo/.libs/libgettextpo.ver
{ global:
local: *; };
========UPDATE======== As [steeldriver](https://unix.stackexchange.com/users/65304/steeldriver) suggested, the .ver file is autogenerated by the 'make' command. Here is the part of the output, responsible for that:
libtool: link: /usr/bin/nm -B   ./.libs/libgnu.a | /usr/bin/sed -n -e 's/^.*[	 ]\([ABCDGIRSTW][ABCDGIRSTW]*\)[	 ][	 ]*\([_A-Za-z][_A-Za-z0-9]*\)$/\1 \2 \2/p' | /usr/bin/sed '/ __gnu_lto/d' | /usr/bin/sed 's/.* //' | sort | uniq > .libs/libgettextpo.exp
libtool: link: /usr/bin/grep -E -e "^([^l]|l[^i]|li[^b]|lib[^g]|libg[^e]|libge[^t]|libget[^t]|libgett[^e]|libgette[^x]|libgettex[^t]|libgettext[^p]|libgettextp[^o]|libgettextpo[^_]|libgettextpo_version).*" ".libs/libgettextpo.exp" > ".libs/libgettextpo.expT"
libtool: link: mv -f ".libs/libgettextpo.expT" ".libs/libgettextpo.exp"
libtool: link: echo "{ global:" > .libs/libgettextpo.ver
libtool: link:  cat .libs/libgettextpo.exp | /usr/bin/sed -e "s/\(.*\)/\1;/" >> .libs/libgettextpo.ver
libtool: link:  echo "local: *; };" >> .libs/libgettextpo.ver
If I understood the logs correctly, make extracts symbols from libgnu.a file, filters them based on some kind of regular expression and then passes them to libgettextpo.exp file, from which the final libgettextpo.ver file is created. libgnu.a file seems to be correct:
root:/source/gettext-0.22/gettext-tools/libgettextpo/.libs# nm -B libgnu.a

asnprintf.o:
                 U __stack_chk_fail
0000000000000000 T libgettextpo_asnprintf
                 U libgettextpo_vasnprintf

fopen.o:
                 U __errno_location
                 U __stack_chk_fail
                 U close
                 U fdopen
                 U fopen
0000000000000000 T libgettextpo_rpl_fopen
                 U memcpy
                 U open
                 U strlen

printf-args.o:
0000000000000000 r .LC0
0000000000000000 T libgettextpo_printf_fetchargs
00000000000000c0 r wide_null_string.0

printf-parse.o:
                 U __errno_location
                 U free
0000000000000000 T libgettextpo_printf_parse
                 U malloc
                 U memcpy
                 U realloc

vasnprintf.o:
                 U __errno_location
                 U __stack_chk_fail
                 U abort
                 U free
                 U libgettextpo_printf_fetchargs
                 U libgettextpo_printf_parse
0000000000000000 T libgettextpo_vasnprintf
0000000000000000 t libgettextpo_vasnprintf.cold
                 U malloc
                 U memcpy
                 U realloc
                 U snprintf
However, **libgettextpo.exp file is empty**. Thus, the issue must be somewhere over these two lines:
libtool: link: /usr/bin/nm -B   ./.libs/libgnu.a | /usr/bin/sed -n -e 's/^.*[    ]\([ABCDGIRSTW][ABCDGIRSTW]*\)[     ][  ]*\([_A-Za-z][_A-Za-z0-9]*\)$/\1 \2 \2/p' | /usr/bin/sed '/ __gnu_lto/d' | /usr/bin/sed 's/.* //' | sort | uniq > .libs/libgettextpo.exp
libtool: link: /usr/bin/grep -E -e "^([^l]|l[^i]|li[^b]|lib[^g]|libg[^e]|libge[^t]|libget[^t]|libgett[^e]|libgette[^x]|libgettex[^t]|libgettext[^p]|libgettextp[^o]|libgettextpo[^_]|libgettextpo_version).*" ".libs/libgettextpo.exp" > ".libs/libgettextpo.expT"
I checked whether commands used in those two lines are present on my system. sort, uniq and /usr/bin/sed are present. I have also heard something about grep being not able to work with '-e' flags before version 2.3. I have grep of version 3.11. ========UPDATE 2======== I tried to replicate this process manually and found out, that the command producing the empty file is this one:
root:/source/gettext-0.22/gettext-tools/libgettextpo# /usr/bin/grep -E -e "^([^l]|l[^i]|li[^b]|lib[^g]|libg[^e]|libge[^t]|libget[^t]|libgett[^e]|libgette[^x]|libgettex[^t]|libgettext[^p]|libgettextp[^o]|libgettextpo[^_]|libgettextpo_version).*" ".libs/libgettextpo.exp" > ".libs/libgettextpo.expT"
Testing showed, that grep -E -e works as intended. I also checked the contents of libgettextpo.exp before filtering, it turned out to be this:
libgettextpo_asnprintf
libgettextpo_printf_fetchargs
libgettextpo_printf_parse
libgettextpo_rpl_fopen
libgettextpo_vasnprintf
Turns out, neither of this strings match the regular expression, specified during the build process. Since nothing matches the regex, the problem might be in the libgnu.a file, from which the libgettextpo.exp file is being produced. Here is how libgnu.a is compiled:
/bin/sh ../libtool  --tag=CC   --mode=link gcc  -g -O2 -version-info 5:9:5 -rpath /usr/lib    -lc -no-undefined -export-symbols-regex '^([^l]|l[^i]|li[^b]|lib[^g]|libg[^e]|libge[^t]|libget[^t]|libgett[^e]|libgette[^x]|libgettex[^t]|libgettext[^p]|libgettextp[^o]|libgettextpo[^_]|libgettextpo_version).*'     -o libgettextpo.la -rpath /usr/lib gettext-po.lo ../src/str-list.lo ../src/dir-list.lo ../src/message.lo ../src/pos.lo ../src/msgl-ascii.lo ../src/po-error.lo ../src/po-xerror.lo ../src/write-catalog.lo ../src/write-po.lo ../src/open-catalog.lo ../src/po-charset.lo ../src/po-lex.lo ../src/po-gram-gen.lo ../src/read-po.lo ../src/read-catalog-abstract.lo ../src/read-catalog.lo ../src/plural-table.lo ../src/format-c.lo ../src/format-c++-brace.lo ../src/format-python.lo ../src/format-python-brace.lo ../src/format-java.lo ../src/format-java-printf.lo ../src/format-csharp.lo ../src/format-javascript.lo ../src/format-scheme.lo ../src/format-lisp.lo ../src/format-elisp.lo ../src/format-librep.lo ../src/format-ruby.lo ../src/format-sh.lo ../src/format-awk.lo ../src/format-lua.lo ../src/format-pascal.lo ../src/format-smalltalk.lo ../src/format-qt.lo ../src/format-qt-plural.lo ../src/format-kde.lo ../src/format-kde-kuit.lo ../src/format-boost.lo ../src/format-tcl.lo ../src/format-perl.lo ../src/format-perl-brace.lo ../src/format-php.lo ../src/format-gcc-internal.lo ../src/format-gfc-internal.lo ../src/format.lo ../src/plural-exp.lo ../src/plural-eval.lo ../src/msgl-check.lo ../src/sentence.lo  libgnu.la  
libtool: link: rm -fr  .libs/libgettextpo.exp .libs/libgettextpo.ver
Yakiv Baiduk (1 rep)
Mar 7, 2024, 02:07 PM • Last activity: Mar 8, 2024, 01:02 PM
Showing page 1 of 20 total questions