pantry/projects/rpm.org/popt/package.yml
2023-10-01 20:41:57 -04:00

66 lines
2.1 KiB
YAML

distributable:
url: http://ftp.rpm.org/popt/releases/popt-1.x/popt-{{ version.raw }}.tar.gz
strip-components: 1
versions:
github: rpm-software-management/popt/releases/tags
strip:
- /^popt-/
- /-release$/
build:
script: |
./configure --disable-debug --disable-dependency-tracking --prefix={{ prefix }}
make install
test:
script: |
mv $FIXTURE test.c
gcc test.c -lpopt -o test
test "$(./test -a 123 -b 456 -c 789 -f)" = "123::456::789::1::0"
test "$(./test --optiona=987 --optionb=654 --optionc=321 --flag2)" = "987::654::321::0::1"
fixture: |
#include <stdio.h>
#include <stdlib.h>
#include <popt.h>
int main(int argc, char *argv[]) {
int optiona=-1, optionb=-1, optionc=-1, flag1=0, flag2=0;
poptContext pc;
struct poptOption po[] = {
{"optiona", 'a', POPT_ARG_INT, &optiona, 11001, "descrip1", "argDescrip1"},
{"optionb", 'b', POPT_ARG_INT, &optionb, 11002, "descrip2", "argDescrip2"},
{"optionc", 'c', POPT_ARG_INT, &optionc, 11003, "descrip3", "argDescrip3"},
{"flag1", 'f', POPT_ARG_NONE, &flag1, 11004, "descrip4", "argDescrip4"},
{"flag2", 'g', POPT_ARG_NONE, &flag2, 11005, "descrip5", "argDescrip5"},
POPT_AUTOHELP
{NULL}
};
pc = poptGetContext(NULL, argc, (const char **)argv, po, 0);
poptSetOtherOptionHelp(pc, "[ARG...]");
if (argc < 2) {
poptPrintUsage(pc, stderr, 0);
exit(1);
}
int val;
while ((val = poptGetNextOpt(pc)) >= 0);
if (val != -1) {
switch(val) {
case POPT_ERROR_NOARG:
printf("Argument missing for an option\\n");
exit(1);
case POPT_ERROR_BADOPT:
printf("Option's argument could not be parsed\\n");
exit(1);
case POPT_ERROR_BADNUMBER:
case POPT_ERROR_OVERFLOW:
printf("Option could not be converted to number\\n");
exit(1);
default:
printf("Unknown error in option processing\\n");
exit(1);
}
}
printf("%d::%d::%d::%d::%d", optiona, optionb, optionc, flag1, flag2);
return 0;
}