Skip to content

Commit

Permalink
Dockerfile[bullseye]: install 3rdparty dependencys
Browse files Browse the repository at this point in the history
  • Loading branch information
sidey79 committed Feb 18, 2024
1 parent 31614ab commit ba16455
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 37 deletions.
79 changes: 61 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,57 @@ on:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
get_dependencies:
runs-on: ubuntu-latest
steps:
- name: Checkout this repository
uses: actions/checkout@v4

- name: Prepare SVN repository checkout and variables
id: prepareSVN
uses: ./.github/workflows/prepare-svn

- uses: shogo82148/actions-setup-perl@v1
with:
perl-version: "5.38"
install-modules-with: cpanm
install-modules-args: --notest
install-modules: PPI Perl::PrereqScanner::NotQuiteLite File::Find::Rule List::MoreUtils

- name: create cpanfile from FHEM 3rdparty repositories at github
run: |
mapfile -t REPO_URLS < <( scripts/get-FHEMRepositorys.sh | awk '{print $4}' && printf '\0' )
mkdir ./3rdparty
cd ./3rdparty
for url in "${REPO_URLS[@]}"; do
[[ -z $url ]] && continue
echo "$url: $(basename $(dirname $url))/$(basename $url)";
git clone "$url" "$(basename $(dirname $url))/$(basename $url)";
done
cd ..
FHEM_MODULES=$(perl scripts/get-Packages.pl ./3rdparty)
scan-perl-prereqs-nqlite -save_cpanfile -suggests -private_re "^(Win32::|YAF|OW|RTypes|RRDs|SetExtensions|HttpUtils|UPnP::ControlPoint|FritzBoxUtils|configDB|RESIDENTStk|SHC_datafields|TcpServerUtils|Blocking|uConv|ZWLib|UpNp:Common|HttpUtils|Unit|GD|DevIo|AttrTemplate|ProtoThreads|$FHEM_MODULES)" ./3rdparty
- uses: actions/upload-artifact@v4
with:
name: cpanfile-3rdParty
path: cpanfile
overwrite: true

- name: create cpanfile from FHEM dependencies
run: |
FHEM_MODULES=$(perl scripts/get-Packages.pl ./src/fhem/trunk)
scan-perl-prereqs-nqlite -save_cpanfile -suggests -private_re "^(Win32::|YAF|OW|RTypes|RRDs|SetExtensions|HttpUtils|UPnP::ControlPoint|FritzBoxUtils|configDB|RESIDENTStk|SHC_datafields|TcpServerUtils|Blocking|uConv|ZWLib|UpNp:Common|HttpUtils|Unit|GD|DevIo|AttrTemplate|ProtoThreads|$FHEM_MODULES)" ./src/fhem/trunk
- uses: actions/upload-artifact@v4
with:
name: cpanfile-FHEM
path: cpanfile
overwrite: true

test_build:
# The type of runner that the job will run on
needs: get_dependencies
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -44,30 +92,20 @@ jobs:
shell: bash
run: |
echo "IMAGE_VERSION=$( git describe --tags --dirty --match "v[0-9]*")" >> $GITHUB_OUTPUT
id: gitVars

- name: Prepare SVN repository checkout and variables
id: prepareSVN
uses: ./.github/workflows/prepare-svn

- uses: shogo82148/actions-setup-perl@v1
with:
perl-version: "5.38"
install-modules-with: cpanm
install-modules-args: --notest
install-modules: PPI Perl::PrereqScanner::NotQuiteLite File::Find::Rule List::MoreUtils

- name: create cpanfile from FHEM dependencies
run: |
FHEM_MODULES=$(perl scripts/get-Packages.pl ./src/fhem/trunk)
scan-perl-prereqs-nqlite -save_cpanfile -suggests -private_re "^(Win32::|YAF|OW|RTypes|RRDs|SetExtensions|HttpUtils|UPnP::ControlPoint|FritzBoxUtils|configDB|RESIDENTStk|SHC_datafields|TcpServerUtils|Blocking|uConv|ZWLib|UpNp:Common|HttpUtils|Unit|GD|DevIo|AttrTemplate|ProtoThreads|$FHEM_MODULES)" ./src/fhem/trunk
- uses: actions/upload-artifact@v4
- uses: actions/download-artifact@v4
with:
name: cpanfile-FHEM
path: cpanfile
overwrite: true

- uses: actions/download-artifact@v4
with:
name: cpanfile-3rdParty
path: 3rdParty

- name: Prepare docker for build and publish
id: prepareDOCKER
Expand Down Expand Up @@ -175,7 +213,12 @@ jobs:
- uses: actions/download-artifact@v4
with:
name: cpanfile-FHEM


- uses: actions/download-artifact@v4
with:
name: cpanfile-3rdParty
path: 3rdParty

- name: Prepare docker for build and publish
id: prepareDOCKER
uses: ./.github/workflows/prepare-docker
Expand Down
18 changes: 16 additions & 2 deletions Dockerfile-bullseye
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ RUN sed -i "s/bullseye main/bullseye main contrib non-free/g" /etc/apt/sources.l
&& LC_ALL=C apt-get autoremove -qqy && LC_ALL=C apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* ~/.[^.] ~/.??* ~/*

# Install all CPAN Modules, needed from FHEM and standard modules
# Install all CPAN Modules, needed from FHEM and standard modules
COPY cpanfile /root/cpanfile
# Fixup modules which do not work on all platforms and install afterwards
# Fixup modules which do not work on all platforms and install afterwards
RUN <<EOF
if [ "${TARGETPLATFORM}" != "linux/amd64" ] && [ "${TARGETPLATFORM}" != "linux/i386" ]; then
sed -i '/Device::SerialPort/d' ./cpanfile > /root/cpanfile
Expand All @@ -95,6 +95,20 @@ RUN <<EOF
rm -rf /root/.cpanm
EOF

# Install all CPAN Modules, needed from 3rd party module repositorys
COPY 3rdParty/cpanfile /root/cpanfile_3rdparty
# Fixup modules which do not work on all platforms and install afterwards
RUN <<EOF
if [ "${TARGETPLATFORM}" != "linux/amd64" ] && [ "${TARGETPLATFORM}" != "linux/i386" ]; then
sed -i '/Device::SerialPort/d' ./cpanfile > /root/cpanfile_3rdparty
sed -i '/Device::Firmata::Constants/d' ./cpanfile > /root/cpanfile_3rdparty
fi

cpanm --notest --cpanfile /root/cpanfile_3rdparty --installdeps --with-suggests .
rm -rf /root/.cpanm
EOF


# Add some more Additional CPAN Modules
RUN LC_ALL=C DEBIAN_FRONTEND=noninteractive \
cpanm --notest \
Expand Down
23 changes: 23 additions & 0 deletions scripts/get-FHEMRepositorys.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

# GitHub API-URL für die Suche nach FHEM-Repositorys
BASE_URL="https://api.github.com/search/repositories"
TAG="FHEM"

# Anzahl der Ergebnisse, die du anzeigen möchtest
PER_PAGE=2000

# API-Anfrage an GitHub
response=$(curl -s "$BASE_URL?q=$TAG+language:Perl&sort=stars&order=desc&per_page=$PER_PAGE")

# Verarbeite die Antwort
if [[ $response == *"items"* ]]; then
while IFS= read -r repo; do
repo_name=$(echo "$repo" | jq -r '.name')
repo_url=$(echo "$repo" | jq -r '.html_url')
#stars=$(echo "$repo" | jq -r '.stargazers_count')
[[ ! $repo_name =~ (mirror|docker) ]] && echo "Repository: $repo_name - $repo_url"
done <<< "$(echo "$response" | jq -c '.items[]')"
else
echo "Keine Repositorys gefunden."
fi
38 changes: 21 additions & 17 deletions scripts/get-Packages.pl
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,39 @@
use Data::Dumper;


my $directory = shift; # Pfad als Argument übergeben
my @directories = @ARGV;

# Alle Perl-Moduldateien im Verzeichnisbaum finden
my @files = File::Find::Rule->file()->name('*.pm')->in($directory);

my %seen; # Hash, um Duplikate zu verfolgen
my @unique_package_names;

foreach my $file (@files) {
my $document = PPI::Document->new($file);

# Alle package-Anweisungen in der Datei finden
my $package_statements = $document->find('PPI::Statement::Package');
# Alle Perl-Moduldateien im Verzeichnisbaum finden
foreach my $directory (@directories) {

my @files = File::Find::Rule->file()->name('*.pm')->in($directory);

# Nur Dateien mit mindestens einer package-Anweisung verarbeiten
next unless $package_statements;
foreach my $file (@files) {

foreach my $package_statement (@$package_statements) {
my $package_name = $package_statement->namespace;
my $document = PPI::Document->new($file);
next unless $document;
# Alle package-Anweisungen in der Datei finden
my $package_statements = $document->find('PPI::Statement::Package');

next if $seen{$package_name};
$seen{$package_name} = 1;
# Nur Dateien mit mindestens einer package-Anweisung verarbeiten
next unless $package_statements;

push @unique_package_names, $package_name;
foreach my $package_statement (@$package_statements) {
my $package_name = $package_statement->namespace;

# print "Paketname: $package_name\n";
next if $seen{$package_name};
$seen{$package_name} = 1;

push @unique_package_names, $package_name;

# print "Paketname: $package_name\n";
}
}
}

# Paketnamen mit | getrennt ausgeben
my $package_string = join '|', @unique_package_names;
print "Eindeutige Paketnamen: $package_string\n";
Expand Down

0 comments on commit ba16455

Please sign in to comment.