Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gnome App dbus fixes (for tag as 0.0.2) #4

Merged
merged 8 commits into from
Jul 20, 2021

Conversation

satmandu
Copy link
Member

@satmandu satmandu commented Jul 14, 2021

These are fixes for chromebrew/chromebrew#5936 once we have this tagged as 0.0.2 and we have crew_profile_base modified accordingly in an upcoming PR.

  • This sets the dbus variables appropriately and also sets a UTF-8 locale. These are needed for Gnome Apps.
  • This sets GCONV_PATH to CREW_LIB_PREFIX/gconv so that iconv works properly. (Removes need for libiconv.) (Note that this needs CREW_LIB_PREFIX set too...)
  • These can be overridden by modifying the 99-locale file if necessary.
  • Also, files are only sourced once they are confirmed to be files, and not directories. (Dev_install can drop directories into /usr/local/etc/env.d )

@satmandu satmandu changed the title 0.0.2 Gnome App dbus fixes (for tag as 0.0.2) Jul 14, 2021
@satmandu
Copy link
Member Author

satmandu commented Jul 14, 2021

Suggested PR for crew_profile_base will have this:

require 'package'

class Crew_profile_base < Package
  description 'Crew-profile-base sets up Chromebrew\'s environment capabilities.'
  homepage 'https://github.com/chromebrew/crew-profile-base'
  version '0.0.2'
  license 'GPL-3+'
  compatibility 'all'
  source_url 'SKIP'

  depends_on 'dbus'
  
  def self.install
    FileUtils.mkdir_p "#{CREW_DEST_PREFIX}/etc/env.d"
    FileUtils.mkdir_p "#{CREW_DEST_PREFIX}/etc/profile.d"
  end

  def self.postinstall
    # Extract as module in postinstall to avoid creating package binaries.
    # Turn off git warnings.
    system 'git config --global advice.detachedHead false'
    system 'git config --global init.defaultBranch main'
    @git_dir = 'crew_profile_base_git'
    @git_hash = version
    @git_url = 'https://github.com/chromebrew/crew-profile-base'
    FileUtils.rm_rf(@git_dir)
    FileUtils.mkdir_p(@git_dir)
    Dir.chdir @git_dir do
      system 'git init'
      system "git remote add origin #{@git_url}"
      system "git fetch --depth 1 origin #{@git_hash}"
      system 'git checkout FETCH_HEAD'

      # Don't overwrite custom changes
      FileUtils.rm './src/env.d/99-custom' if File.exist? "#{CREW_PREFIX}/etc/env.d/99-custom"
      FileUtils.rm './src/profile.d/99-custom' if File.exist? "#{CREW_PREFIX}/etc/profile.d/99-custom"
      # Custom changes should only go in the above two files.
      #FileUtils.rm './src/env.d/00-locale' if File.exist? "#{CREW_PREFIX}/etc/env.d/00-locale"
      #FileUtils.rm './src/env.d/01-editor' if File.exist? "#{CREW_PREFIX}/etc/env.d/01-editor"
      #FileUtils.rm './src/env.d/02-pager' if File.exist? "#{CREW_PREFIX}/etc/env.d/02-pager"

      FileUtils.mkdir_p "#{CREW_PREFIX}/etc/"
      FileUtils.cp_r Dir.glob('./src/*'), "#{CREW_PREFIX}/etc/"

      # Remove stale files from the last install
      FileUtils.rm "#{HOME}/.bashrc.bak" if File.exist? "#{HOME}/.bashrc.bak"
      FileUtils.rm "#{HOME}/.zshrc.bak" if File.exist? "#{HOME}/.zshrc.bak"

      # Don't overwrite a custom shell rc
      @_str = "source #{CREW_PREFIX}/etc/profile"

      # Write our rc files
      @crew_rcfile = <<~CREW_PROFILE_EOF
                # DO NOT DELETE THIS LINE
                # See #{CREW_PREFIX}/etc/profile for further details
                source #{CREW_PREFIX}/etc/profile

                # Put your stuff under this comment
                
      CREW_PROFILE_EOF
      # Must write directly to HOME and not CREW_DEST_HOME to prevent chromebrew from removing ~/.bashrc during reinstall
      if File.exist? "#{HOME}/.bashrc"
        if `grep -c "#{@_str}" #{HOME}/.bashrc`.to_i.zero?
          old_bashrc = IO.read "#{HOME}/.bashrc"
          IO.write "#{HOME}/.bashrc", @crew_rcfile + old_bashrc
        end
      else
        IO.write("#{HOME}/.bashrc", @crew_rcfile)
      if File.exist? "#{HOME}/.zshrc"
        if `grep -c "#{@_str}" #{HOME}/.zshrc`.to_i.zero?
          old_zshrc = IO.read "#{HOME}/.zshrc"
          IO.write "#{HOME}/.zshrc", @crew_rcfile + old_zshrc
        end
      else
        IO.write("#{HOME}/.zshrc", @crew_rcfile)
      end

      puts
      puts 'IT IS IMPERATIVE TO THE FUNCTION OF CHROMEBREW FOR'.lightblue
      puts "#{HOME}/.bashrc to contain the line 'source #{CREW_PREFIX}/etc/profile'.".lightblue
      puts 'This should have happened automatically.'.lightblue
      puts "If the line doesn't exist, add it now and report a bug at https://github.com/chromebrew/crew-profile-base/issues.".lightblue
      puts "Please put customizations in #{CREW_PREFIX}/etc/env.d/99-custom and #{CREW_PREFIX}/etc/profile.d/99-custom .".lightblue
      puts
    end
  end
end

src/env.d/03-dbus Outdated Show resolved Hide resolved
@satmandu
Copy link
Member Author

satmandu commented Jul 14, 2021 via email

@supechicken
Copy link
Member

Not a symlink...

Just do a bit research about it, /var/run might be a symlink to /run so they are same file

src/env.d/03-dbus Outdated Show resolved Hide resolved
@satmandu
Copy link
Member Author

@saltedcoffii Any comments?

@saltedcoffii
Copy link
Collaborator

It looks good to me!

@satmandu
Copy link
Member Author

@uberhacker ...

@satmandu
Copy link
Member Author

Will one of you merge and tag this as 0.0.2?

@uberhacker uberhacker merged commit 8749754 into chromebrew:master Jul 20, 2021
@satmandu satmandu deleted the 0.0.2 branch July 22, 2021 04:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants