sysutils/filevercmp: Compare version strings as in sort --version-sort

Approved by:    jrm (mentor)
Differential Revision:  https://reviews.freebsd.org/D15098
This commit is contained in:
Jason W. Bacon
2018-04-16 16:21:31 +00:00
parent 54e83cc506
commit 8ec045d8ae
5 changed files with 92 additions and 0 deletions
+1
View File
@@ -323,6 +323,7 @@
SUBDIR += fileprune
SUBDIR += fileschanged
SUBDIR += filetype
SUBDIR += filevercmp
SUBDIR += filewatcherd
SUBDIR += finfo
SUBDIR += firstboot-freebsd-update
+20
View File
@@ -0,0 +1,20 @@
# $FreeBSD$
PORTNAME= filevercmp
DISTVERSION= g20151117
CATEGORIES= sysutils
MAINTAINER= jwb@FreeBSD.org
COMMENT= Compare version strings as in sort --version-sort
LICENSE= GPLv3
USE_GITHUB= yes
GH_ACCOUNT= ekg
GH_TAGNAME= cccb6ba1fffa2898718b0a96c63279e0979e002b
MAKEFILE= ${FILESDIR}/Makefile
INSTALL_TARGET= install-strip
PLIST_FILES= bin/filevercmp include/filevercmp.h lib/libfilevercmp.a
.include <bsd.port.mk>
+3
View File
@@ -0,0 +1,3 @@
TIMESTAMP = 1523600860
SHA256 (ekg-filevercmp-g20151117-cccb6ba1fffa2898718b0a96c63279e0979e002b_GH0.tar.gz) = de0b23cd95bb121a6ec774cdbd54e1fbabe4e1cc00211997d7ecc2b5a9d102c5
SIZE (ekg-filevercmp-g20151117-cccb6ba1fffa2898718b0a96c63279e0979e002b_GH0.tar.gz) = 3105
+52
View File
@@ -0,0 +1,52 @@
# Use ?= to allow overriding from the env or command-line, e.g.
#
# make CXXFLAGS="-O3 -fPIC" install
#
# Package managers will override many of these variables automatically, so
# this is aimed at making it easy to create packages (Debian packages,
# FreeBSD ports, MacPorts, pkgsrc, etc.)
CC ?= cc
CFLAGS ?= -O -g
AR ?= ar
MKDIR ?= mkdir
INSTALL ?= install -c
STRIP ?= strip
DESTDIR ?= stage
PREFIX ?= /usr/local
OBJS= filevercmp.o
MAIN = main.o
BIN = filevercmp
LIB = libfilevercmp.a
all: ${BIN} ${LIB}
${BIN}: ${OBJS} ${MAIN}
${CC} ${CFLAGS} -o ${BIN} ${OBJS} ${MAIN}
${LIB}: ${OBJS}
${AR} -rs ${LIB} ${OBJS}
install: all
${MKDIR} -p ${DESTDIR}${PREFIX}/bin
${MKDIR} -p ${DESTDIR}${PREFIX}/include
${MKDIR} -p ${DESTDIR}${PREFIX}/lib
${INSTALL} ${BIN} ${DESTDIR}${PREFIX}/bin
${INSTALL} *.h ${DESTDIR}${PREFIX}/include
${INSTALL} ${LIB} ${DESTDIR}${PREFIX}/lib
install-strip: install
${STRIP} ${DESTDIR}${PREFIX}/bin/${BIN}
clean:
rm -rf ${BIN} ${LIB} ${OBJS} ${MAIN} ${DESTDIR}
.PHONY: all clean
filevercmp.o: filevercmp.c filevercmp.h
${CC} ${CFLAGS} -c filevercmp.c
main.o: main.c filevercmp.h
${CC} ${CFLAGS} -c main.c
+16
View File
@@ -0,0 +1,16 @@
Compare version strings:
This function compares strings S1 and S2:
By PREFIX in the same way as strcmp.
Then by VERSION (most similarly to version compare of Debian's dpkg).
Leading zeros in version numbers are ignored.
If both (PREFIX and VERSION) are equal, strcmp function is used for
comparison. So this function can return 0 if (and only if) strings S1 and
S2 are identical.
It returns number >0 for S1 > S2, 0 for S1 == S2 and number <0 for S1 < S2.
WWW: https://github.com/ekg/filevercmp