Skip to content

Commit

Permalink
feat: pkg for RHEL
Browse files Browse the repository at this point in the history
  • Loading branch information
SMillerDev committed Aug 22, 2023
1 parent cf2fd16 commit f490e0f
Show file tree
Hide file tree
Showing 2 changed files with 131 additions and 0 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/build-pkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ on:
paths:
- .github/workflows/build-pkg.yml
- package/**/*
- package/*
pull_request:
paths:
- .github/workflows/build-pkg.yml
- package/**/*
- package/*
release:
types:
- published
Expand Down Expand Up @@ -172,3 +178,70 @@ jobs:
run: gh release upload --repo Homebrew/brew
"${GITHUB_REF//refs\/tags\//}"
Homebrew-${{ steps.print-version.outputs.version }}.pkg
build-rpm:
# if: github.repository_owner == 'Homebrew'
runs-on: ubuntu-latest
container:
image: almalinux:8
permissions:
# To write assets to GitHub release
contents: write
env:
HOMEBREW_NO_ANALYTICS_THIS_RUN: 1
HOMEBREW_NO_ANALYTICS_MESSAGE_OUTPUT: 1
steps:
- name: Checkout Homebrew
uses: actions/checkout@v3
with:
path: brew
fetch-depth: 0

- name: Get Homebrew version from Git
id: print-version
run: echo "version=$(git -C brew describe --tags --always)" >> "${GITHUB_OUTPUT}"

- name: Setup build environment
run: |
echo "%_topdir ${{ github.workspace }}/rpmbuild" > "$HOME/.rpmmacros"
mkdir -p "${{ github.workspace }}/rpmbuild/"{SOURCES,SPECS,BUILD,BUILDROOT,RPMS,SRPMS}
cp brew/package/homebrew.spec "${{ github.workspace }}/rpmbuild/SPECS/"
- name: Create source tar
run: |
tar czvf ${{ github.workspace }}/rpmbuild/SOURCES/brew-${{ steps.print-version.outputs.version }}.tar.gz brew/
- run: git -C brew describe --tags --always
- run: ls -al ${{ github.workspace }}/rpmbuild/SOURCES/
- run: ls -al ${{ github.workspace }}/rpmbuild/SPECS/

- run: dnf install -y ruby git rpm-build

- name: Build Homebrew package
run: rpmbuild -ba ${{ github.workspace }}/rpmbuild/SPECS/homebrew.spec --define='version ${{ steps.print-version.outputs.version }}'

- name: Install package
working-directory: ${{ github.workspace }}/rpmbuild
run: rpm -i RPMS/*/homebrew-*.rpm

- run: /home/linuxbrew/.linuxbrew/bin/brew shellenv

- run: brew config

- run: brew doctor

- name: Upload installer to GitHub Actions
uses: actions/upload-artifact@v3
with:
name: Homebrew ${{ steps.print-version.outputs.version }} rpms
path: "${{ github.workspace }}/rpmbuild/*RPMS/*/homebrew-${{ steps.print-version.outputs.version }}*.rpm"

# - name: Install gh
# run: brew install gh

# - name: Upload installer to GitHub release
# if: startsWith(github.ref, 'refs/tags/')
# env:
# GH_TOKEN: ${{ github.token }}
# run: gh release upload --repo Homebrew/brew
# "${GITHUB_REF//refs\/tags\//}"
# Homebrew-${{ steps.print-version.outputs.version }}.pkg
58 changes: 58 additions & 0 deletions package/homebrew.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
Summary: Homebrew package manager
Name: homebrew
Version: 0.0.1
Release: 1
License: BSD-2-clause
Group: Development/Tools
Source: https://github.com/Homebrew/brew/archive/refs/tags/%{version}.tar.gz
%define homebrew_user linuxbrew
%define homebrew_directory /home/%{homebrew_user}/.%{homebrew_user}

# See: https://github.com/Homebrew/install/blob/master/install.sh#L211-L214
BuildRequires: git
Requires: git>=2.7.0
Requires: glibc>=2.13
Requires: ruby>=2.6.0

%description
The Missing Package Manager for macOS (or Linux)

%prep
%autosetup -n brew-%{version}

%build
git init
git remote add origin https://github.com/Homebrew/brew
git fetch --tags --set-upstream origin

%install
install -d "$RPM_BUILD_ROOT%{homebrew_directory}"
cp -r bin "$RPM_BUILD_ROOT%{homebrew_directory}"
cp -r completions "$RPM_BUILD_ROOT%{homebrew_directory}"
cp -r manpages "$RPM_BUILD_ROOT%{homebrew_directory}"
cp -r .git "$RPM_BUILD_ROOT%{homebrew_directory}"
cp -r *.md "$RPM_BUILD_ROOT%{homebrew_directory}"
cp -r *.txt "$RPM_BUILD_ROOT%{homebrew_directory}"
cp -rd Library "$RPM_BUILD_ROOT%{homebrew_directory}"

pushd "$RPM_BUILD_ROOT%{homebrew_directory}"
mkdir -vp Cellar Frameworks etc include lib opt sbin share var/homebrew/linked

%check
export HOMEBREW_NO_ANALYTICS_THIS_RUN=1
export HOMEBREW_NO_ANALYTICS_MESSAGE_OUTPUT=1
%{homebrew_directory}/bin/brew config
%{homebrew_directory}/bin/brew doctor

%pre
getent passwd %{homebrew_user} >/dev/null || \
useradd -r -d %{homebrew_directory} -s /sbin/nologin \
-c "The Homebrew default user" %{homebrew_user}
chown -R "%{homebrew_user}" %{homebrew_directory}

%files
%{homebrew_directory}
%license %{homebrew_directory}/LICENSE.txt
%doc %{homebrew_directory}/CHANGELOG.md %{homebrew_directory}/CONTRIBUTING.md %{homebrew_directory}/README.md

%changelog

0 comments on commit f490e0f

Please sign in to comment.