From adcd846cc26c4725313a9769996de18cf0b05feb Mon Sep 17 00:00:00 2001 From: d3v-null Date: Wed, 29 Jan 2025 19:44:05 +0800 Subject: [PATCH] add casacore data again --- .github/workflows/bottle.yml | 35 ++++++++++++++++++++---- Formula/birli.rb | 7 ++++- Formula/casacore-data.rb | 53 ++++++++++++++++++++++++++++++++++++ Formula/casacore.rb | 5 ++-- Formula/cfitsio_reentrant.rb | 2 -- 5 files changed, 92 insertions(+), 10 deletions(-) create mode 100644 Formula/casacore-data.rb diff --git a/.github/workflows/bottle.yml b/.github/workflows/bottle.yml index 17fc2de..f803e86 100644 --- a/.github/workflows/bottle.yml +++ b/.github/workflows/bottle.yml @@ -36,19 +36,44 @@ jobs: - run: brew test-bot --only-tap-syntax + # todo: + # - run: brew test-bot --only-formulae Formula/cfitsio_reentrant.rb Formula/casacore-data.rb + # Error: Unexpected bottle tarball: /Users/runner/work/homebrew-tap/homebrew-tap/cfitsio_reentrant--4.5.0_1.arm64_sonoma.bottle.1.tar.gz + # Error: Unexpected bottle JSON: /Users/runner/work/homebrew-tap/homebrew-tap/cfitsio_reentrant--4.5.0_1.arm64_sonoma.bottle.json + # + # - run: brew test-bot --only-formulae Formula/casacore.rb + # Error: Failed to load cask: Formula/casacore-data.rb + # Cask 'casacore-data' is unreadable: wrong constant name # + # Error: Failed to load cask: Formula/casacore.rb + # Cask 'casacore' is unreadable: wrong constant name # + # Warning: Treating Formula/casacore.rb as a formula. + # Error: The `brew link` step did not complete successfully + # The formula built, but is not symlinked into /opt/homebrew + # Could not symlink include/fitsio.h + # Target /opt/homebrew/include/fitsio.h + # is a symlink belonging to cfitsio_reentrant. You can unlink it: + # brew unlink cfitsio_reentrant + # To force the link and overwrite all conflicting files: + # brew link --overwrite cfitsio + # To list all files that would be deleted: + # brew link --overwrite cfitsio --dry-run + # Possible conflicting files are: + # /opt/homebrew/include/fitsio.h -> /opt/homebrew/Cellar/cfitsio_reentrant/4.5.0_1/include/fitsio.h + # /opt/homebrew/include/fitsio2.h -> /opt/homebrew/Cellar/cfitsio_reentrant/4.5.0_1/include/fitsio2.h + # /opt/homebrew/include/longnam.h -> /opt/homebrew/Cellar/cfitsio_reentrant/4.5.0_1/include/longnam.h - run: brew test-bot --only-formulae Formula/aoflagger.rb Formula/birli.rb + - run: + brew tap mwatelescope/tap + brew audit --strict --new mwatelescope/tap/cfitsio_reentrant mwatelescope/tap/casacore-data mwatelescope/tap/casacore mwatelescope/tap/aoflagger mwatelescope/tap/birli - name: Get version number from current date run: echo "DATE=$(date +'v%Y.%m.%d.%H.%M')" | tee -a "$GITHUB_ENV" - - name: get archive names id: archive_names run: | # build casacore source first - brew install --build-from-source Formula/casacore.rb - brew install --build-from-source Formula/cfitsio_reentrant.rb - for package in aoflagger birli; do - brew install --build-bottle Formula/$package.rb + for package in cfitsio_reentrant casacore-data casacore aoflagger birli; do + brew install --formula --build-bottle Formula/$package.rb brew bottle --json Formula/$package.rb echo "${package}_path=$(ls ${package}--*.bottle*.tar.gz)" | tee -a "$GITHUB_ENV" done diff --git a/Formula/birli.rb b/Formula/birli.rb index 377b459..9c3a7c2 100644 --- a/Formula/birli.rb +++ b/Formula/birli.rb @@ -5,7 +5,7 @@ class Birli < Formula sha256 "4b0a14f6bbd12e292d04eaa9791597a6d08f9fa044c9ba6dba8e06f796544bb9" license "MPL-2.0" - head "https://github.com/MWATelescope/Birli.git" + head "https://github.com/MWATelescope/Birli.git", branch: "main" depends_on "automake" => :build depends_on "rust" => :build @@ -23,4 +23,9 @@ def install end bin.install "target/release/birli" end + + test do + system "cargo", "test", "--locked", "--release" + system "birli", "--help" + end end diff --git a/Formula/casacore-data.rb b/Formula/casacore-data.rb new file mode 100644 index 0000000..bd40303 --- /dev/null +++ b/Formula/casacore-data.rb @@ -0,0 +1,53 @@ +# source: https://github.com/casacore/homebrew-tap/blob/e104598bbfe44e17a07d59c8bdb6a3559b527c67/Formula/casacore-data.rb +class ZtarDownloadStrategy < CurlDownloadStrategy + def stage(&block) + UnpackStrategy::Tar.new(cached_location).extract(basename:, verbose: verbose?) + chdir(&block) + end +end + +class CasacoreData < Formula + desc "Ephemerides and geodetic data for casacore measures (via Astron)" + homepage "https://github.com/casacore/casacore" + # curl ftp://anonymous@ftp.astron.nl/outgoing/Measures/ + url "ftp://anonymous@ftp.astron.nl/outgoing/Measures/WSRT_Measures_20250128-160001.ztar", using: ZtarDownloadStrategy + # curl -s 'ftp://anonymous@ftp.astron.nl/outgoing/Measures/WSRT_Measures_20250128-160001.ztar' | sha256 - + sha256 "5835e3f5458d8f88fd057044a891d26a5cbfdec9a865967b1189d4fd52140c80" + head "ftp://ftp.astron.nl/outgoing/Measures/WSRT_Measures.ztar", using: ZtarDownloadStrategy + + option "with-casapy", "Use Mac CASA.App (aka casapy) data directory if found" + + deprecated_option "use-casapy" => "with-casapy" + + APP_DIR = (Pathname.new "/Applications").freeze + CASAPY_APP_NAME = "CASA.app".freeze + CASAPY_APP_DIR = (APP_DIR / CASAPY_APP_NAME).freeze + CASAPY_DATA = (CASAPY_APP_DIR / "Contents/data").freeze + + def install + if build.with? "casapy" + if !Dir.exist? CASAPY_APP_DIR + odie "--with-casapy was specified, but #{CASAPY_APP_NAME} was not found in #{APP_DIR}" + elsif !Dir.exist? CASAPY_DATA + odie "--with-casapy was specified, but data directory not found at #{CASAPY_DATA}" + end + prefix.install_symlink CASAPY_DATA + else + (prefix / CASAPY_DATA.basename).install Dir["*"] + end + end + + def caveats + data_dir = prefix / CASAPY_DATA.basename + if File.symlink? data_dir + "Linked to CASA data directory (#{CASAPY_DATA}) from #{data_dir}" + else + "Installed latest Astron WSRT_Measures tarball to #{data_dir}" + end + end + + test do + Dir.exist? (prefix / CASAPY_DATA.basename / "ephemerides") + Dir.exist? (prefix / CASAPY_DATA.basename / "geodetic") + end +end diff --git a/Formula/casacore.rb b/Formula/casacore.rb index 36c2f31..8fba69a 100644 --- a/Formula/casacore.rb +++ b/Formula/casacore.rb @@ -1,19 +1,20 @@ +# source: https://github.com/casacore/homebrew-tap/blob/e104598bbfe44e17a07d59c8bdb6a3559b527c67/Formula/casacore.rb class Casacore < Formula desc "Suite of C++ libraries for radio astronomy data processing" homepage "https://github.com/casacore/casacore" url "https://github.com/casacore/casacore/archive/refs/tags/v3.6.1.tar.gz" sha256 "480d3340fa17e9ba67f18efbaff4bbb272a01d1f400d2295c0b6c86eb7abcf82" - head "https://github.com/casacore/casacore.git" + head "https://github.com/casacore/casacore.git", branch: "master" option "without-python", "Build without Python bindings" depends_on "cmake" => :build - depends_on "casacore/tap/casacore-data" depends_on "cfitsio_reentrant" depends_on "fftw" depends_on "gcc" # for gfortran depends_on "gsl" depends_on "hdf5" + depends_on "mwatelescope/tap/casacore-data" depends_on "ncurses" depends_on "openblas" depends_on "readline" diff --git a/Formula/cfitsio_reentrant.rb b/Formula/cfitsio_reentrant.rb index b9a1a90..7941323 100644 --- a/Formula/cfitsio_reentrant.rb +++ b/Formula/cfitsio_reentrant.rb @@ -1,11 +1,9 @@ class CfitsioReentrant < Formula desc "C access to FITS data files with optional Fortran wrappers with reentrant" - # https://heasarc.gsfc.nasa.gov/fitsio/c/c_user/node15.html homepage "https://heasarc.gsfc.nasa.gov/docs/software/fitsio/fitsio.html" url "https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-4.5.0.tar.gz" sha256 "e4854fc3365c1462e493aa586bfaa2f3d0bb8c20b75a524955db64c27427ce09" license "CFITSIO" - revision 1 livecheck do url :homepage