diff options
author | EuAndreh <eu@euandre.org> | 2023-03-21 11:38:47 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2023-03-21 11:38:47 -0300 |
commit | 21199e03edb130e136d538f4927711eea5dd730f (patch) | |
tree | be97101be27711964a8b9301c4228c7cc5635d9a /src/bin/paku | |
parent | src/bin/paku: Use list of strings over multiple loops (diff) | |
download | package-repository-21199e03edb130e136d538f4927711eea5dd730f.tar.gz package-repository-21199e03edb130e136d538f4927711eea5dd730f.tar.xz |
paku.lock: Use flat format for packages
Diffstat (limited to 'src/bin/paku')
-rwxr-xr-x | src/bin/paku | 382 |
1 files changed, 188 insertions, 194 deletions
diff --git a/src/bin/paku b/src/bin/paku index e4f0b83..d73107a 100755 --- a/src/bin/paku +++ b/src/bin/paku @@ -132,76 +132,74 @@ if ($action eq 'nix') { self: super: { $ns = rec { EOF - for my $package (@{$json->{packages}}) { - for my $version (@{$package->{versions}}) { - my $ver = $version->{name}; - $ver =~ s/^v//; - $ver =~ s/\./-/g; - if ($version->{type} eq 'latest') { - $ver = 'latest'; - print <<~EOF; - $package->{name} = $package->{name}-latest; - EOF - } - - my $long = $version->{'long-description'}; - $long =~ s/^(.)/ $1/gm; - - my $base_url = $base_url_prefix . '/' . $package->{name}; - + for my $pkg (@{$json->{packages}}) { + my $ver = $pkg->{version}; + $ver =~ s/^v//; + $ver =~ s/\./-/g; + if ($pkg->{type} eq 'latest') { + $ver = 'latest'; print <<~EOF; - $package->{name}-$ver = pkgs.stdenv.mkDerivation rec { - name = "$package->{name}"; - version = "$version->{name}"; + $pkg->{name} = $pkg->{name}-latest; + EOF + } - src = fetchTarball { - url = - "$version->{url}"; - sha256 = "$version->{sha256}"; - }; + my $long = $pkg->{'long-description'}; + $long =~ s/^(.)/ $1/gm; - nativeBuildInputs = with pkgs; [ - EOF + my $base_url = $base_url_prefix . '/' . $pkg->{name}; - for my $input (@{$version->{'native-inputs'}}) { - print <<~EOF; - $input - EOF - } - print <<~EOF; - ]; + print <<~EOF; + $pkg->{name}-$ver = pkgs.stdenv.mkDerivation rec { + name = "$pkg->{name}"; + version = "$pkg->{version}"; + + src = fetchTarball { + url = + "$pkg->{url}"; + sha256 = "$pkg->{sha256}"; + }; + + nativeBuildInputs = with pkgs; [ + EOF - buildInputs = with pkgs; [ + for my $input (@{$pkg->{'native-inputs'}}) { + print <<~EOF; + $input EOF - for my $input (@{$version->{inputs}}) { - print <<~EOF; - $input - EOF - } + } + print <<~EOF; + ]; + + buildInputs = with pkgs; [ + EOF + for my $input (@{$pkg->{inputs}}) { print <<~EOF; - ]; - - makeFlags = [ "PREFIX=\$(out)" ]; - - doCheck = true; - enableParallelBuilding = true; - - meta = with pkgs.lib; { - description = "$version->{description}"; - longDescription = '' - $long - ''; - homepage = "$base_url/"; - changelog = "$base_url/CHANGELOG.html"; - downloadPage = "$base_url/#releases"; - license = licenses.agpl3; - platforms = platforms.unix; - }; - }; + $input EOF - # FIXME: escape quotes in description - # FIXME: parameterize license } + print <<~EOF; + ]; + + makeFlags = [ "PREFIX=\$(out)" ]; + + doCheck = true; + enableParallelBuilding = true; + + meta = with pkgs.lib; { + description = "$pkg->{description}"; + longDescription = '' + $long + ''; + homepage = "$base_url/"; + changelog = "$base_url/CHANGELOG.html"; + downloadPage = "$base_url/#releases"; + license = licenses.agpl3; + platforms = platforms.unix; + }; + }; + EOF + # FIXME: escape quotes in description + # FIXME: parameterize license } print <<~EOF; }; @@ -232,78 +230,76 @@ if ($action eq 'guix') { EOF - for my $package (@{$json->{packages}}) { - for my $version (@{$package->{versions}}) { - my $ver = $version->{name}; - $ver =~ s/^v//; - $ver =~ s/\./-/g; - if ($version->{type} eq 'latest') { - push @pkgs, "$package->{name}"; - $ver = 'latest'; - } + for my $pkg (@{$json->{packages}}) { + my $ver = $pkg->{version}; + $ver =~ s/^v//; + $ver =~ s/\./-/g; + if ($pkg->{type} eq 'latest') { + push @pkgs, "$pkg->{name}"; + $ver = 'latest'; + } - my $long = $version->{'long-description'}; - $long =~ s/^(.)/ $1/gm; + my $long = $pkg->{'long-description'}; + $long =~ s/^(.)/ $1/gm; - my $base_url = $base_url_prefix . '/' . $package->{name}; + my $base_url = $base_url_prefix . '/' . $pkg->{name}; - push @pkgs, "$package->{name}-$ver"; - # FIXME: indentation of (source ...) - print <<~EOF; - (define-public $package->{name}-$ver - (package - (name "$package->{name}-$ver") - (version "$version->{name}") - (source (origin - (method url-fetch) - (uri "$version->{url}") - (sha256 - (base32 "$version->{sha256FIXME}")))) - (build-system gnu-build-system) - (native-inputs - EOF + push @pkgs, "$pkg->{name}-$ver"; + # FIXME: indentation of (source ...) + print <<~EOF; + (define-public $pkg->{name}-$ver + (package + (name "$pkg->{name}-$ver") + (version "$pkg->{version}") + (source (origin + (method url-fetch) + (uri "$pkg->{url}") + (sha256 + (base32 "$pkg->{sha256FIXME}")))) + (build-system gnu-build-system) + (native-inputs + EOF + + print ' (list'; + for my $input (@{$pkg->{'native-inputs'}}) { + my $name = $json->{mappings}{$input}{guix} || $input; + print "\n $name"; + } + print "))\n"; - print ' (list'; - for my $input (@{$version->{'native-inputs'}}) { - my $name = $json->{mappings}{$input}{guix} || $input; - print "\n $name"; - } - print "))\n"; - - print " (inputs\n"; - print ' (list'; - for my $input (@{$version->{inputs}}) { - my $name = $json->{mappings}{$input}{guix} || $input; - print "\n $name"; - } - print "))\n"; + print " (inputs\n"; + print ' (list'; + for my $input (@{$pkg->{inputs}}) { + my $name = $json->{mappings}{$input}{guix} || $input; + print "\n $name"; + } + print "))\n"; + print <<~EOF; + (arguments + (list + #:make-flags '(list (string-append "PREFIX=" %output)) + #:phases + #~(modify-phases %standard-phases + (delete 'configure)))) + (synopsis "$pkg->{description}") + (description + "$pkg->{'long-description'}") + (home-page "$base_url/") + (license license:agpl3+))) + + EOF + # FIXME: escape quotes in description + # FIXME: parameterize license + if ($pkg->{type} eq 'latest') { print <<~EOF; - (arguments - (list - #:make-flags '(list (string-append "PREFIX=" %output)) - #:phases - #~(modify-phases %standard-phases - (delete 'configure)))) - (synopsis "$version->{description}") - (description - "$version->{'long-description'}") - (home-page "$base_url/") - (license license:agpl3+))) + (define-public $pkg->{name} + (package + (inherit $pkg->{name}-latest) + (name "$pkg->{name}"))) + EOF - # FIXME: escape quotes in description - # FIXME: parameterize license - if ($version->{type} eq 'latest') { - print <<~EOF; - (define-public $package->{name} - (package - (inherit $package->{name}-latest) - (name "$package->{name}"))) - - - EOF - } } } print '(list'; @@ -326,82 +322,80 @@ my %vars = ( my @targets = (); -for my $package (@{$json->{packages}}) { - for my $version (@{$package->{versions}}) { - push @{$vars{tarballs}}, "\t$dir/tarballs/$version->{fname} \\\n"; - push @{$vars{checkouts}}, "\t$dir/checkouts/$package->{name}-$version->{name} \\\n"; - - push @targets, <<~EOF; - $dir/tarballs/$version->{fname}: - mkdir -p \$(\@D) - wget -O \$\@ \\ - '$version->{url}' +for my $pkg (@{$json->{packages}}) { + push @{$vars{tarballs}}, "\t$dir/tarballs/$pkg->{fname} \\\n"; + push @{$vars{checkouts}}, "\t$dir/checkouts/$pkg->{name}-$pkg->{version} \\\n"; - $dir/checkouts/$package->{name}-$version->{name}: $dir/tarballs/$version->{fname} - mkdir -p \$(\@D) - tar -C $dir/checkouts/ -xf $dir/tarballs/$version->{fname} - touch \$\@ - - EOF + push @targets, <<~EOF; + $dir/tarballs/$pkg->{fname}: + mkdir -p \$(\@D) + wget -O \$\@ \\ + '$pkg->{url}' + $dir/checkouts/$pkg->{name}-$pkg->{version}: $dir/tarballs/$pkg->{fname} + mkdir -p \$(\@D) + tar -C $dir/checkouts/ -xf $dir/tarballs/$pkg->{fname} + touch \$\@ - next if $version->{architectures} ne 'any'; + EOF - push @{$vars{destdirs}}, "\t$dir/debian-destdir/$package->{name}-$version->{name}/DEBIAN \\\n"; - push @{$vars{ctrlfiles}}, "\t$dir/debian-destdir/$package->{name}-$version->{name}/DEBIAN/control \\\n"; - push @{$vars{destdebs}}, "\t$dir/debian-destdir/$package->{name}-$version->{name}.deb \\\n"; - push @{$vars{debs}}, "\t$dir/debian/$package->{name}_$version->{name}_all.deb \\\n"; - my $ver = $version->{type} eq 'latest' ? '0.' . $version->{name} . '.latest' : $version->{name}; - $ver =~ s/^v//; - my $maintainer_b64 = MIME::Base64::encode_base64 $version->{maintainer}, ''; - my $desc_b64 = MIME::Base64::encode_base64 $version->{description}, ''; - my $long_desc_b64 = MIME::Base64::encode_base64 $version->{'long-description'}, ''; - - push @targets, <<~EOF; - $dir/debian-destdir/$package->{name}-$version->{name}/DEBIAN: $dir/checkouts/$package->{name}-$version->{name} - \$(MAKE) \\ - -C $dir/checkouts/$package->{name}-$version->{name} \\ - install \\ - PREFIX=/usr \\ - DESTDIR="\$\$PWD"/$dir/debian-destdir/$package->{name}-$version->{name} - mkdir -p \$\@ - touch \$\@ - - $dir/debian-destdir/$package->{name}-$version->{name}/DEBIAN/control: $dir/debian-destdir/$package->{name}-$version->{name}/DEBIAN - printf '' > \$\@ - printf 'Package: $package->{name}\\n' >> \$\@ - printf 'Version: $ver\\n' >> \$\@ - printf 'Section: custom\\n' >> \$\@ - printf 'Depends:\\n' >> \$\@ - printf 'Priority: optional\\n' >> \$\@ - printf 'Architecture: all\\n' >> \$\@ - printf 'Essential: no\\n' >> \$\@ - - printf 'Maintainer: ' >> \$\@ - printf '$maintainer_b64' | base64 -d >> \$\@ - printf '\\n' >> \$\@ - - printf 'Description: ' >> \$\@ - printf '$desc_b64' | base64 -d >> \$\@ - printf '\\n' >> \$\@ - - printf '$long_desc_b64' | \\ - base64 -d | \\ - sed 's|^\$\$|.|' | \\ - sed 's|^| |' >> \$\@ - printf '\\n' >> \$\@ - - $dir/debian-destdir/$package->{name}-$version->{name}.deb: $dir/debian-destdir/$package->{name}-$version->{name}/DEBIAN/control - dpkg-deb --build $dir/debian-destdir/$package->{name}-$version->{name} - - $dir/debian/$package->{name}_$version->{name}_all.deb: $dir/debian-destdir/$package->{name}-$version->{name}.deb - mkdir -p \$(\@D) - cp $dir/debian-destdir/$package->{name}-$version->{name}.deb \$\@ + next if $pkg->{architectures} ne 'any'; + + push @{$vars{destdirs}}, "\t$dir/debian-destdir/$pkg->{name}-$pkg->{version}/DEBIAN \\\n"; + push @{$vars{ctrlfiles}}, "\t$dir/debian-destdir/$pkg->{name}-$pkg->{version}/DEBIAN/control \\\n"; + push @{$vars{destdebs}}, "\t$dir/debian-destdir/$pkg->{name}-$pkg->{version}.deb \\\n"; + push @{$vars{debs}}, "\t$dir/debian/$pkg->{name}_$pkg->{version}_all.deb \\\n"; + + my $ver = $pkg->{type} eq 'latest' ? '0.' . $pkg->{version} . '.latest' : $pkg->{version}; + $ver =~ s/^v//; + my $maintainer_b64 = MIME::Base64::encode_base64 $pkg->{maintainer}, ''; + my $desc_b64 = MIME::Base64::encode_base64 $pkg->{description}, ''; + my $long_desc_b64 = MIME::Base64::encode_base64 $pkg->{'long-description'}, ''; + + push @targets, <<~EOF; + $dir/debian-destdir/$pkg->{name}-$pkg->{version}/DEBIAN: $dir/checkouts/$pkg->{name}-$pkg->{version} + \$(MAKE) \\ + -C $dir/checkouts/$pkg->{name}-$pkg->{version} \\ + install \\ + PREFIX=/usr \\ + DESTDIR="\$\$PWD"/$dir/debian-destdir/$pkg->{name}-$pkg->{version} + mkdir -p \$\@ + touch \$\@ + + $dir/debian-destdir/$pkg->{name}-$pkg->{version}/DEBIAN/control: $dir/debian-destdir/$pkg->{name}-$pkg->{version}/DEBIAN + printf '' > \$\@ + printf 'Package: $pkg->{name}\\n' >> \$\@ + printf 'Version: $ver\\n' >> \$\@ + printf 'Section: custom\\n' >> \$\@ + printf 'Depends:\\n' >> \$\@ + printf 'Priority: optional\\n' >> \$\@ + printf 'Architecture: all\\n' >> \$\@ + printf 'Essential: no\\n' >> \$\@ + + printf 'Maintainer: ' >> \$\@ + printf '$maintainer_b64' | base64 -d >> \$\@ + printf '\\n' >> \$\@ + + printf 'Description: ' >> \$\@ + printf '$desc_b64' | base64 -d >> \$\@ + printf '\\n' >> \$\@ + + printf '$long_desc_b64' | \\ + base64 -d | \\ + sed 's|^\$\$|.|' | \\ + sed 's|^| |' >> \$\@ + printf '\\n' >> \$\@ + + $dir/debian-destdir/$pkg->{name}-$pkg->{version}.deb: $dir/debian-destdir/$pkg->{name}-$pkg->{version}/DEBIAN/control + dpkg-deb --build $dir/debian-destdir/$pkg->{name}-$pkg->{version} + + $dir/debian/$pkg->{name}_$pkg->{version}_all.deb: $dir/debian-destdir/$pkg->{name}-$pkg->{version}.deb + mkdir -p \$(\@D) + cp $dir/debian-destdir/$pkg->{name}-$pkg->{version}.deb \$\@ - EOF - } + EOF } |