Commit 826b2fc7 authored by William Turner's avatar William Turner Committed by Ed Reel

Rework the vim packages to better handle config (#3001)

parent 3eb169fd
require 'package' require 'package'
class Gvim < Package class Gvim < Package
description 'gVim is a highly configurable text editor built to make creating and changing any kind of text very efficient.' description 'Vim is a highly configurable text editor built to make creating and changing any kind of text very efficient. (with advanced features, such as a GUI)'
homepage 'http://www.vim.org/' homepage 'http://www.vim.org/'
version '8.1-1' version '8.1.0648'
source_url 'ftp://ftp.vim.org/pub/vim/unix/vim-8.1.tar.bz2' source_url 'https://github.com/vim/vim/archive/v8.1.0648.tar.gz'
source_sha256 '8b69fbd01c877dd8ecbbeca1dc66e5e927228d631ac4c2174b9307eb5c827c86' source_sha256 '7e6ad44dbb8fda0aca91c22fa0dcaed2d845cf00c26d6d3df3bfaa38c9da222a'
binary_url ({ binary_url ({
aarch64: 'https://dl.bintray.com/chromebrew/chromebrew/gvim-8.1-1-chromeos-armv7l.tar.xz',
armv7l: 'https://dl.bintray.com/chromebrew/chromebrew/gvim-8.1-1-chromeos-armv7l.tar.xz',
i686: 'https://dl.bintray.com/chromebrew/chromebrew/gvim-8.1-1-chromeos-i686.tar.xz',
x86_64: 'https://dl.bintray.com/chromebrew/chromebrew/gvim-8.1-1-chromeos-x86_64.tar.xz',
}) })
binary_sha256 ({ binary_sha256 ({
aarch64: 'fdda85b0be941d9043acf35f166b7c95457ab96d04c8a3c82b96c7bc6314f99e',
armv7l: 'fdda85b0be941d9043acf35f166b7c95457ab96d04c8a3c82b96c7bc6314f99e',
i686: 'dcf0668bbabdd5623ed6481c3e1503a52df398771fe3c9fa64a1f58d1cb0ed95',
x86_64: 'd8fb8c1ee73295d0e7646235c012f1785c38a67c46db18846faf33b89384cdfc',
}) })
depends_on 'vim' depends_on 'python27' => :build
depends_on 'gtk2' depends_on 'python3' => :build
depends_on 'vim_runtime'
depends_on 'gtk3'
depends_on 'sommelier' depends_on 'sommelier'
def self.patch
# set the system-wide vimrc path
FileUtils.cd('src') do
system "sed", "-i", "s|^.*#define SYS_VIMRC_FILE.*$|#define SYS_VIMRC_FILE \"#{CREW_PREFIX}/etc/vimrc\"|", "feature.h"
system "sed", "-i", "s|^.*#define SYS_GVIMRC_FILE.*$|#define SYS_GVIMRC_FILE \"#{CREW_PREFIX}/etc/gvimrc\"|", "feature.h"
system "autoconf"
end
end
def self.build def self.build
system "./configure \ system "./configure",
--prefix=#{CREW_PREFIX} \ "--prefix=#{CREW_PREFIX}",
--disable-nls \ "--localstatedir=#{CREW_PREFIX}/var/lib/vim",
--enable-gui \ "--with-features=huge",
--with-x \ "--with-compiledby='Chromebrew'",
--enable-fontset \ "--with-x=yes",
--enable-multibyte \ "--enable-gui=gtk3",
--with-tlib=ncurses \ "--enable-multibyte",
--enable-perlinterp \ "--enable-cscope",
--enable-python3interp \ "--enable-fontset",
--enable-rubyinterp \ "--enable-perlinterp=dynamic",
--with-python3-command=#{CREW_PREFIX}/bin/python3 \ "--enable-pythoninterp=dynamic",
--with-ruby-command=#{CREW_PREFIX}/bin/ruby \ "--enable-python3interp=dynamic",
--with-features=huge \ "--enable-rubyinterp=dynamic",
--disable-selinux" "--disable-selinux"
system 'make' system "make"
end end
def self.install def self.install
tmpdir = "#{CREW_PREFIX}/tmp/vim" system "make", "VIMRCLOC=#{CREW_PREFIX}/etc", "DESTDIR=#{CREW_DEST_DIR}", "install"
configdir = "#{CREW_PREFIX}/.config/vim"
configdestdir = "#{CREW_DEST_PREFIX}/.config/vim"
system "make", "DESTDIR=#{CREW_DEST_DIR}", "install"
FileUtils.mkdir_p "#{tmpdir}"
system "cp #{CREW_DEST_PREFIX}/bin/evi* #{tmpdir}"
system "cp #{CREW_DEST_PREFIX}/bin/*gvi* #{tmpdir}"
system "cp #{CREW_DEST_PREFIX}/share/man/man1/evi*.1 #{tmpdir}"
system "cp #{CREW_DEST_PREFIX}/share/man/man1/*gvi*.1 #{tmpdir}"
system "cp #{CREW_DEST_PREFIX}/share/vim/vim81/gvimrc_example.vim #{tmpdir}"
system "rm -rf #{CREW_DEST_PREFIX}"
FileUtils.mkdir_p "#{CREW_DEST_PREFIX}/bin"
FileUtils.mkdir_p "#{CREW_DEST_PREFIX}/share/man/man1"
FileUtils.mkdir_p "#{CREW_DEST_PREFIX}/share/vim/vim81"
system "mv #{tmpdir}/gvimrc_example.vim #{CREW_DEST_PREFIX}/share/vim/vim81"
system "mv #{tmpdir}/*.1 #{CREW_DEST_PREFIX}/share/man/man1"
system "mv #{tmpdir}/* #{CREW_DEST_PREFIX}/bin"
system "rm -rf #{tmpdir}"
system "compressdoc --gzip -9 #{CREW_DEST_PREFIX}/share/man/man1" system "compressdoc --gzip -9 #{CREW_DEST_PREFIX}/share/man/man1"
FileUtils.mkdir_p "#{configdestdir}"
FileUtils.mkdir_p "#{CREW_DEST_HOME}" # these are provided by 'vim_runtime'
system "touch #{configdir}/gvimrc #{configdestdir}/gvimrc" system "rm", "-r", "#{CREW_DEST_PREFIX}/share/vim"
system "ln -s #{configdir}/gvimrc #{CREW_DEST_HOME}/.gvimrc"
end end
def self.postinstall def self.postinstall
configdir = "#{CREW_PREFIX}/.config/vim"
system "cp #{CREW_PREFIX}/share/vim/vim81/gvimrc_example.vim #{configdir}/gvimrc" unless File.size? "#{configdir}/gvimrc"
puts puts
puts "To finish the installation, execute the following:".lightblue puts "The config files are located in #{CREW_PREFIX}/etc".lightblue
puts "echo '# Fixes Warning: Missing charsets in String to FontSet conversion' >> ~/.bashrc".lightblue puts "User-specific configuration should go in ~/.gvimrc".lightblue
puts "echo 'export LC_ALL=C' >> ~/.bashrc && . ~/.bashrc".lightblue
puts puts
puts "The config files are located in $HOME/.vim".lightblue puts "If you are upgrading from an earlier version, edit ~/.bashrc".orange
puts "and remove the 'export VIMRUNTIME' and 'export LC_ALL=C' lines.".orange
puts puts
end end
end end
...@@ -3,79 +3,67 @@ require 'package' ...@@ -3,79 +3,67 @@ require 'package'
class Vim < Package class Vim < Package
description 'Vim is a highly configurable text editor built to make creating and changing any kind of text very efficient.' description 'Vim is a highly configurable text editor built to make creating and changing any kind of text very efficient.'
homepage 'http://www.vim.org/' homepage 'http://www.vim.org/'
version '8.1-1' version '8.1.0648'
source_url 'ftp://ftp.vim.org/pub/vim/unix/vim-8.1.tar.bz2' source_url 'https://github.com/vim/vim/archive/v8.1.0648.tar.gz'
source_sha256 '8b69fbd01c877dd8ecbbeca1dc66e5e927228d631ac4c2174b9307eb5c827c86' source_sha256 '7e6ad44dbb8fda0aca91c22fa0dcaed2d845cf00c26d6d3df3bfaa38c9da222a'
binary_url ({ binary_url ({
aarch64: 'https://dl.bintray.com/chromebrew/chromebrew/vim-8.1-1-chromeos-armv7l.tar.xz',
armv7l: 'https://dl.bintray.com/chromebrew/chromebrew/vim-8.1-1-chromeos-armv7l.tar.xz',
i686: 'https://dl.bintray.com/chromebrew/chromebrew/vim-8.1-1-chromeos-i686.tar.xz',
x86_64: 'https://dl.bintray.com/chromebrew/chromebrew/vim-8.1-1-chromeos-x86_64.tar.xz',
}) })
binary_sha256 ({ binary_sha256 ({
aarch64: '7dea736a534604b7356a2056097b13bb67804a9b7281ffae6d8462daa4596096',
armv7l: '7dea736a534604b7356a2056097b13bb67804a9b7281ffae6d8462daa4596096',
i686: '67422ff9eed379c72a8ce63ee214a5141aee420f187752838efc9c4ade8ffce9',
x86_64: '6ebd581a5d978985b1eb8c5fe12fafb8e659e94a311a46a047f0eab2d6e4251b',
}) })
depends_on 'python3' depends_on 'python27' => :build
depends_on 'xdg_base' depends_on 'python3' => :build
depends_on 'vim_runtime'
def self.preinstall def self.patch
configdir = "#{CREW_PREFIX}/.config" # set the system-wide vimrc path
# Save any previous configuration, if it exists. FileUtils.cd('src') do
if Dir.exists? "$HOME/.vim" system "sed", "-i", "s|^.*#define SYS_VIMRC_FILE.*$|#define SYS_VIMRC_FILE \"#{CREW_PREFIX}/etc/vimrc\"|", "feature.h"
system "cp -r $HOME/.vim #{configdir}" system "sed", "-i", "s|^.*#define SYS_GVIMRC_FILE.*$|#define SYS_GVIMRC_FILE \"#{CREW_PREFIX}/etc/gvimrc\"|", "feature.h"
system "mv #{configdir}/.vim #{configdir}/vim" system "autoconf"
system "rm -rf $HOME/.vim"
end
if File.exists? "$HOME/.vimrc"
system "cp $HOME/.vimrc #{configdir}/vim/vimrc"
end end
end end
def self.build def self.build
system "./configure \ system "./configure",
--prefix=#{CREW_PREFIX} \ "--prefix=#{CREW_PREFIX}",
--enable-gui=no \ "--localstatedir=#{CREW_PREFIX}/var/lib/vim",
--without-x \ "--with-features=huge",
--disable-nls \ "--with-compiledby='Chromebrew'",
--enable-multibyte \ "--with-x=no",
--with-tlib=ncurses \ "--disable-gui",
--enable-perlinterp \ "--enable-multibyte",
--enable-python3interp \ "--enable-cscope",
--enable-rubyinterp \ "--enable-fontset",
--with-python3-command=#{CREW_PREFIX}/bin/python3 \ "--enable-perlinterp=dynamic",
--with-ruby-command=#{CREW_PREFIX}/bin/ruby \ "--enable-pythoninterp=dynamic",
--with-features=huge \ "--enable-python3interp=dynamic",
--disable-selinux" "--enable-rubyinterp=dynamic",
system 'make' "--disable-selinux"
system "make"
end end
def self.install def self.install
configdir = "#{CREW_PREFIX}/.config/vim" system "make", "DESTDIR=#{CREW_DEST_DIR}", "VIMRCLOC=#{CREW_PREFIX}/etc", "install"
configdestdir = "#{CREW_DEST_PREFIX}/.config/vim"
system "make", "DESTDIR=#{CREW_DEST_DIR}", "install"
system "compressdoc --gzip -9 #{CREW_DEST_PREFIX}/share/man/man1" system "compressdoc --gzip -9 #{CREW_DEST_PREFIX}/share/man/man1"
FileUtils.mkdir_p "#{configdestdir}"
system "cp -r #{CREW_DEST_PREFIX}/share/vim/vim81/* #{configdestdir}" # these are provided by 'vim_runtime'
FileUtils.mkdir_p "#{CREW_DEST_HOME}" system "rm", "-r", "#{CREW_DEST_PREFIX}/share/vim"
FileUtils.mkdir_p "#{configdir}" unless Dir.exists? "#{configdir}"
system "ln -s #{configdir} #{CREW_DEST_HOME}/.vim" # remove desktop and icon files for the cli package
system "ln -s #{configdir}/vimrc #{CREW_DEST_HOME}/.vimrc" system "rm", "-r", "#{CREW_DEST_PREFIX}/share/applications"
system "touch #{configdir}/vimrc #{configdestdir}/vimrc" system "rm", "-r", "#{CREW_DEST_PREFIX}/share/icons"
end end
def self.postinstall def self.postinstall
configdir = "#{CREW_PREFIX}/.config/vim"
system "cp #{CREW_PREFIX}/share/vim/vim81/vimrc_example.vim #{configdir}/vimrc" unless File.size? "#{configdir}/vimrc"
puts puts
puts "To finish the installation, execute the following:".lightblue puts "The config files are located in #{CREW_PREFIX}/etc".lightblue
puts "echo 'export VIMRUNTIME=$HOME/.vim' >> ~/.bashrc && . ~/.bashrc".lightblue puts "User-specific configuration should go in ~/.vimrc".lightblue
puts puts
puts "The config files are located in $HOME/.vim".lightblue puts "If you are upgrading from an earlier version, edit ~/.bashrc".orange
puts "and remove the 'export VIMRUNTIME' line.".orange
puts puts
end end
end end
require 'package'
class Vim_runtime < Package
description 'Vim is a highly configurable text editor built to make creating and changing any kind of text very efficient. (shared runtime)'
homepage 'http://www.vim.org/'
version '8.1.0648'
source_url 'https://github.com/vim/vim/archive/v8.1.0648.tar.gz'
source_sha256 '7e6ad44dbb8fda0aca91c22fa0dcaed2d845cf00c26d6d3df3bfaa38c9da222a'
binary_url ({
})
binary_sha256 ({
})
depends_on 'python27' => :build
depends_on 'python3' => :build
def self.patch
# set the system-wide vimrc path
FileUtils.cd('src') do
system "sed", "-i", "s|^.*#define SYS_VIMRC_FILE.*$|#define SYS_VIMRC_FILE \"#{CREW_PREFIX}/etc/vimrc\"|", "feature.h"
system "sed", "-i", "s|^.*#define SYS_GVIMRC_FILE.*$|#define SYS_GVIMRC_FILE \"#{CREW_PREFIX}/etc/gvimrc\"|", "feature.h"
system "autoconf"
end
end
def self.build
system "./configure",
"--prefix=#{CREW_PREFIX}",
"--localstatedir=#{CREW_PREFIX}/var/lib/vim",
"--with-features=huge",
"--with-compiledby='Chromebrew'",
"--with-x=no",
"--disable-gui",
"--enable-multibyte",
"--enable-cscope",
"--enable-fontset",
"--enable-perlinterp=dynamic",
"--enable-pythoninterp=dynamic",
"--enable-python3interp=dynamic",
"--enable-rubyinterp=dynamic",
"--disable-selinux"
system "make"
end
def self.install
system "make", "VIMRCLOC=#{CREW_PREFIX}/etc", "DESTDIR=#{CREW_DEST_DIR}", "install"
# bin and man will be provided by the 'vim' packages
system "rm", "-r", "#{CREW_DEST_PREFIX}/bin"
system "rm", "-r", "#{CREW_DEST_PREFIX}/share/man"
# remove desktop and icon files for the terminal package
system "rm", "-r", "#{CREW_DEST_PREFIX}/share/applications"
system "rm", "-r", "#{CREW_DEST_PREFIX}/share/icons"
# add sane defaults and simulate some XDG support
FileUtils.mkdir_p("#{CREW_DEST_PREFIX}/share/vim/vimfiles")
File.write("#{CREW_DEST_PREFIX}/share/vim/vimfiles/chromebrew.vim", <<~EOF)
" Global vimrc - setting some sane defaults
"
" DO NOT EDIT THIS FILE. IT'S OVERWRITTEN UPON UPGRADES.
"
" Use #{CREW_PREFIX}/etc/vimrc for system-wide and ~/.vimrc for personal
" configuration.
" Use Vim defaults instead of 100% vi compatibility
" Avoid side-effects when nocompatible has already been set.
if &compatible
set nocompatible
endif
set backspace=indent,eol,start
set ruler
set suffixes+=.aux,.bbl,.blg,.brf,.cb,.dvi,.idx,.ilg,.ind,.inx,.jpg,.log,.out,.png,.toc
set suffixes-=.h
set suffixes-=.obj
" Move temporary files to a secure location to protect against CVE-2017-1000382
if exists('$XDG_CACHE_HOME')
let &g:directory=$XDG_CACHE_HOME
else
let &g:directory=$HOME . '/.cache'
endif
let &g:undodir=&g:directory . '/vim/undo//'
let &g:backupdir=&g:directory . '/vim/backup//'
let &g:directory.='/vim/swap//'
" Create directories if they doesn't exist
if ! isdirectory(expand(&g:directory))
silent! call mkdir(expand(&g:directory), 'p', 0700)
endif
if ! isdirectory(expand(&g:backupdir))
silent! call mkdir(expand(&g:backupdir), 'p', 0700)
endif
if ! isdirectory(expand(&g:undodir))
silent! call mkdir(expand(&g:undodir), 'p', 0700)
endif
EOF
end
def self.postinstall
vimrc = "#{CREW_PREFIX}/etc/vimrc"
# keep user changes by writing to a new file
vimrc += ".new" if File.exists?(vimrc)
# by default we will load the global config
File.write(vimrc, <<~EOF)
" System-wide defaults are in #{CREW_PREFIX}/share/vim/vimfiles/chromebrew.vim
" and sourced by this file. If you wish to change any of those settings, you
" should do so at the end of this file or in your user-specific (~/.vimrc) file.
" If you do not wish to use the bundled defaults, remove the next line.
runtime! chromebrew.vim
EOF
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment