POSIX sh version of mkversion

Most targeted platforms have "sh" and don't need Perl as requirement.
Still Perl script is present as fallback.
This commit is contained in:
Philippe Teuwen 2019-08-29 20:58:36 +02:00
commit 8987e956ac
8 changed files with 67 additions and 6 deletions

View file

@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file.
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log... This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
## [unreleased][unreleased] ## [unreleased][unreleased]
- Chg posix sh version of mkversion (@doegox)
- Chg remove entirely ncurses, not needed nowadays (@doegox) - Chg remove entirely ncurses, not needed nowadays (@doegox)
- Chg remove deprecated termcap, use ncurses instead (@ZeroChaos-) - Chg remove deprecated termcap, use ncurses instead (@ZeroChaos-)
- Chg 'hf iclass encrypt' - now takes transport key as param. (@iceman1001) - Chg 'hf iclass encrypt' - now takes transport key as param. (@iceman1001)

View file

@ -144,7 +144,7 @@ all: $(OBJS)
# version.c should be remade on every time fullimage.stage1.elf should be remade # version.c should be remade on every time fullimage.stage1.elf should be remade
version.c: default_version.c $(OBJDIR)/fpga_version_info.o $(OBJDIR)/fpga_all.o $(THUMBOBJ) $(ARMOBJ) version.c: default_version.c $(OBJDIR)/fpga_version_info.o $(OBJDIR)/fpga_all.o $(THUMBOBJ) $(ARMOBJ)
$(info [-] GEN $@) $(info [-] GEN $@)
$(Q)perl ../tools/mkversion.pl .. > $@ || $(COPY) $^ $@ $(Q)sh ../tools/mkversion.sh > $@ || perl ../tools/mkversion.pl > $@ || $(COPY) $^ $@
fpga_version_info.c: $(FPGA_BITSTREAMS) | $(FPGA_COMPRESSOR) fpga_version_info.c: $(FPGA_BITSTREAMS) | $(FPGA_COMPRESSOR)
$(info [-] GEN $@) $(info [-] GEN $@)

View file

@ -36,7 +36,7 @@ OBJS = $(OBJDIR)/bootrom.s19
# version.c should be remade on every compilation # version.c should be remade on every compilation
version.c: default_version.c version.c: default_version.c
$(info [=] GEN $@) $(info [=] GEN $@)
$(Q)perl ../tools/mkversion.pl .. > $@ || $(COPY) $^ $@ $(Q)sh ../tools/mkversion.sh > $@ || perl ../tools/mkversion.pl > $@ || $(COPY) $^ $@
all: $(OBJS) all: $(OBJS)

View file

@ -1,5 +1,5 @@
#include "proxmark3_arm.h" #include "proxmark3_arm.h"
/* This is the default version.c file that Makefile.common falls back to if perl is not available */ /* This is the default version.c file that Makefile.common falls back to if neither sh nor perl are available */
const struct version_information __attribute__((section(".version_information"))) version_information = { const struct version_information __attribute__((section(".version_information"))) version_information = {
VERSION_INFORMATION_MAGIC, VERSION_INFORMATION_MAGIC,
1, /* version 1 */ 1, /* version 1 */

View file

@ -25,7 +25,7 @@ Install the requirements
```sh ```sh
sudo apt-get install p7zip git ca-certificates build-essential libreadline5 libreadline-dev \ sudo apt-get install p7zip git ca-certificates build-essential libreadline5 libreadline-dev \
libusb-0.1-4 libusb-dev perl pkg-config wget gcc-arm-none-eabi libnewlib-dev libqt4-dev libusb-0.1-4 libusb-dev pkg-config wget gcc-arm-none-eabi libnewlib-dev libqt4-dev
``` ```
If you don't need the graphical components of the Proxmark3 client, you can skip the installation of `libqt4-dev`. If you don't need the graphical components of the Proxmark3 client, you can skip the installation of `libqt4-dev`.

View file

@ -66,7 +66,7 @@ These instructions will show how to setup the environment on OSX to the point wh
2. Install dependencies: 2. Install dependencies:
``` ```
brew install readline p7zip libusb-compat perl qt5 wget pkgconfig brew install readline p7zip libusb-compat qt5 wget pkgconfig
brew install RfidResearchGroup/proxmark3/arm-none-eabi-gcc brew install RfidResearchGroup/proxmark3/arm-none-eabi-gcc
``` ```

View file

@ -99,7 +99,7 @@ Enter WSL prompt (`wsl`) and from there, follow the [Linux Installation Instruct
```sh ```sh
sudo apt-get update sudo apt-get update
sudo apt-get install p7zip git ca-certificates build-essential libreadline5 libreadline-dev libusb-0.1-4 \ sudo apt-get install p7zip git ca-certificates build-essential libreadline5 libreadline-dev libusb-0.1-4 \
libusb-dev perl pkg-config wget gcc-arm-none-eabi libstdc++-arm-none-eabi-newlib \ libusb-dev pkg-config wget gcc-arm-none-eabi libstdc++-arm-none-eabi-newlib \
libqt4-dev libqt4-dev
``` ```

60
tools/mkversion.sh Executable file
View file

@ -0,0 +1,60 @@
#!/bin/sh
# Output a version.c file that includes information about the current build
# From mkversion.pl
# pure sh POSIX as now even on Windows we use WSL or ProxSpace with sh available
# Clear environment locale so that git will not use localized strings
export LC_ALL="C"
export LANG="C"
# if you are making your own fork, change this line to reflect your fork-name
fullgitinfo="RRG/Iceman"
# GIT status 0 = dirty, 1 = clean , 2 = undecided
clean=2
# Do we have acces to git command?
commandGIT=$(env which git)
if [ "$commandGIT" != "" ]; then
# now avoiding the "fatal: No names found, cannot describe anything." error by fallbacking to abbrev hash in such case
gitversion=$(git describe --dirty --always)
gitbranch=$(git rev-parse --abbrev-ref HEAD)
if [ "$gitversion" != "${gitversion%-dirty}" ]; then
clean=0
else
clean=1
fi
if [ "$gitbranch" != "" ] && [ "$gitversion" != "" ]; then
fullgitinfo="${fullgitinfo}/${gitbranch}/${gitversion}"
ctime="$(date '+%Y-%m-%d %H:%M:%S')"
else
fullgitinfo="${fullgitinfo}/master/release (git)"
fi
else
fullgitinfo="${fullgitinfo}/master/release (no_git)"
dl_time=$(stat --printf="%y" ../README.md)
# POSIX way...
ctime=${dl_time%.*}
fi
# Crop so it fits within 50 characters C string, so max 49 chars
# POSIX way
fullgitinfoextra="${fullgitinfo#??????????????????????????????????????????????}"
if [ "$fullgitinfoextra" != "$fullgitinfo" ]; then
fullgitinfo46="${fullgitinfo%"${fullgitinfoextra}"}"
fullgitinfo="${fullgitinfo46}..."
fi
cat <<EOF
#include "proxmark3_arm.h"
/* Generated file, do not edit */
const struct version_information __attribute__((section(".version_information"))) version_information = {
VERSION_INFORMATION_MAGIC,
1,
1,
$clean,
"$fullgitinfo",
"$ctime",
};
EOF