Discussion:
cat vs. cp in slackbuilds
Add Reply
Mike Small
2024-10-30 03:17:26 UTC
Reply
Permalink
I've noticed slackbuilds tend to copy files in place using cat unless
they do multiple files in one command, in which case they of course must
use cp. Anyone know the thinking behind or origin of that?

I see a couple web hits with possibilities but nothing definitive...

https://unix.stackexchange.com/questions/30295/cp-vs-cat-to-copy-a-file
https://www.linuxquestions.org/questions/linux-general-1/cat-vs-cp-777453/

Another possibility would be the GNU install program, but I never see
that used in slackbuild scripts.
King Beowulf
2024-10-30 03:48:56 UTC
Reply
Permalink
Post by Mike Small
I've noticed slackbuilds tend to copy files in place using cat unless
they do multiple files in one command, in which case they of course must
use cp. Anyone know the thinking behind or origin of that?
I see a couple web hits with possibilities but nothing definitive...
https://unix.stackexchange.com/questions/30295/cp-vs-cat-to-copy-a-file
https://www.linuxquestions.org/questions/linux-general-1/cat-vs-
cp-777453/
Post by Mike Small
Another possibility would be the GNU install program, but I never see
that used in slackbuild scripts.
Interesting question. I've used both in slackbuilds (and am also a
Slackbuilds.org maintainer) and usually opt for 'cp' when creating from
scratch. On the scripts I took over, I've left 'cat' unless there was a
reason to change. Copy file vs copy contents of file are a bit
different, but I am not sure if that is significant in package creation.

As for 'install', a few SBo scripts do use this, in the case of

1. .deb or similar repackage
2. no 'make install' target in build system

-Ed
Henrik Carlqvist
2024-10-30 15:50:54 UTC
Reply
Permalink
On Wed, 30 Oct 2024 03:48:56 +0000, King Beowulf wrote:
As for 'install', a few SBo scripts do use this, in the case of
Post by King Beowulf
2. no 'make install' target in build system
And also those build systems which do have "make install" implemented
often call gnu install from their Makefile. There is nothing wrong with a
SlackBuild script depending upon gnu install, as it included in the
stock coreutils package. SlackBuild scripts from slackbuilds.org may not
only require such fundamental packages installed, they are only tested
on, and thus might require a full install of Slackware.

regards Henrik
Eli the Bearded
2024-10-30 20:16:20 UTC
Reply
Permalink
Post by Mike Small
I've noticed slackbuilds tend to copy files in place using cat unless
they do multiple files in one command, in which case they of course must
use cp. Anyone know the thinking behind or origin of that?
I see a couple web hits with possibilities but nothing definitive...
https://unix.stackexchange.com/questions/30295/cp-vs-cat-to-copy-a-file
My speculation is on the permissions issues mentioned in a reply there.
cp will copy permissions (to a certain extent), cat > newfile will
create new permissions based on umask.

# touch /tmp/installme
# chmod 7661 /tmp/installme
# cat /tmp/installme > /tmp/installme-cat
# cp /tmp/installme /tmp/installme-cp
# ls -l /tmp/installme*
-rwSrwS--t 1 root root 0 Oct 30 13:13 /tmp/installme
-rw-r--r-- 1 root root 0 Oct 30 13:13 /tmp/installme-cat
-rw-r----x 1 root root 0 Oct 30 13:13 /tmp/installme-cp
#

But any proper install will be setting permissions as a followup step
anyway, right?

Elijah
------
the sparse file thing is plausible, too

Loading...