Git Product home page Git Product logo

Comments (3)

abeltrano avatar abeltrano commented on May 18, 2024

Please ensure the version is defined using semver format. It should also be easily checked in the code with pre-processor macros. Usually, having integral and string versions are useful. Eg. (something like below, not necessarily exactly this):

#define xstr(s) str(s)
#define str(s) #s

#define VERSION_BUILD(_major, _minor_, _build) ((_major << 24 | _minor << 16 | _build))
#define ZTP_LIB_VERSION_MAJOR 3
#define ZTP_LIB_VERSION_MINOR 11
#define ZTP_LIB_VERSION_PATCH 1

// Define numerical version for pre-process macro checks/comparisons
#define ZTP_LIB_VERSION_3_11_1 VERSION_BUILD(ZTP_LIB_VERSION_MAJOR, ZTP_LIB_VERSION_MINOR, ZTP_LIB_VERSION_PATCH)
#define ZTP_VERSION_CURRENT ZTP_LIB_VERSION_3_11_1

#define ZTP_VERSION_CURRENT_STR "v" xstr(ZTP_LIB_VERSION_MAJOR) "." xstr(ZTP_LIB_VERSION_MINOR) "." xtr(ZTP_LIB_VERSION_PATCH) 

#if ZTP_VERSION_CURRENT > ZTP_VERSION_3_11_1
// do version conditional-things
#endif

...
main(int argv, char *argv[]) {
   switch (optarg) {
   case 'v':
        printf("ztpd " ZTP_VERSION_CURRENT_STR);
        break;
   // ...
   }
}

from wifi-ztp.

forwardpointer avatar forwardpointer commented on May 18, 2024

A current workaround for this is to query the package manager:

rpm -qa | grep ztpd

from wifi-ztp.

abeltrano avatar abeltrano commented on May 18, 2024

A current workaround for this is to query the package manager:

rpm -qa | grep ztpd

This works ok for rpm-based distros, but won't work for .deb-based distros (Debian, Ubuntu). For the former, consider using rpm query tags to extract very specific versioning information. Also, instead of grepping the output, you should instead specify the package name explicitly, rpm -qa ztpd. Be careful as well, since if multiple versions are installed, you need to take care to format/filter/select the expected output. It's not trivial to list the "latest"/"newest" version installed.

from wifi-ztp.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.