Skip to content

Commit

Permalink
Merge pull request #45 from nkryuchkov/fix/skyimager-archive-format
Browse files Browse the repository at this point in the history
Fix skyimager archive format
  • Loading branch information
nkryuchkov authored Oct 21, 2020
2 parents f57ec2e + 626bc30 commit b616a55
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ deploy:
provider: releases
file_glob: true
file:
- output/final/*.tar.xz
- fyne-cross/bin/*.tar.xz
- output/final/*.tar.gz
- fyne-cross/bin/*.tar.gz
draft: true
prerelease: true
skip_cleanup: true
Expand Down
3 changes: 1 addition & 2 deletions build-skyimager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ TARGETS=("linux-amd64" "darwin-amd64" "windows-amd64")
for target in "${TARGETS[@]}"; do
cd "$FYNE" || exit 1
dst="./skyimager-$target-$VERSION"
tar -czf "$dst.tar" "$target"/* || exit 1
xz -vzT0 "$dst.tar" || exit 1
tar -czf "$dst.tar.gz" "$target"/* || exit 1
done

cd "$(pwd)" || 0
5 changes: 2 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,7 @@ calc_sums_compress()
# compress
info "Compressing, this will take a while..."
name=$(echo "${img}" | rev | cut -d '.' -f 2- | rev)
tar -cvf "${name}.tar" "${img}"*
xz -vzT0 "${name}.tar"
tar -cvzf "${name}.tar.gz" "${img}"*
done

cd "${ROOT}" || return 1
Expand All @@ -442,7 +441,7 @@ clean_output_dir()
# Clean parts.
cd "${PARTS_ARMBIAN_DIR}" && find . -type f ! -name '*.7z' -delete
cd "${PARTS_SKYWIRE_DIR}" && find . -type f ! -name '*.tar.gz' -delete && rm -rf bin
cd "${FINAL_IMG_DIR}" && find . -type f ! -name '*.tar.xz' -delete
cd "${FINAL_IMG_DIR}" && find . -type f ! -name '*.tar.gz' -delete

# Rm base image.
rm -v "${IMAGE_DIR}/base_image"
Expand Down
12 changes: 6 additions & 6 deletions pkg/imager/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
// File extensions which we expect to see in the archive.
const (
ExtTmp = ".tmp"
ExtTarXz = ".tar.xz"
ExtTarGz = ".tar.gz"
ExtImg = ".img"
ExtMD5 = ".img.md5"
ExtSHA1 = ".img.sha1"
Expand Down Expand Up @@ -71,7 +71,7 @@ func NewBuilder(log logrus.FieldLogger, root string) (*Builder, error) {

// DownloadPath returns the path to the download file.
func (b *Builder) DownloadPath() string {
return filepath.Join(b.baseDir, "download"+ExtTarXz)
return filepath.Join(b.baseDir, "download"+ExtTarGz)
}

// DownloadTotal is a thread-safe function that returns the total download size.
Expand Down Expand Up @@ -103,15 +103,15 @@ func (b *Builder) ExtractArchive() (err error) {
pkgFile := b.DownloadPath()
log.WithField("archive_file", pkgFile).Info("Extracting...")

tarXz := archiver.NewTarXz()
tarGz := archiver.NewTarGz()
defer func() {
if err := tarXz.Close(); err != nil {
if err := tarGz.Close(); err != nil {
log.WithError(err).Error("Failed to close archiver.")
}
}()

walkFn := func(f archiver.File) error {
if _, ok := hasExtension(f.Name(), ExtTarXz); ok || f.IsDir() {
if _, ok := hasExtension(f.Name(), ExtTarGz); ok || f.IsDir() {
log.WithField("file_name", f.Name()).
Debug("Skipping...")
return nil
Expand Down Expand Up @@ -160,7 +160,7 @@ func (b *Builder) ExtractArchive() (err error) {
return nil
}

if err = tarXz.Walk(pkgFile, walkFn); err != nil {
if err = tarGz.Walk(pkgFile, walkFn); err != nil {
return err
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/imager/latest_release.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const (
)

func expectedBaseImgAssetName(tag string) string {
return fmt.Sprintf("Skybian-%s%s", tag, ExtTarXz)
return fmt.Sprintf("Skybian-%s%s", tag, ExtTarGz)
}

// LatestBaseImgURL returns the latest stable base image download URL.
Expand Down

0 comments on commit b616a55

Please sign in to comment.