Skip to content

Commit

Permalink
Merge pull request #268 from essentialkaos/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
andyone authored Dec 21, 2023
2 parents 937607c + 24c784c commit 8788c0a
Show file tree
Hide file tree
Showing 65 changed files with 1,115 additions and 1,035 deletions.
94 changes: 61 additions & 33 deletions release-info-gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@ package main

// ////////////////////////////////////////////////////////////////////////////////// //
// //
// Copyright (c) 2021 ESSENTIAL KAOS //
// Copyright (c) 2023 ESSENTIAL KAOS //
// Apache License, Version 2.0 <https://www.apache.org/licenses/LICENSE-2.0> //
// //
// ////////////////////////////////////////////////////////////////////////////////// //

import (
"fmt"
"os"
"os/exec"
"sort"
"strconv"
"strings"

"pkg.re/essentialkaos/ek.v12/fmtc"
"pkg.re/essentialkaos/ek.v12/path"
"pkg.re/essentialkaos/ek.v12/sortutil"
"pkg.re/essentialkaos/ek.v12/strutil"
"github.com/essentialkaos/ek/env"
"github.com/essentialkaos/ek/fmtc"
"github.com/essentialkaos/ek/path"
"github.com/essentialkaos/ek/sortutil"
"github.com/essentialkaos/ek/strutil"
)

// ////////////////////////////////////////////////////////////////////////////////// //

const (
APP = "ReleaseInfoGen"
VER = "1.0.0"
VER = "2.0.0"
DESC = "Go utility for generating release info"
)

Expand Down Expand Up @@ -59,9 +59,32 @@ func (c Changes) Less(i, j int) bool {
// ////////////////////////////////////////////////////////////////////////////////// //

func main() {
checkoutLatestChanges()
check()
genChanges()
}

// check checks required apps
func check() {
if env.Which("git") == "" {
printErrorAndExit("This script requires git")
}
}

// genChanges generates list of changes
func genChanges() {
err := checkoutLatestChanges()

if err != nil {
printErrorAndExit(err.Error())
}

changes := createChangesList()

if len(changes) == 0 {
printWarn("No changes found")
return
}

listAdditions(changes)
listModifications(changes)
listDeletions(changes)
Expand All @@ -70,20 +93,22 @@ func main() {
// ////////////////////////////////////////////////////////////////////////////////// //

// checkoutLatestChanges checkouts the latest changes
func checkoutLatestChanges() {
func checkoutLatestChanges() error {
cmd := exec.Command("git", "checkout", "-B", "master", "origin/master")
err := cmd.Run()

if err != nil {
printErrorAndExit(err.Error())
return err
}

cmd = exec.Command("git", "checkout", "develop")
err = cmd.Run()

if err != nil {
printErrorAndExit(err.Error())
return err
}

return nil
}

// createChangesList makes slice with changes between develop and master branch
Expand Down Expand Up @@ -118,11 +143,10 @@ func listAdditions(changes Changes) {

for _, c := range changes {
if c.Type == TYPE_ADDED {
pkgName := getSpecValue(c.File, "name")
pkgDesc := getSpecValue(c.File, "summary")
values := getSpecValue(c.File, "name", "summary")

data = append(data, fmt.Sprintf(
"`%s` (_%s_)", pkgName, pkgDesc,
data = append(data, fmtc.Sprintf(
"`%s` (_{&}%s{!}_)", values[0], values[1],
))
}

Expand All @@ -131,22 +155,21 @@ func listAdditions(changes Changes) {
srcName := path.Base(c.Source)

if fileName != srcName {
pkgName := getSpecValue(c.File, "name")
pkgDesc := getSpecValue(c.File, "summary")
values := getSpecValue(c.File, "name", "summary")

data = append(data, fmt.Sprintf(
"`%s` (_%s_)", pkgName, pkgDesc,
data = append(data, fmtc.Sprintf(
"`%s` (_{&}%s{!}_)", values[0], values[1],
))
}
}
}

sortutil.StringsNatural(data)

fmt.Println("### New packages\n")
fmtc.Println("{*}### New packages{!}\n")

for _, info := range data {
fmt.Printf("- %s\n", info)
fmtc.Printf("{s}-{!} %s\n", info)
}

fmtc.NewLine()
Expand All @@ -161,20 +184,19 @@ func listModifications(changes Changes) {
continue
}

pkgName := getSpecValue(c.File, "name")
pkgVer := getSpecValue(c.File, "version")
values := getSpecValue(c.File, "name", "version")

data = append(data, fmt.Sprintf(
"`%s` updated to %s", pkgName, pkgVer,
data = append(data, fmtc.Sprintf(
"`%s` updated to %s", values[0], values[1],
))
}

sortutil.StringsNatural(data)

fmt.Println("### Updates\n")
fmtc.Println("{*}### Updates{!}\n")

for _, info := range data {
fmt.Printf("- %s\n", info)
fmtc.Printf("{s}-{!} %s\n", info)
}

fmtc.NewLine()
Expand Down Expand Up @@ -216,10 +238,10 @@ func listDeletions(changes Changes) {

sortutil.StringsNatural(data)

fmt.Println("### Deletions\n")
fmtc.Println("{*}### Deletions{!}\n")

for _, pkg := range data {
fmt.Printf("- `%s`\n", pkg)
fmtc.Printf("{s}-{!} `%s`\n", pkg)
}

fmtc.NewLine()
Expand Down Expand Up @@ -271,15 +293,21 @@ func filterChanges(changes Changes) Changes {
}

// getSpecValue reads macro value from spec
func getSpecValue(file, macro string) string {
cmd := exec.Command("rpm", "-q", "--qf", "%{"+macro+"}\n", "--specfile", file)
func getSpecValue(file string, macros ...string) []string {
var macroList string

for _, macro := range macros {
macroList += "%{" + macro + "}\n"
}

cmd := exec.Command("rpm", "-q", "--qf", macroList, "--specfile", file)
output, err := cmd.Output()

if err != nil {
return ""
return make([]string, len(macros))
}

return strings.Split(string(output), "\n")[0]
return strings.Split(string(output), "\n")
}

// isUniqSpec returns true if spec is unique (only one spec with this name)
Expand Down
10 changes: 7 additions & 3 deletions specs/adoptium/jdk11.spec
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@

################################################################################

%define jdk_major 11.0.19
%define jdk_minor 7
%define jdk_major 11.0.21
%define jdk_minor 9

%define install_dir %{_prefix}/java/%{name}-%{version}
%define jdk_bin_dir %{install_dir}/bin
%define jdk_man_dir %{install_dir}/man/man1

%define alt_priority 1166
%define alt_priority 1167

################################################################################

Expand All @@ -40,6 +40,7 @@ Conflicts: java-1.7.0-openjdk-headless
Conflicts: java-1.8.0-openjdk-headless
Conflicts: java-11-openjdk-headless
Conflicts: java-17-openjdk-headless
Conflicts: java-21-openjdk-headless

AutoProv: no
AutoReqProv: no
Expand Down Expand Up @@ -109,6 +110,9 @@ deps="$deps --slave %{_sysconfdir}/profile.d/java.sh java-profile %{install_dir}
################################################################################

%changelog
* Wed Dec 06 2023 Anton Novojilov <[email protected]> - 11.0.21-9
- https://adoptium.net/en-GB/temurin/release-notes/?version=jdk-11.0.21+9

* Sat Jul 08 2023 Anton Novojilov <[email protected]> - 11.0.19-7
- https://adoptium.net/en-GB/temurin/release-notes/?version=jdk-11.0.19+7

Expand Down
10 changes: 7 additions & 3 deletions specs/adoptium/jdk17.spec
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@

################################################################################

%define jdk_major 17.0.7
%define jdk_minor 7
%define jdk_major 17.0.9
%define jdk_minor 9

%define install_dir %{_prefix}/java/%{name}-%{version}
%define jdk_bin_dir %{install_dir}/bin
%define jdk_man_dir %{install_dir}/man/man1

%define alt_priority 1754
%define alt_priority 1755

################################################################################

Expand All @@ -40,6 +40,7 @@ Conflicts: java-1.7.0-openjdk-headless
Conflicts: java-1.8.0-openjdk-headless
Conflicts: java-11-openjdk-headless
Conflicts: java-17-openjdk-headless
Conflicts: java-21-openjdk-headless

AutoProv: no
AutoReqProv: no
Expand Down Expand Up @@ -109,6 +110,9 @@ deps="$deps --slave %{_sysconfdir}/profile.d/java.sh java-profile %{install_dir}
################################################################################

%changelog
* Wed Dec 06 2023 Anton Novojilov <[email protected]> - 17.0.9-9
- https://adoptium.net/en-GB/temurin/release-notes/?version=jdk-17.0.9+9

* Sat Jul 08 2023 Anton Novojilov <[email protected]> - 17.0.7-7
- https://adoptium.net/en-GB/temurin/release-notes/?version=jdk-17.0.7+7

Expand Down
114 changes: 114 additions & 0 deletions specs/adoptium/jdk21.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
################################################################################

%global crc_check pushd ../SOURCES ; sha512sum -c %{SOURCE100} ; popd

################################################################################

%define __jar_repack %{nil}

################################################################################

%define jdk_major 21.0.1
%define jdk_minor 12

%define install_dir %{_prefix}/java/%{name}-%{version}
%define jdk_bin_dir %{install_dir}/bin
%define jdk_man_dir %{install_dir}/man/man1

%define alt_priority 2155

################################################################################

Summary: OpenJDK Runtime Environment (JDK 21)
Name: jdk21
Epoch: 1
Version: %{jdk_major}
Release: %{jdk_minor}%{?dist}
Group: Development/Languages
License: ASL 1.1 and ASL 2.0 and BSD and BSD with advertising and GPL+ and GPLv2 and GPLv2 with exceptions and IJG and LGPLv2+ and MIT and MPLv2.0 and Public Domain and W3C and zlib
URL: https://adoptium.net

Source0: https://github.com/adoptium/temurin21-binaries/releases/download/jdk-%{jdk_major}+%{jdk_minor}/OpenJDK21U-jdk_x64_linux_hotspot_%{jdk_major}_%{jdk_minor}.tar.gz
Source1: java.sh

Source100: checksum.sha512

BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

Conflicts: java-1.6.0-openjdk-headless
Conflicts: java-1.7.0-openjdk-headless
Conflicts: java-1.8.0-openjdk-headless
Conflicts: java-11-openjdk-headless
Conflicts: java-17-openjdk-headless
Conflicts: java-21-openjdk-headless

AutoProv: no
AutoReqProv: no

Provides: jdk = 1:21
Provides: jdk-lts = 1:21
Provides: java = 1:21
Provides: jdk-%{jdk_major} = 1:%{version}-%{release}
Provides: jdk-lts-%{jdk_major} = 1:%{version}-%{release}
Provides: java-%{jdk_major} = 1:%{version}-%{release}

Provides: %{name} = %{version}-%{release}

################################################################################

%description
Java™ is the world's leading programming language and platform. The Adoptium
Working Group promotes and supports high-quality, TCK certified runtimes and
associated technology for use across the Java™ ecosystem.

################################################################################

%prep
%{crc_check}

%setup -qn jdk-%{jdk_major}+%{jdk_minor}

%build

%install
rm -rf %{buildroot}

rm -rf demo release

mkdir -p %{buildroot}%{install_dir}
cp -a * %{buildroot}%{install_dir}/

install -pm 644 %{SOURCE1} %{buildroot}%{install_dir}/

%clean
rm -rf %{buildroot}

%post
deps="%{_bindir}/java java %{jdk_bin_dir}/java %{alt_priority}"

for bin in $(ls -1 %{jdk_bin_dir}) ; do
deps="$deps --slave %{_bindir}/$bin $bin %{jdk_bin_dir}/$bin"
done

for doc in $(ls -1 %{jdk_man_dir}) ; do
deps="$deps --slave %{_mandir}/man1/$doc $doc %{jdk_man_dir}/$doc"
done

deps="$deps --slave %{_sysconfdir}/profile.d/java.sh java-profile %{install_dir}/java.sh"

%{_sbindir}/update-alternatives --install $deps

%preun
%{_sbindir}/update-alternatives --remove java %{jdk_bin_dir}/java

################################################################################

%files
%defattr(-, root, root, -)
%{install_dir}

################################################################################

%changelog
* Wed Dec 06 2023 Anton Novojilov <[email protected]> - 21.0.1-12
- Initial build for kaos repository
Loading

0 comments on commit 8788c0a

Please sign in to comment.