diff options
author | Bryan Drewery <bryan@shatow.net> | 2014-01-30 23:20:56 +0400 |
---|---|---|
committer | Bryan Drewery <bryan@shatow.net> | 2014-01-30 23:20:56 +0400 |
commit | 9c958124f5d47bfcd8d913c06a35220538583ba2 (patch) | |
tree | 3e1f7b9b0cb0741d9b804f27a13941c55fcf39ab /src/libexec | |
parent | d19c489448c496d6ab2fb321edda4a0aec637fe1 (diff) |
ATOMIC_PACKAGE_REPOSITORY: Fix build with 9.1 and 8.x
mv(1) supports the -h param in 10.0/head/9.2 to rename a symlink instead
of move it. Add our own rename(1) which will just call rename(2).
This also avoids overhead in mv(1) and may be beneficial in queue
handling.
Diffstat (limited to 'src/libexec')
-rw-r--r-- | src/libexec/poudriere/Makefile | 2 | ||||
-rw-r--r-- | src/libexec/poudriere/rename/Makefile | 8 | ||||
-rw-r--r-- | src/libexec/poudriere/rename/rename.c | 47 |
3 files changed, 56 insertions, 1 deletions
diff --git a/src/libexec/poudriere/Makefile b/src/libexec/poudriere/Makefile index 0bc69893..f26c50e8 100644 --- a/src/libexec/poudriere/Makefile +++ b/src/libexec/poudriere/Makefile @@ -1,4 +1,4 @@ -SUBDIR= dirempty dirwatch +SUBDIR= dirempty dirwatch rename .if !defined(DRAGONFLY) SUBDIR+= make_index cpdup diff --git a/src/libexec/poudriere/rename/Makefile b/src/libexec/poudriere/rename/Makefile new file mode 100644 index 00000000..aa7c73d5 --- /dev/null +++ b/src/libexec/poudriere/rename/Makefile @@ -0,0 +1,8 @@ +PREFIX?= /usr/local +BINDIR= ${PREFIX}/libexec/poudriere + +PROG= rename +NO_MAN= yes +WARNS= 6 + +.include <bsd.prog.mk> diff --git a/src/libexec/poudriere/rename/rename.c b/src/libexec/poudriere/rename/rename.c new file mode 100644 index 00000000..a3a43a23 --- /dev/null +++ b/src/libexec/poudriere/rename/rename.c @@ -0,0 +1,47 @@ +/*- + * Copyright (c) 2014 Bryan Drewery <bdrewery@FreeBSD.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <err.h> +#include <stdlib.h> +#include <stdio.h> +#include <sysexits.h> + +/** + * Just call rename(2) on the params. This is a replacement for mv(1) + * to both lower overhead and to support mv -h, which is not in 8.x or + * 9.1, to rename a symlink and not move it. + */ +int +main(int argc, char **argv) { + + if (argc != 3) + errx(EX_USAGE, "Usage: rename src dst"); + + if (rename(argv[1], argv[2])) + err(EXIT_FAILURE, NULL); + + return 0; +} |