cpt

[ARCHIVED] Carbs Packaging Tools
git clone git://git.ckyln.com/~cem/cpt.git
Log | Files | Refs | README | LICENSE

commit 6542d434d279e092ef54144a8d887c6e26f05482
parent 6277c7b12450e97ad783194eeeafe197c856f147
Author: Cem Keylan <cem@ckyln.com>
Date:   Mon,  4 May 2020 13:24:51 +0300

kiss-readlink: add 'readlink -f' replacement

Diffstat:
M.gitignore | 4++--
MMakefile | 19++++++++++++-------
Abin/kiss-readlink.c | 25+++++++++++++++++++++++++
Mkiss | 4++--
Mman/kiss-contrib.1 | 5+++++
5 files changed, 46 insertions(+), 11 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1 +1,2 @@ -kiss-stat- \ No newline at end of file +kiss-stat +kiss-readlink diff --git a/Makefile b/Makefile @@ -4,21 +4,25 @@ MANPREFIX = ${PREFIX}/share/man MAN1 = ${MANPREFIX}/man1 CC = cc -all: kiss-stat +all: kiss-stat kiss-readlink kiss-stat: ${CC} -o kiss-stat bin/kiss-stat.c +kiss-readlink: + ${CC} -o kiss-readlink bin/kiss-readlink.c + clean: - rm -f kiss-stat + rm -f kiss-stat kiss-readlink install: all mkdir -p ${DESTDIR}${BINDIR} - cp kiss ${DESTDIR}${BINDIR}/kiss - chmod 755 ${DESTDIR}${BINDIR}/kiss - cp kiss-stat ${DESTDIR}${BINDIR}/kiss-stat - chmod 755 ${DESTDIR}${BINDIR}/kiss-stat - for bin in contrib/* ; do cp $${bin} ${DESTDIR}${BINDIR}/$${bin##*/}; \ + cp kiss kiss-stat kiss-readlink ${DESTDIR}${BINDIR} + chmod 755 ${DESTDIR}${BINDIR}/kiss \ + ${DESTDIR}${BINDIR}/kiss-stat \ + ${DESTDIR}${BINDIR}/kiss-readlink + for bin in contrib/* ; do \ + cp $${bin} ${DESTDIR}${BINDIR}/$${bin##*/}; \ chmod 755 ${DESTDIR}${BINDIR}/$${bin##*/} ; done mkdir -p ${DESTDIR}${MAN1} @@ -29,6 +33,7 @@ install: all uninstall: rm -f ${DESTDIR}${BINDIR}/kiss rm -f ${DESTDIR}${BINDIR}/kiss-stat + rm -f ${DESTDIR}${BINDIR}/kiss-readlink for bin in contrib/* ; do rm -f ${DESTDIR}${BINDIR}/$${bin##*/} ; done rm -f ${DESTDIR}${MAN1}/kiss.1 ${DESTDIR}${MAN1}/kiss.1 rm -f ${DESTDIR}${MAN1}/kiss-contrib.1 ${DESTDIR}${MAN1}/kiss-contrib.1 diff --git a/bin/kiss-readlink.c b/bin/kiss-readlink.c @@ -0,0 +1,25 @@ +// kiss-readlink --- a utility replacement for readlink +// See LICENSE for copyright information + +// This is basically a 'readlink -f' command. +#include <stdio.h> +#include <stdlib.h> + +int main(int argc, char *argv[]) { + + char buf[512]; + + if (argc != 2) { + printf("usage: %s FILE\n", argv[0]); + return(1); + } + + if (!realpath(argv[1], buf)) { + perror("realpath:"); + return(1); + } + + // fputs(buf,stdout); + printf("%s\n", buf); + return(0); +} diff --git a/kiss b/kiss @@ -448,7 +448,7 @@ pkg_fixdeps() { # canonicalize the path. dep=${dep#* => } dep=${dep% *} - dep=$(readlink -f "$dep") + dep=$(kiss-readlink "$dep") # Figure out which package owns the file. own=$("$grep" -lFx "${dep#$KISS_ROOT}" "$@") @@ -746,7 +746,7 @@ pkg_conflicts() { case $file in */) continue; esac printf '%s/%s\n' \ - "$(readlink -f "$KISS_ROOT/${file%/*}" 2>/dev/null)" \ + "$(kiss-readlink "$KISS_ROOT/${file%/*}" 2>/dev/null)" \ "${file##*/}" done < "$tar_dir/$1/$pkg_db/$1/manifest" > "$cac_dir/$pid-m" diff --git a/man/kiss-contrib.1 b/man/kiss-contrib.1 @@ -122,6 +122,11 @@ can be used to check if personal packages are outdated. <file> Checks which package has installed the given file. +.SH KISS-READLINK +.B kiss-readlink +<file> + +A 'readlink -f' replacement to be used inside the package manager. .SH KISS-REPODEPENDS .B kiss-repodepends <pkg>