1

I'm using the Busybox 1.32.0 package tools in an embedded device. When I'm in Ubuntu based x64 platforms, the unzip tool packaged there can extract over a destination directory without prompting any errors if I'm trying to extract a symlink. However, in the case of Busybox, when I try to do this and there's already a symlink with the same link stored there I get this error:

unzip: '/usr/local/bin/sample.so.1' exists but is not a regular file

Sure it's not a regular file, because it's actually a symlink. But what I want to do is either:

  • Continue with the unzip process omitting this files.
  • Replace this files with the symlink files stored in the zip.

Is there any way to achieve this?

2
  • 1
    You could first do a unzip -l to get all the filenames, and pass them into a script to remove those files, such as xargs rm -f. Commented Jul 22, 2021 at 14:08
  • @alecxs, yes it does. Maybe I used the wrong sample: unzip: '/usr/local/bin/sample.so.1' exists but is not a regular file. Edited.. Commented Aug 26, 2021 at 16:29

1 Answer 1

2

No, it can't.

You'll have to remove it first.

This is the actual source code:

                /* Does target file already exist? */
                {
                        int mode = get_lstat_mode(dst_fn);
                        if (mode == -1) {
                                /* ENOENT: does not exist */
                                goto do_open_and_extract;
                        }
                        if (overwrite == O_NEVER) {
                                goto skip_cmpsize;
                        }
                        if (!S_ISREG(mode)) {
 fishy:
                                bb_error_msg_and_die("'%s' exists but is not a %
s",
                                        printable_string(dst_fn),
                                        "regular file"
                                );
                        }
                        if (overwrite == O_ALWAYS) {
                                goto do_open_and_extract;
                        }

As you see, no way to bypass that error.

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.