diff --git a/deb-arm/Dockerfile b/deb-arm/Dockerfile index a49862e5d..0f1244580 100644 --- a/deb-arm/Dockerfile +++ b/deb-arm/Dockerfile @@ -119,6 +119,10 @@ RUN if [ "$DD_TARGET_ARCH" = "aarch64" ] ; then set -ex \ && /build-gcc.sh \ && rm /build-gcc.sh ; fi +# triehash +COPY ./triehash.pl /usr/local/bin/triehash +RUN chmod +x /usr/local/bin/triehash + # Entrypoint COPY ./entrypoint.sh / RUN chmod +x /entrypoint.sh diff --git a/deb-x64/Dockerfile b/deb-x64/Dockerfile index f20b0a02a..46782be95 100644 --- a/deb-x64/Dockerfile +++ b/deb-x64/Dockerfile @@ -195,6 +195,10 @@ RUN chmod +x /build-gcc.sh \ && /build-gcc.sh \ && rm /build-gcc.sh +# triehash +COPY ./triehash.pl /usr/local/bin/triehash +RUN chmod +x /usr/local/bin/triehash + # Entrypoint COPY ./entrypoint.sh / RUN chmod +x /entrypoint.sh diff --git a/rpm-arm64/Dockerfile b/rpm-arm64/Dockerfile index dac4f7790..24156934f 100644 --- a/rpm-arm64/Dockerfile +++ b/rpm-arm64/Dockerfile @@ -111,6 +111,10 @@ RUN chmod +x /build-gcc.sh \ && /build-gcc.sh \ && rm /build-gcc.sh +# triehash +COPY ./triehash.pl /usr/local/bin/triehash +RUN chmod +x /usr/local/bin/triehash + # Entrypoint COPY ./entrypoint.sh / RUN chmod +x /entrypoint.sh diff --git a/rpm-armhf/Dockerfile b/rpm-armhf/Dockerfile index 1dc82db13..e0b8f090b 100644 --- a/rpm-armhf/Dockerfile +++ b/rpm-armhf/Dockerfile @@ -100,6 +100,10 @@ RUN GIMME_ARCH=arm gimme $GIMME_GO_VERSION COPY ./gobin.sh /etc/profile.d/ +# triehash +COPY ./triehash.pl /usr/local/bin/triehash +RUN chmod +x /usr/local/bin/triehash + # Entrypoint COPY ./entrypoint.sh / RUN chmod +x /entrypoint.sh diff --git a/rpm-x64/Dockerfile b/rpm-x64/Dockerfile index 98641a619..f2e2dbce6 100644 --- a/rpm-x64/Dockerfile +++ b/rpm-x64/Dockerfile @@ -280,6 +280,9 @@ RUN chmod +x /build-gcc.sh \ && /build-gcc.sh \ && rm /build-gcc.sh +# triehash +COPY ./triehash.pl /usr/local/bin/triehash + # Entrypoint COPY ./entrypoint.sh / RUN chmod +x /entrypoint.sh diff --git a/suse-x64/Dockerfile b/suse-x64/Dockerfile index df963fc6f..ddf74fe0d 100644 --- a/suse-x64/Dockerfile +++ b/suse-x64/Dockerfile @@ -172,6 +172,11 @@ RUN curl -sL -o /tmp/rpm-4.14.3.tar.bz2 http://ftp.rpm.org/releases/rpm-4.14.x/r RUN mkdir -p /usr/local/var/lib/rpm \ && cp /var/lib/rpm/Packages /usr/local/var/lib/rpm/Packages \ && /usr/local/bin/rpm --rebuilddb + +# triehash +COPY ./triehash.pl /usr/local/bin/triehash +RUN chmod +x /usr/local/bin/triehash + # Entrypoint COPY ./entrypoint.sh / RUN chmod +x /entrypoint.sh diff --git a/triehash.pl b/triehash.pl new file mode 100755 index 000000000..1671dd72c --- /dev/null +++ b/triehash.pl @@ -0,0 +1,728 @@ +#!/usr/bin/env perl +# +# Copyright (C) 2016 Julian Andres Klode +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +=encoding utf8 + +=head1 NAME + +triehash - Generate a perfect hash function derived from a trie. + +=cut + +use strict; +use warnings; +use utf8; +use Getopt::Long; + +=head1 SYNOPSIS + +B [S>] [S>] + +=head1 DESCRIPTION + +triehash takes a list of words in input file and generates a function and +an enumeration to describe the word + +=head1 INPUT FILE FORMAT + +The file consists of multiple lines of the form: + + [label ~ ] word [= value] + +This maps word to value, and generates an enumeration with entries of the form: + + label = value + +If I