chore(gitlab-ci): query nodejs roots in nix store if nix store delete fails,...
This commit is contained in:
parent
b190e25c88
commit
0d46802862
207
.gitlab-ci.yml
207
.gitlab-ci.yml
@ -1,4 +1,4 @@
|
||||
# SPDX-FileCopyrightText: 2022-2023 Sarah Vaupel <sarah.vaupel@uniworx.de>, Gregor Kleen <gregor@kleen.consulting>
|
||||
# SPDX-FileCopyrightText: 2022-2024 Sarah Vaupel <sarah.vaupel@uniworx.de>, Gregor Kleen <gregor@kleen.consulting>
|
||||
#
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
@ -35,6 +35,7 @@ node dependencies:
|
||||
stage: frontend:build
|
||||
script:
|
||||
- nix -L build -o result ".#uniworxNodeDependencies"
|
||||
- nix-store --gc
|
||||
- nix-store --export $(nix-store -qR result) | xz -T0 -2 > node-dependencies.nar.xz
|
||||
before_script: &nix-before
|
||||
- git config --global init.defaultBranch master
|
||||
@ -54,8 +55,12 @@ node dependencies:
|
||||
well known:
|
||||
stage: frontend:build
|
||||
script:
|
||||
# - xzcat node-dependencies.nar.xz > node-dependencies-debug.nar
|
||||
# - nix-shell -p util-linux --command "hexdump -C node-dependencies-debug.nar | head -n 10"
|
||||
# - nix nar ls node-dependencies-debug.nar /
|
||||
- xzcat node-dependencies.nar.xz | nix-store --import
|
||||
- nix -L build -o result ".#uniworxWellKnown"
|
||||
- nix-store --gc
|
||||
- nix-store --export $(nix-store -qR result) | xz -T0 -2 > well-known.nar.xz
|
||||
before_script: *nix-before
|
||||
needs:
|
||||
@ -75,6 +80,7 @@ frontend:
|
||||
- xzcat node-dependencies.nar.xz | nix-store --import
|
||||
- xzcat well-known.nar.xz | nix-store --import
|
||||
- nix -L build -o result ".#uniworxFrontend"
|
||||
- nix-store --gc
|
||||
- nix-store --export $(nix-store -qR result) | xz -T0 -2 > frontend.nar.xz
|
||||
before_script: *nix-before
|
||||
needs:
|
||||
@ -95,6 +101,7 @@ uniworx:lib:uniworx:
|
||||
script:
|
||||
- xzcat frontend.nar.xz | nix-store --import
|
||||
- nix -L build -o result ".#uniworx:lib:uniworx"
|
||||
- nix-store --gc
|
||||
- nix-store --export $(nix-store -qR result) | xz -T0 -2 > uniworx:lib:uniworx.nar.xz
|
||||
before_script: *nix-before
|
||||
needs:
|
||||
@ -117,6 +124,7 @@ uniworx:exe:uniworx:
|
||||
script:
|
||||
- xzcat uniworx:lib:uniworx.nar.xz | nix-store --import
|
||||
- nix -L build -o result ".#uniworx:exe:uniworx"
|
||||
- nix-store --gc
|
||||
- nix-store --export $(nix-store -qR result) | xz -T0 -2 > uniworx:exe:uniworx.nar.xz
|
||||
before_script: *nix-before
|
||||
needs:
|
||||
@ -141,6 +149,7 @@ uniworx:exe:uniworxdb:
|
||||
script:
|
||||
- xzcat uniworx:lib:uniworx.nar.xz | nix-store --import
|
||||
- nix -L build -o result ".#uniworx:exe:uniworxdb"
|
||||
- nix-store --gc
|
||||
- nix-store --export $(nix-store -qR result) | xz -T0 -2 > uniworx:exe:uniworxdb.nar.xz
|
||||
before_script: *nix-before
|
||||
needs:
|
||||
@ -165,6 +174,7 @@ uniworx:exe:uniworxload:
|
||||
script:
|
||||
- xzcat uniworx:lib:uniworx.nar.xz | nix-store --import
|
||||
- nix -L build -o result ".#uniworx:exe:uniworxload"
|
||||
- nix-store --gc
|
||||
- nix-store --export $(nix-store -qR result) | xz -T0 -2 > uniworx:exe:uniworxload.nar.xz
|
||||
before_script: *nix-before
|
||||
needs:
|
||||
@ -207,8 +217,13 @@ container:
|
||||
stage: container:build
|
||||
script:
|
||||
- xzcat uniworx:exe:uniworx.nar.xz | nix-store --import
|
||||
- cp -pr --reflink=auto -L $(nix build --print-out-paths ".#uniworxDocker") uniworx.tar.gz
|
||||
# - &container-remove-nodejs
|
||||
# "for i in `ls /nix/store/ | grep -E -i '^[a-z0-9]+-nodejs-'` ; do ( nix store delete --ignore-liveness \"/nix/store/$i\" || ( echo \"Could not remove NodeJS from /nix/store/ due to: \" && ( nix-store --query --roots \"/nix/store/$i\" | cat ) && echo \"Removing NodeJS by brute force...\" && rm -rf \"/nix/store/$i\" ) ) ; done"
|
||||
- cp -p --reflink=auto -L $(nix build --print-out-paths ".#uniworxDocker") uniworx.tar.gz
|
||||
before_script: *nix-before
|
||||
# TODO: reintroduce working version of after_script
|
||||
# after_script: &container-fail-on-nodejs
|
||||
# - (ls /nix/store/ | grep -E -i '^[a-z0-9]+-nodejs-') && (echo "NodeJS remainder in container /nix/store!" 1>&2; exit 1)
|
||||
needs:
|
||||
- job: node dependencies # transitive
|
||||
artifacts: false
|
||||
@ -235,8 +250,10 @@ test container:
|
||||
stage: container:build
|
||||
script:
|
||||
- xzcat uniworx:exe:uniworx.nar.xz | nix-store --import
|
||||
- cp -pr --reflink=auto -L $(nix build --print-out-paths ".#uniworxTestDocker") uniworx.tar.gz
|
||||
# - *container-remove-nodejs
|
||||
- cp -p --reflink=auto -L $(nix build --print-out-paths ".#uniworxTestDocker") uniworx.tar.gz
|
||||
before_script: *nix-before
|
||||
# after_script: *container-fail-on-nodejs
|
||||
needs:
|
||||
- job: node dependencies # transitive
|
||||
artifacts: false
|
||||
@ -259,6 +276,128 @@ test container:
|
||||
interruptible: true
|
||||
rules: &test-release-rules
|
||||
- if: $CI_COMMIT_TAG =~ /^t/
|
||||
dev container:
|
||||
stage: container:build
|
||||
script:
|
||||
- xzcat uniworx:exe:uniworx.nar.xz | nix-store --import
|
||||
- cp -p --reflink=auto -L $(nix build --print-out-paths ".#uniworxDevDocker") uniworx.tar.gz
|
||||
before_script: *nix-before
|
||||
needs:
|
||||
- job: node dependencies # transitive
|
||||
artifacts: false
|
||||
- job: well known # transitive
|
||||
artifacts: false
|
||||
- job: frontend # tranitive
|
||||
artifacts: false
|
||||
- job: uniworx:lib:uniworx # transitive
|
||||
artifacts: false
|
||||
- job: uniworx:exe:uniworx
|
||||
artifacts: true
|
||||
- job: check # sanity
|
||||
artifacts: false
|
||||
artifacts:
|
||||
paths:
|
||||
- uniworx.tar.gz
|
||||
name: "${CI_JOB_NAME}-${CI_COMMIT_SHORT_SHA}"
|
||||
expire_in: "1 day"
|
||||
retry: 2
|
||||
interruptible: true
|
||||
rules: &dev-release-rules
|
||||
- if: $CI_COMMIT_TAG =~ /^d/
|
||||
|
||||
sanitize container:
|
||||
stage: container:build
|
||||
needs:
|
||||
- job: node dependencies # transitive
|
||||
artifacts: false
|
||||
- job: well known # transitive
|
||||
artifacts: false
|
||||
- job: frontend # transitive
|
||||
artifacts: false
|
||||
- job: uniworx:lib:uniworx # transitive
|
||||
artifacts: false
|
||||
- job: uniworx:exe:uniworx # transitive
|
||||
artifacts: false
|
||||
- job: check # sanity
|
||||
artifacts: false
|
||||
- job: container
|
||||
artifacts: true
|
||||
before_script: *nix-before
|
||||
script:
|
||||
- nix shell nixpkgs#perl --command ./.gitlab-ci/sanitize-docker.pl
|
||||
after_script:
|
||||
- tar xzvf uniworx-sanitized.tar.gz
|
||||
- for i in `tar tf */layer.tar | grep 'nix/store/[0-9a-z]*-nodejs'`; do echo "NodeJS remainer found in /nix/store!"; echo "$i"; exit 1; done
|
||||
artifacts:
|
||||
paths:
|
||||
- uniworx-sanitized.tar.gz
|
||||
name: "${CI_JOB_NAME}-${CI_COMMIT_SHORT_SHA}"
|
||||
expire_in: "1 day"
|
||||
retry: 2
|
||||
interruptible: true
|
||||
rules: *release-rules
|
||||
sanitize test container:
|
||||
stage: container:build
|
||||
needs:
|
||||
- job: node dependencies # transitive
|
||||
artifacts: false
|
||||
- job: well known # transitive
|
||||
artifacts: false
|
||||
- job: frontend # transitive
|
||||
artifacts: false
|
||||
- job: uniworx:lib:uniworx # transitive
|
||||
artifacts: false
|
||||
- job: uniworx:exe:uniworx # transitive
|
||||
artifacts: false
|
||||
- job: check # sanity
|
||||
artifacts: false
|
||||
- job: test container
|
||||
artifacts: true
|
||||
before_script: *nix-before
|
||||
script:
|
||||
- nix shell nixpkgs#perl --command ./.gitlab-ci/sanitize-docker.pl
|
||||
after_script:
|
||||
- tar xzvf uniworx-sanitized.tar.gz
|
||||
- for i in `tar tf */layer.tar | grep 'nix/store/[0-9a-z]*-nodejs'`; do echo "NodeJS remainer found in /nix/store!"; echo "$i"; exit 1; done
|
||||
artifacts:
|
||||
paths:
|
||||
- uniworx-sanitized.tar.gz
|
||||
name: "${CI_JOB_NAME}-${CI_COMMIT_SHORT_SHA}"
|
||||
expire_in: "1 day"
|
||||
retry: 2
|
||||
interruptible: true
|
||||
rules: *test-release-rules
|
||||
sanitize dev container:
|
||||
stage: container:build
|
||||
needs:
|
||||
- job: node dependencies # transitive
|
||||
artifacts: false
|
||||
- job: well known # transitive
|
||||
artifacts: false
|
||||
- job: frontend # transitive
|
||||
artifacts: false
|
||||
- job: uniworx:lib:uniworx # transitive
|
||||
artifacts: false
|
||||
- job: uniworx:exe:uniworx # transitive
|
||||
artifacts: false
|
||||
- job: check # sanity
|
||||
artifacts: false
|
||||
- job: dev container
|
||||
artifacts: true
|
||||
before_script: *nix-before
|
||||
script:
|
||||
- nix shell nixpkgs#perl --command ./.gitlab-ci/sanitize-docker.pl
|
||||
after_script:
|
||||
- tar xzvf uniworx-sanitized.tar.gz
|
||||
- for i in `tar tf */layer.tar | grep 'nix/store/[0-9a-z]*-nodejs'`; do echo "NodeJS remainer found in /nix/store!"; echo "$i"; exit 1; done
|
||||
artifacts:
|
||||
paths:
|
||||
- uniworx-sanitized.tar.gz
|
||||
name: "${CI_JOB_NAME}-${CI_COMMIT_SHORT_SHA}"
|
||||
expire_in: "1 day"
|
||||
retry: 2
|
||||
interruptible: true
|
||||
rules: *dev-release-rules
|
||||
|
||||
parse changelog:
|
||||
stage: prepare release
|
||||
@ -311,25 +450,27 @@ upload container:
|
||||
stage: release
|
||||
image: quay.io/skopeo/stable:latest
|
||||
script:
|
||||
- skopeo --insecure-policy copy --dest-creds "${CI_REGISTRY_USER}:${CI_JOB_TOKEN}" docker-archive://$(pwd)/uniworx.tar.gz docker://${CI_REGISTRY_IMAGE}:${VERSION}
|
||||
- skopeo --insecure-policy copy --dest-creds "${CI_REGISTRY_USER}:${CI_JOB_TOKEN}" docker-archive://$(pwd)/uniworx-sanitized.tar.gz docker://${CI_REGISTRY_IMAGE}:${VERSION}
|
||||
- skopeo --insecure-policy copy --src-creds "${CI_REGISTRY_USER}:${CI_JOB_TOKEN}" --dest-creds "${CI_REGISTRY_USER}:${CI_JOB_TOKEN}" docker://${CI_REGISTRY_IMAGE}:${VERSION} docker://${CI_REGISTRY_IMAGE}:latest
|
||||
needs:
|
||||
- job: node dependencies # transitive
|
||||
artifacts: false
|
||||
- job: well known # transitive
|
||||
artifacts: false
|
||||
- job: frontend # tranitive
|
||||
- job: frontend # transitive
|
||||
artifacts: false
|
||||
- job: uniworx:lib:uniworx # transitive
|
||||
artifacts: false
|
||||
- job: uniworx:exe:uniworx # transitive
|
||||
artifacts: false
|
||||
- job: container
|
||||
artifacts: true
|
||||
- job: container # transitive
|
||||
artifacts: false
|
||||
- job: parse changelog
|
||||
artifacts: true
|
||||
- job: check # sanity
|
||||
artifacts: false
|
||||
- job: sanitize container
|
||||
artifacts: true
|
||||
rules: *release-rules
|
||||
retry: 2
|
||||
upload test container:
|
||||
@ -338,27 +479,56 @@ upload test container:
|
||||
stage: release
|
||||
image: quay.io/skopeo/stable:latest
|
||||
script:
|
||||
- skopeo --insecure-policy copy --dest-creds "${CI_REGISTRY_USER}:${CI_JOB_TOKEN}" docker-archive://$(pwd)/uniworx.tar.gz docker://${CI_REGISTRY}/fradrive/fradrive/test:${CI_COMMIT_REF_NAME}
|
||||
- skopeo --insecure-policy copy --dest-creds "${CI_REGISTRY_USER}:${CI_JOB_TOKEN}" docker-archive://$(pwd)/uniworx-sanitized.tar.gz docker://${CI_REGISTRY}/fradrive/fradrive/test:${CI_COMMIT_REF_NAME}
|
||||
- skopeo --insecure-policy copy --src-creds "${CI_REGISTRY_USER}:${CI_JOB_TOKEN}" --dest-creds "${CI_REGISTRY_USER}:${CI_JOB_TOKEN}" docker://${CI_REGISTRY}/fradrive/fradrive/test:${CI_COMMIT_REF_NAME} docker://${CI_REGISTRY}/fradrive/fradrive/test:latest
|
||||
needs:
|
||||
- job: node dependencies # transitive
|
||||
artifacts: false
|
||||
- job: well known # transitive
|
||||
artifacts: false
|
||||
- job: frontend # tranitive
|
||||
- job: frontend # transitive
|
||||
artifacts: false
|
||||
- job: uniworx:lib:uniworx # transitive
|
||||
artifacts: false
|
||||
- job: uniworx:exe:uniworx # transitive
|
||||
artifacts: false
|
||||
- job: test container
|
||||
artifacts: true
|
||||
- job: test container # transitive
|
||||
artifacts: false
|
||||
- job: parse test changelog
|
||||
artifacts: true
|
||||
- job: check # sanity
|
||||
artifacts: false
|
||||
- job: sanitize test container
|
||||
artifacts: true
|
||||
rules: *test-release-rules
|
||||
retry: 2
|
||||
upload dev container:
|
||||
variables:
|
||||
GIT_STRATEGY: none
|
||||
stage: release
|
||||
image: quay.io/skopeo/stable:latest
|
||||
script:
|
||||
- skopeo --insecure-policy copy --dest-creds "${CI_REGISTRY_USER}:${CI_JOB_TOKEN}" docker-archive://$(pwd)/uniworx-sanitized.tar.gz docker://${CI_REGISTRY}/fradrive/fradrive/dev:${CI_COMMIT_REF_NAME}
|
||||
- skopeo --insecure-policy copy --src-creds "${CI_REGISTRY_USER}:${CI_JOB_TOKEN}" --dest-creds "${CI_REGISTRY_USER}:${CI_JOB_TOKEN}" docker://${CI_REGISTRY}/fradrive/fradrive/dev:${CI_COMMIT_REF_NAME} docker://${CI_REGISTRY}/fradrive/fradrive/dev:latest
|
||||
needs:
|
||||
- job: node dependencies # transitive
|
||||
artifacts: false
|
||||
- job: well known # transitive
|
||||
artifacts: false
|
||||
- job: frontend # transitive
|
||||
artifacts: false
|
||||
- job: uniworx:lib:uniworx # transitive
|
||||
artifacts: false
|
||||
- job: uniworx:exe:uniworx # transitive
|
||||
artifacts: false
|
||||
- job: dev container # transitive
|
||||
artifacts: false
|
||||
- job: check # sanity
|
||||
artifacts: false
|
||||
- job: sanitize dev container
|
||||
artifacts: true
|
||||
rules: *dev-release-rules
|
||||
retry: 2
|
||||
|
||||
release:
|
||||
variables:
|
||||
@ -394,3 +564,18 @@ test release:
|
||||
artifacts: false
|
||||
- job: parse test changelog
|
||||
artifacts: true
|
||||
dev release:
|
||||
variables:
|
||||
GIT_STRATEGY: none
|
||||
stage: release
|
||||
image: registry.gitlab.com/gitlab-org/release-cli:latest
|
||||
rules: *dev-release-rules
|
||||
script:
|
||||
- echo "Will create dev release ${VERSION}-dev..."
|
||||
release:
|
||||
name: "${VERSION}-dev"
|
||||
tag_name: '$CI_COMMIT_TAG'
|
||||
description: .current-changelog.md
|
||||
needs:
|
||||
- job: check # sanity
|
||||
artifacts: false
|
||||
|
||||
231
.gitlab-ci/sanitize-docker.pl
Executable file
231
.gitlab-ci/sanitize-docker.pl
Executable file
@ -0,0 +1,231 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Data::Dumper;
|
||||
|
||||
my $tmpdir = "tmp-sanitize";
|
||||
|
||||
die "Has already run, abort" if -e $tmpdir;
|
||||
|
||||
mkdir $tmpdir;
|
||||
|
||||
chmod(0755, $tmpdir);
|
||||
chdir($tmpdir);
|
||||
system("ln -s ../uniworx.tar.gz .");
|
||||
system("tar xzvf uniworx.tar.gz");
|
||||
chmod(0755, '.'); # tar can change the rights of '.' if it contains an entry for '.' with other rights
|
||||
|
||||
my %truerights = ();
|
||||
storeRightsMake7(".");
|
||||
|
||||
#print "=== Extended rights:\n";
|
||||
#system("ls -l *");
|
||||
#resetRights(".");
|
||||
#print "=== Reset rights:\n";
|
||||
#system("ls -l *");
|
||||
|
||||
#
|
||||
sub storeRightsMake7 {
|
||||
my ($pwd) = @_;
|
||||
my $dh = undef;
|
||||
opendir($dh, $pwd) or die "Could not read dir '$pwd', because: $!";
|
||||
while(my $fn = readdir($dh)) {
|
||||
next if $fn=~m#^\.\.?$#;
|
||||
#perl -le 'my $dh = undef;opendir($dh, ".");while(my $fn = readdir($dh)) { my $mode = (stat($fn))[2];my $fm = $mode % 512;my $fmo=sprintf("%03o",$fm);print "$fn -> $fmo" }'
|
||||
my $fullname = "$pwd/$fn";
|
||||
my $mode = (stat($fullname))[2];
|
||||
my $fm = $mode % 512;
|
||||
#my $fmo = sprintf("%03o",$fm);
|
||||
$truerights{$fullname} = $fm;
|
||||
chmod(($fm | 0700), $fullname);
|
||||
storeRightsMake7($fullname) if -d $fullname;
|
||||
}
|
||||
}
|
||||
|
||||
sub resetRights {
|
||||
my ($pwd) = @_;
|
||||
print "Resetting rights to:\n" if '.' eq $pwd;
|
||||
print Data::Dumper::Dumper(\%truerights);
|
||||
my $dh = undef;
|
||||
opendir($dh, $pwd) or die "Could not read dir '$pwd', because: $!";
|
||||
while(my $fn = readdir($dh)) {
|
||||
next if $fn=~m#^\.\.?$#;
|
||||
#perl -le 'my $dh = undef;opendir($dh, ".");while(my $fn = readdir($dh)) { my $mode = (stat($fn))[2];my $fm = $mode % 512;my $fmo=sprintf("%03o",$fm);print "$fn -> $fmo" }'
|
||||
my $fullname = "$pwd/$fn";
|
||||
printf(" set rights of '$fullname' back to %03o\n", $truerights{$fullname});
|
||||
chmod($truerights{$fullname}, $fullname);
|
||||
resetRights($fullname) if -d $fullname;
|
||||
}
|
||||
}
|
||||
|
||||
sub renameWithRights {
|
||||
my ($from, $to) = @_;
|
||||
print " rename file '$from' to '$to'\n";
|
||||
my %oldrights = %truerights;
|
||||
%truerights = ();
|
||||
while(my ($k,$v) = each %oldrights) {
|
||||
$k =~ s#^\./\Q$from\E#./$to#;
|
||||
$truerights{$k} = $v;
|
||||
}
|
||||
#my $rights = $truerights{$from};
|
||||
#delete $truerights{$from};
|
||||
rename($from, $to) or die "Could not rename '$from' to '$to', because $!";
|
||||
#$truerights{$to} = $rights
|
||||
}
|
||||
|
||||
print Data::Dumper::Dumper(\%truerights);
|
||||
#exit 0;
|
||||
|
||||
# Checksummen:
|
||||
# outerjson c27f -- toplevel $outerjson.json, by sha256sum $outerjson.json
|
||||
# imageid d940 -- toplevel verzeichnis mit der layer darin; doc says: Each image’s ID is given by the SHA256 hash of its configuration JSON.
|
||||
# we'll try as configuration "remove nodejs $oldhash"
|
||||
# or we just use a random number ;)
|
||||
# layertar fd3d -- doc says: Each image’s ID is given by the SHA256 hash of its configuration JSON.
|
||||
#
|
||||
##### FOUND
|
||||
# outerjson c27f64c8de183296ef409baecc27ddac8cd4065aac760b1b512caf482ad782dd -- in manifest.json
|
||||
# imageid d940253667b5ab47060e8bf537bd5b3e66a2447978f3c784a22b115a262fccbf -- in manifest.json
|
||||
# imageid d940253667b5ab47060e8bf537bd5b3e66a2447978f3c784a22b115a262fccbf -- as toplevel dirname
|
||||
# outerjson c27f64c8de183296ef409baecc27ddac8cd4065aac760b1b512caf482ad782dd -- as toplevel filename
|
||||
# imageid d940253667b5ab47060e8bf537bd5b3e66a2447978f3c784a22b115a262fccbf -- in $layerdir/json
|
||||
# layertar fd3d3cdf4ece09864ac933aa664eb5f397cf5ca28652125addd689726f8485cd -- in $outerjson.json
|
||||
#
|
||||
#
|
||||
##### COMPUTE
|
||||
# toplevel
|
||||
# outerjson c27f64c8de183296ef409baecc27ddac8cd4065aac760b1b512caf482ad782dd $outerjson.json
|
||||
# b21db3fcc85b23d91067a2a5834e114ca9eec0364742c8680546f040598d8cd9 manifest.json
|
||||
# 238f234e3a1ddb27a034f4ee1e59735175741e5cc05673b5dd41d9a42bac2ebd uniworx.tar.gz
|
||||
# in $layerdir/
|
||||
# 028c1e8d9688b420f7316bb44ce0e26f4712dc21ef93c5af8000c102b1405ad4 json
|
||||
# layertar fd3d3cdf4ece09864ac933aa664eb5f397cf5ca28652125addd689726f8485cd layer.tar
|
||||
# d0ff5974b6aa52cf562bea5921840c032a860a91a3512f7fe8f768f6bbe005f6 VERSION
|
||||
#
|
||||
#
|
||||
# sha256sum layer.tar fd3d3cdf4ece09864ac933aa664eb5f397cf5ca28652125addd689726f8485cd
|
||||
|
||||
my ($outerjson, $imageid) = ();
|
||||
|
||||
{
|
||||
my $dirh = undef;
|
||||
opendir($dirh, '.') or die "Could not read dir '.', because: $!";
|
||||
while(my $fn = readdir($dirh)) {
|
||||
next if $fn=~m#^\.#;
|
||||
if($fn=~m#(.*)\.json#) {
|
||||
$outerjson = $1;
|
||||
next
|
||||
}
|
||||
if($fn=~m#^[0-9a-f]{64}$#) {
|
||||
$imageid = $fn
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
die "Bad archive, could not found expected files and directories" unless defined($outerjson) and defined($imageid);
|
||||
|
||||
#system("pwd");
|
||||
#print "will run: sha256sum $imageid/layer.tar\n";
|
||||
|
||||
my $oldLayerdir = qx(sha256sum $imageid/layer.tar);
|
||||
#print "oldLayerdir is for now $oldLayerdir\n\n";
|
||||
$oldLayerdir =~ m#^([0-9a-f]{64}).*$# or die "layer.tar not found or sha256sum not installed!";
|
||||
$oldLayerdir = $1;
|
||||
|
||||
# tar --delete --file layer.tar nix/store/cdalbhzm3z4gz07wyg89maprdbjc4yah-nodejs-14.17.0
|
||||
my $layerContent = qx(tar -tf $imageid/layer.tar);
|
||||
|
||||
my @rms = $layerContent=~m#^((?:\./)?nix/store/[a-z0-9]+-(?:nodejs|openjdk|ghc)-[^/]+/)$#gm;
|
||||
|
||||
print "rm <<$_>>\n" for @rms;
|
||||
|
||||
system("tar --delete --file $imageid/layer.tar '$_'") for @rms;
|
||||
|
||||
|
||||
### Deconstruction finished, now lets put everything together again after fixing the checksums
|
||||
|
||||
|
||||
my $newImageId = qx(echo 'remove nodejs $imageid' | sha256sum);
|
||||
$newImageId =~ m#^([0-9a-f]{64}).*$# or die "sha256sum not installed!";
|
||||
$newImageId = $1;
|
||||
|
||||
my $newLayerdir = qx(sha256sum $imageid/layer.tar);
|
||||
$newLayerdir =~ m#^([0-9a-f]{64}).*$# or die "sha256sum not installed!";
|
||||
$newLayerdir = $1;
|
||||
|
||||
# new outerjson is computed later, as we first have to change its content
|
||||
|
||||
sub cautionWaiter {
|
||||
# some file operations give the impression that they are not instant.
|
||||
# Hence, we wait here a bit to see if that fixes stuff
|
||||
#sleep 5; # seems not to be the reason
|
||||
}
|
||||
|
||||
sub replaceInFile {
|
||||
my ($filename, $replacer) = @_;
|
||||
return unless -e $filename;
|
||||
my $fh = undef;
|
||||
open($fh, '<', $filename) or die "Could not read $filename, because: $!";
|
||||
my $content = join '', <$fh>;
|
||||
close $fh;
|
||||
keys %$replacer;
|
||||
while(my ($k,$v) = each %$replacer) {
|
||||
$content=~s#\Q$k\E#$v#g;
|
||||
}
|
||||
my $wh = undef;
|
||||
open($wh, '>', $filename) or die "Could not write $filename, because: $!";
|
||||
print $wh $content
|
||||
}
|
||||
|
||||
my %replacer = (
|
||||
$oldLayerdir => $newLayerdir,
|
||||
$imageid => $newImageId,
|
||||
);
|
||||
|
||||
replaceInFile("$imageid/json", \%replacer);
|
||||
replaceInFile("$outerjson.json", \%replacer);
|
||||
|
||||
cautionWaiter();
|
||||
|
||||
my $newOuterjson = qx(sha256sum '$outerjson.json');
|
||||
$newOuterjson =~ m#^([0-9a-f]{64}).*$# or die "sha256sum not installed!";
|
||||
$newOuterjson = $1;
|
||||
|
||||
cautionWaiter();
|
||||
|
||||
renameWithRights("$outerjson.json", "$newOuterjson.json");
|
||||
$replacer{$outerjson} = $newOuterjson;
|
||||
|
||||
replaceInFile("manifest.json", \%replacer);
|
||||
|
||||
replaceInFile("repositories", \%replacer);
|
||||
|
||||
cautionWaiter();
|
||||
renameWithRights($imageid, $newImageId);
|
||||
|
||||
cautionWaiter();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
resetRights(".");
|
||||
|
||||
|
||||
|
||||
|
||||
unlink("uniworx.tar.gz");
|
||||
|
||||
system("tar czvf uniwox-rmnodejs.tar.gz *");
|
||||
|
||||
cautionWaiter();
|
||||
print "Debug output, content of container:\n";
|
||||
system("tar tzvf uniwox-rmnodejs.tar.gz");
|
||||
|
||||
cautionWaiter();
|
||||
#unlink("../uniworx.tar.gz");
|
||||
|
||||
system("cp uniwox-rmnodejs.tar.gz ../uniworx-sanitized.tar.gz");
|
||||
|
||||
1584
CHANGELOG.md
1584
CHANGELOG.md
File diff suppressed because it is too large
Load Diff
@ -16,8 +16,13 @@ fi
|
||||
branch="$(git rev-parse --abbrev-ref HEAD)"
|
||||
|
||||
if [[ $branch != "master" && $branch != "test" ]]; then
|
||||
if echo $@ | grep -xqe '--dev';
|
||||
then
|
||||
: # dev-releases possible on any branch
|
||||
else
|
||||
echo "Not on master or test" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
ourHash=$(git rev-parse HEAD)
|
||||
|
||||
@ -14,8 +14,8 @@ let
|
||||
'');
|
||||
in if self ? lastModified then fromDate else "1970-01-01T00:00:01Z";
|
||||
|
||||
mkUniworxDocker = { isTest }: prev.dockerTools.buildImage {
|
||||
name = "uniworx${optionalString isTest "-test"}";
|
||||
mkUniworxDocker = { scope, isTest }: prev.dockerTools.buildImage {
|
||||
name = "uniworx" + (if scope == null then "" else "-${scope}");
|
||||
tag =
|
||||
let
|
||||
versionFile = if isTest then ./test-version.json else ./version.json;
|
||||
@ -111,6 +111,7 @@ let
|
||||
};
|
||||
in
|
||||
mapAttrs (_name: mkUniworxDocker) {
|
||||
uniworxTestDocker = { isTest = true; };
|
||||
uniworxDocker = { isTest = false; };
|
||||
uniworxDocker = { isTest = false; scope = null; };
|
||||
uniworxTestDocker = { isTest = false; scope = "test"; };
|
||||
uniworxDevDocker = { isTest = false; scope = "dev"; };
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"version": "28.0.0"
|
||||
"version": "28.0.7"
|
||||
}
|
||||
|
||||
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "uni2work",
|
||||
"version": "28.0.0",
|
||||
"version": "28.0.7",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "uni2work",
|
||||
"version": "28.0.0",
|
||||
"version": "28.0.7",
|
||||
"description": "",
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
@ -25,7 +25,9 @@
|
||||
"i18n:test": "./missing-translations.sh",
|
||||
"prerelease": "./is-clean.sh && npm run test",
|
||||
"release": "./release.sh",
|
||||
"release-dev": "./release.sh --dev",
|
||||
"postrelease": "git push --follow-tags",
|
||||
"postrelease-dev": "git push --follow-tags",
|
||||
"parse-changelog": "changelog-parser ./CHANGELOG.md > changelog.json"
|
||||
},
|
||||
"husky": {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
name: uniworx
|
||||
version: 28.0.0
|
||||
version: 28.0.7
|
||||
dependencies:
|
||||
- base
|
||||
- yesod
|
||||
|
||||
11
release.sh
11
release.sh
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# SPDX-FileCopyrightText: 2023 Sarah Vaupel <sarah.vaupel@uniworx.de>
|
||||
# SPDX-FileCopyrightText: 2023-2024 Sarah Vaupel <sarah.vaupel@uniworx.de>
|
||||
#
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
@ -14,7 +14,12 @@ case "$(git rev-parse --abbrev-ref HEAD)" in
|
||||
standard-version -a -t t
|
||||
;;
|
||||
*)
|
||||
echo "Current branch not supported for release!"
|
||||
exit 1
|
||||
if echo $@ | grep -xqe '--dev';
|
||||
then
|
||||
standard-version -a -t d
|
||||
else
|
||||
echo "Current branch not supported for release!"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
Loading…
Reference in New Issue
Block a user