Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
97f41285c3 | |||
72430a2d8e | |||
b87065b548 | |||
d86d54d2ec | |||
8d77819f57 | |||
7029d039a3 | |||
991d8a9977 | |||
b16d319b0c | |||
4cf94e5514 | |||
ccc7acbed7 | |||
4a004567fa | |||
4907cc8de7 | |||
2f280c9daf |
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
target*
|
||||||
|
source*
|
||||||
|
go-gluon-publish
|
@ -30,3 +30,4 @@ matrix:
|
|||||||
GOARCH:
|
GOARCH:
|
||||||
- arm64
|
- arm64
|
||||||
- amd64
|
- amd64
|
||||||
|
- 386
|
||||||
|
8
main.go
8
main.go
@ -19,9 +19,9 @@ func main() {
|
|||||||
sdir := *source_dir
|
sdir := *source_dir
|
||||||
tdir := *target_dir
|
tdir := *target_dir
|
||||||
br := *branch
|
br := *branch
|
||||||
|
version := readVersions(*branch)
|
||||||
var source_dir_branch string = sdir + br + "/"
|
var source_dir_branch string = sdir + br + "/images/"
|
||||||
var target_dir_branch string = tdir + br + "/"
|
var target_dir_branch string = tdir + br
|
||||||
|
|
||||||
if is_firmware_folder(source_dir_branch) {
|
if is_firmware_folder(source_dir_branch) {
|
||||||
//generate manifest file for branch
|
//generate manifest file for branch
|
||||||
@ -31,7 +31,7 @@ func main() {
|
|||||||
log.Println("Error generating Manifest file: ", err)
|
log.Println("Error generating Manifest file: ", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
release_branch(*branch, source_dir_branch, target_dir_branch, *dryrun)
|
release_branch(*branch, source_dir_branch, target_dir_branch, *dryrun, version)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
manifest.go
10
manifest.go
@ -44,9 +44,9 @@ func split_filenames(files []fs.FileInfo, dir string) []Files {
|
|||||||
}
|
}
|
||||||
split_name := len(split) - 1
|
split_name := len(split) - 1
|
||||||
// Routername
|
// Routername
|
||||||
router_name := strings.Join(split[5:split_name], "-")
|
router_name := strings.Join(split[4:split_name], "-")
|
||||||
//RELEASE
|
//RELEASE
|
||||||
router_release := strings.Join(split[3:5], "-")
|
router_release := strings.Join(split[2:4], "-")
|
||||||
//Checksum
|
//Checksum
|
||||||
sha256, _ := checksum.SHA256sum(dir + "/" + current_name)
|
sha256, _ := checksum.SHA256sum(dir + "/" + current_name)
|
||||||
//FileSize
|
//FileSize
|
||||||
@ -60,7 +60,7 @@ func split_filenames(files []fs.FileInfo, dir string) []Files {
|
|||||||
func build_manifest(files []Files, dir string) error {
|
func build_manifest(files []Files, dir string) error {
|
||||||
// Datei zum Schreiben öffnen
|
// Datei zum Schreiben öffnen
|
||||||
release := strings.Split(files[0].Release, "-")
|
release := strings.Split(files[0].Release, "-")
|
||||||
file, err := os.Create(dir + release[0] + ".manifest")
|
file, err := os.Create(dir + release[1] + ".manifest")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("error creating manifest file")
|
fmt.Println("error creating manifest file")
|
||||||
return err
|
return err
|
||||||
@ -72,7 +72,7 @@ func build_manifest(files []Files, dir string) error {
|
|||||||
// Datum im gewünschten Format formatieren
|
// Datum im gewünschten Format formatieren
|
||||||
formatted := now.Format("2006-01-02 15:04:05-07:00")
|
formatted := now.Format("2006-01-02 15:04:05-07:00")
|
||||||
|
|
||||||
branch_line := "BRANCH=" + release[0] + "\n"
|
branch_line := "BRANCH=" + release[1] + "\n"
|
||||||
date_line := "DATE=" + formatted + "\n"
|
date_line := "DATE=" + formatted + "\n"
|
||||||
prio_line := "PRIORITY=0" + "\n"
|
prio_line := "PRIORITY=0" + "\n"
|
||||||
|
|
||||||
@ -104,6 +104,6 @@ func build_manifest(files []Files, dir string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.Println("Manifest file " + release[0] + ".manifest" + " generated")
|
log.Println("Manifest file " + release[1] + ".manifest" + " generated")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
99
release.go
99
release.go
@ -1,37 +1,65 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func release_branch(branch string, source_dir string, target_dir string, dryrun bool) {
|
func release_branch(b string, sDir string, tDir string, dryrun bool, v string) {
|
||||||
checkOldFolder, _ := os.ReadDir(source_dir)
|
check_sDir, _ := os.ReadDir(sDir)
|
||||||
checkNewFolder, _ := os.ReadDir(target_dir)
|
check_tDir, _ := os.ReadDir(tDir)
|
||||||
var newImages bool = false
|
var newImages bool = false
|
||||||
if len(checkOldFolder) > 0 {
|
if len(check_sDir) > 0 {
|
||||||
newImages = true
|
newImages = true
|
||||||
}
|
}
|
||||||
|
sVersion := GetGluonVersion(sDir)
|
||||||
|
tVersion := GetGluonVersion(tDir)
|
||||||
|
fmt.Println("Target Version:", b, tVersion)
|
||||||
|
fmt.Println("Source Version:", b, sVersion)
|
||||||
|
fmt.Println("Wanted Version:", b, v)
|
||||||
|
//check wanted version in target
|
||||||
|
if tVersion == v {
|
||||||
|
log.Println(b, "wanted version is already published!")
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
log.Println(b, "published version is outdated, try to update from source folder")
|
||||||
|
if sVersion != v {
|
||||||
|
log.Println(b, "wanted Version is not availible in source folder")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
if newImages {
|
if newImages {
|
||||||
// delete old firmware files in public folder
|
// delete old firmware files in public folder
|
||||||
for _, file := range checkNewFolder {
|
// if we are in stable branch, move images to archive
|
||||||
if !(dryrun) {
|
if b == "stable" {
|
||||||
err := os.RemoveAll(target_dir + file.Name())
|
err := os.Rename(tDir+"/*", tDir+"/archive/"+v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("error deleting file: ", err)
|
log.Fatalln(err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for _, file := range check_tDir {
|
||||||
|
if !(dryrun) {
|
||||||
|
err := os.RemoveAll(tDir + "/" + file.Name())
|
||||||
|
if err != nil {
|
||||||
|
log.Println("error deleting file: ", err)
|
||||||
|
} else {
|
||||||
|
log.Println("removed file: ", file.Name())
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
log.Println("removed file: ", file.Name())
|
log.Println("DRYRUN: delete folder :", file.Name())
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
log.Println("DRYRUN: delete folder :", file.Name())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//move new files to folder
|
//move new files to folder
|
||||||
for _, file := range checkOldFolder {
|
for _, file := range check_sDir {
|
||||||
if !(dryrun) {
|
if !(dryrun) {
|
||||||
os.Rename(source_dir+file.Name(), target_dir+file.Name())
|
os.Rename(sDir+file.Name(), tDir+file.Name())
|
||||||
log.Println("moved file: ", file.Name())
|
log.Println("moved file: ", file.Name())
|
||||||
} else {
|
} else {
|
||||||
log.Println("DRYRUN: move folder: ", file.Name())
|
log.Println("DRYRUN: move folder: ", file.Name())
|
||||||
@ -39,3 +67,46 @@ func release_branch(branch string, source_dir string, target_dir string, dryrun
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetGluonVersion(path string) string {
|
||||||
|
image_folder := path + "/sysupgrade/"
|
||||||
|
files, err := filepath.Glob(filepath.Join(image_folder, "gluon-tdf-*"))
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error reading directory: ", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(files) > 0 {
|
||||||
|
fileName := filepath.Base(files[0])
|
||||||
|
parts := strings.Split(fileName, "-")
|
||||||
|
if len(parts) >= 4 {
|
||||||
|
version := parts[2]
|
||||||
|
return version
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func readVersions(branch string) string {
|
||||||
|
filePath := "/srv/fwuploads-tmp/bin/release_state.json"
|
||||||
|
v, err := ioutil.ReadFile(filePath)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalln("Error reading version JSON file!")
|
||||||
|
}
|
||||||
|
|
||||||
|
var data Versions
|
||||||
|
err = json.Unmarshal(v, &data)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalln("Error in JSON data!")
|
||||||
|
}
|
||||||
|
switch branch {
|
||||||
|
case "stable":
|
||||||
|
return data.Stable
|
||||||
|
case "beta":
|
||||||
|
return data.Beta
|
||||||
|
case "experimental":
|
||||||
|
return data.Experimental
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
5
release_state.json
Normal file
5
release_state.json
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"stable": "v2022.1.4",
|
||||||
|
"beta": "v2022.1.5",
|
||||||
|
"experimental": "v2022.1.4"
|
||||||
|
}
|
@ -1,6 +0,0 @@
|
|||||||
BRANCH=stable
|
|
||||||
DATE=2023-05-29 21:26:35+02:00
|
|
||||||
PRIORITY=0
|
|
||||||
|
|
||||||
avm-fritz-wlan-repeater-300e stable-3.7.0 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 gluon-lo-snw-stable-3.7.0-avm-fritz-wlan-repeater-300e-sysupgrade.bin
|
|
||||||
tp-link-tl-wdr3600-v1 stable-3.7.0 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 gluon-lo-snw-stable-3.7.0-tp-link-tl-wdr3600-v1-sysupgrade.bin
|
|
Loading…
Reference in New Issue
Block a user