Commit 70cae4eb authored by Michał Siwek's avatar Michał Siwek

Implement path constants and support for path prefix

parent cbc4ca95
......@@ -9,14 +9,21 @@ require 'fileutils'
@command = ARGV[0]
@pkgName = ARGV[1]
@device = JSON.parse(File.read('./device.json'), symbolize_names: true)
CBREW_PREFIX = '/usr/local'
CBREW_LIB_PATH = CBREW_PREFIX + '/lib/cbrew/'
CBREW_CONFIG_PATH = CBREW_PREFIX + '/etc/cbrew/'
CBREW_BREW_DIR = CBREW_PREFIX + '/tmp/cbrew/'
$LOAD_PATH.push CBREW_LIB_PATH
@device = JSON.parse(File.read(CBREW_CONFIG_PATH + 'device.json'), symbolize_names: true)
#symbolize also values
@device.each do |key, elem|
@device[key] = @device[key].to_sym rescue @device[key]
end
def setPkg (pkgName, silent = false)
require './packages/' + pkgName
require 'packages/' + pkgName
@pkg = Object.const_get(pkgName.capitalize)
@pkg.name = pkgName
puts "Found #{pkgName}, version #{@pkg.version}" unless silent
......@@ -41,8 +48,10 @@ def download
end
uri = URI.parse url
filename = File.basename(uri.path)
system('wget', '--content-disposition', url)
abort 'Checksum mismatch :/ try again' unless Digest::SHA1.hexdigest( File.read("./#{filename}") ) == @pkg.binary_sha1[@device[:architecture]]
Dir.chdir CBREW_BREW_DIR do
system('wget', '--content-disposition', url)
abort 'Checksum mismatch :/ try again' unless Digest::SHA1.hexdigest( File.read("./#{filename}") ) == @pkg.binary_sha1[@device[:architecture]]
end
puts "Archive downloaded"
return {source: source, filename: filename}
end
......@@ -119,15 +128,28 @@ def install
puts "Installing..."
#system "mv", "./usr/*", "./xd"
FileUtils.mv './dlist', "./meta/#{@pkg.name}.directorylist"
FileUtils.mv './filelist', "./meta/#{@pkg.name}.filelist"
Dir.chdir CBREW_BREW_DIR do
FileUtils.mv './dlist', CBREW_CONFIG_PATH + "meta/#{@pkg.name}.directorylist"
FileUtils.mv './filelist', CBREW_CONFIG_PATH + "meta/#{@pkg.name}.filelist"
end
Dir.chdir CBREW_CONFIG_PATH do
File.open("meta/#{@pkg.name}.directorylist").each_line do |line|
system "mkdir", "-p", line.chomp
end
File.open("meta/#{@pkg.name}.filelist").each_line do |line|
Dir.chdir CBREW_BREW_DIR do
system "mv", '.' + line.chomp, line.chomp
end
end
end
end
end
#add to installed packages
@device[:installed_packages].push(name: @pkg.name, version: @pkg.version)
File.open('./device.json', 'w') do |file|
File.open(CBREW_CONFIG_PATH + 'device.json', 'w') do |file|
output = JSON.parse @device.to_json
file.write JSON.pretty_generate(output)
end
......@@ -141,29 +163,31 @@ def remove
end
unless @pkg.is_fake?
File.open("./meta/#{@pkg.name}.filelist").each_line do |line|
begin
File.unlink '.' + line.chomp
rescue => exception #swallow exception
Dir.chdir CBREW_CONFIG_PATH do
File.open("meta/#{@pkg.name}.filelist").each_line do |line|
begin
File.unlink '.' + line.chomp
rescue => exception #swallow exception
end
end
end
File.readlines("./meta/#{@pkg.name}.directorylist").reverse.each do |line|
begin
Dir.rmdir '.' + line.chomp
rescue => exception #swallow exception
File.readlines("meta/#{@pkg.name}.directorylist").reverse.each do |line|
begin
Dir.rmdir '.' + line.chomp
rescue => exception #swallow exception
end
end
end
File.unlink "./meta/#{@pkg.name}.filelist"
File.unlink "./meta/#{@pkg.name}.directorylist"
File.unlink "meta/#{@pkg.name}.filelist"
File.unlink "meta/#{@pkg.name}.directorylist"
end
end
#remove from installed packages
@device[:installed_packages].each do |elem|
@device[:installed_packages].delete elem if elem[:name] == @pkg.name
end
File.open('./device.json', 'w') do |file|
File.open(CBREW_CONFIG_PATH + 'device.json', 'w') do |file|
out = JSON.parse @device.to_json
file.write JSON.pretty_generate(out)
end
......
https://dl.dropboxusercontent.com/s/u3cp7mpdyfx99ij/binutils-2.23.2-chromeos-i686.tar.gz?token_hash=AAGsFB9HXNb5tSAm_Wd2GyIUL59BkZYgMTHkj4CkHLxggg&dl=1
https://dl.dropboxusercontent.com/s/c06pcge8ogsqfcd/gcc-4.8.1-baseline-chromeos-i686.tar.gz?token_hash=AAFLnE_8iL_lAnGtAAVM5G_sYqejA44jGW8D9r0a8xCjrQ&dl=1
https://dl.dropboxusercontent.com/s/dic47f8eqxhpf89/glibc-2.17.90-baseline-chromeos-i686.tar.gz?token_hash=AAHx_77YtWLLnkjCJRaCJt7RsdKrfkT6lgKS9BZc4O-0Pg&dl=1
https://dl.dropboxusercontent.com/s/9cwila1kaomsyl2/gmp-5.1.2-chromeos-i686.tar.gz?token_hash=AAHO9VxBpvXU2GPWBwimsp4hL8DADIItfNnIaFbfcyynMg&dl=1
https://dl.dropboxusercontent.com/s/3o6uc8n4uy3oved/mpc-1.0.1-chromeos-i686.tar.gz?token_hash=AAH_OlvQWGUF7lyFhV3DXXgYRM1fupgKoHIwyiVmmVyWUQ&dl=1
https://dl.dropboxusercontent.com/s/lo9ks3g7ar3zpfu/mpfr-3.1.2-chromeos-i686.tar.gz?token_hash=AAH1GlLfYtUs4uxl1ayeGTBe8RJ5uTXzOAsXgSlv8G5rrA&dl=1
https://dl.dropboxusercontent.com/s/mdzdoyq7dtnz682/linux-headers-3.4.0-chromeos-i686.tar.gz?token_hash=AAE4yw5oH_SfZ3lAx02mFP603rnjmoB9Gp4vqTY14NsA-A&dl=1
https://dl.dropboxusercontent.com/s/f6pg4bkg6m3vn7q/make-3.82-chromeos-i686.tar.gz?token_hash=AAHP__I3leN8BCLdP0pLbkNopoFGGhDuKX0sN-I6Zx4JYg&dl=1
#cd to /usr/local so we are certain we are able to execute stuff (certain partitions are mounted with no execute privileges)
echo "Changing working directory to /usr/local"
cd /usr/local
#create installation directory and cd into it
echo "Creating installation directory (/usr/local/chromebrew_install)"
mkdir chromebrew_install
cd chromebrew_install
#download installation files
echo "Downloading installation files"
wget https://raw.github.com/skycocker/chromebrew/master/$(uname -m)_links
wget https://raw.github.com/skycocker/chromebrew/master/lib_files_already_present_in_system_list
#download precompiled core tarballs
echo "Downloading core tarballs (this may take a while)"
for url in $(cat $(uname -m)_links)
do
wget --content-disposition $url
done
#extract tarballs
echo "Extracting core tarballs (this may take a while)..."
for tarball in *.tar.gz
do
tar -xf $tarball
done
#install tarballs content
echo "Installing core files..."
cp -r usr/* /usr
#this is sort of an ugly hack, fix if you feel like it's worth your time :p
echo "Creating symlinks..."
ln -s /usr/local/lib/libmpc.so.3 /usr/local/lib/libmpc.so.2
#link already present files to avoid conflicts
for filename in $(cat lib_files_already_present_in_system_list)
do
ln -s /lib/$filename /usr/local/lib/$filename
done
#check if gcc installation succeeded
if [ -f /usr/local/bin/gcc ]; then
echo "Installation complete! You can now run gcc :)"
else
echo "An unexpected error occured :/"
fi
require './lib/package_helpers'
require 'package_helpers'
class Package
property :version, :binary_url, :binary_sha1, :source_url, :is_fake
......
ld-linux.so.2
libanl.so.1
libBrokenLocale.so.1
libcidn.so.1
libcrypt.so.1
libc.so.6
libdl.so.2
libmemusage.so
libm.so.6
libnsl.so.1
libnss_compat.so.2
libnss_db.so.2
libnss_dns.so.2
libnss_files.so.2
libnss_hesiod.so.2
libnss_nisplus.so.2
libnss_nis.so.2
libpcprofile.so
libpthread.so.0
libresolv.so.2
librt.so.1
libSegFault.so
libthread_db-1.0.so
libthread_db.so.1
libutil.so.1
module.exports =
version: "2.23.2"
binary_url: "https://dl.dropboxusercontent.com/s/u3cp7mpdyfx99ij/binutils-2.23.2-chromeos-i686.tar.gz?token_hash=AAGsFB9HXNb5tSAm_Wd2GyIUL59BkZYgMTHkj4CkHLxggg&dl=1"
binary_sha1: "a7edc9bdaf9fc72112fe6b370f158a9a1aee87ac"
require './lib/package'
require 'package'
class Binutils < Package
version '2.12'
......
require './lib/package'
require 'package'
class Buildessential < Package
version '1.0'
......
module.exports =
version: "4.8.1-baseline"
binary_url: "https://dl.dropboxusercontent.com/s/c06pcge8ogsqfcd/gcc-4.8.1-baseline-chromeos-i686.tar.gz?token_hash=AAFLnE_8iL_lAnGtAAVM5G_sYqejA44jGW8D9r0a8xCjrQ&dl=1"
binary_sha1: "d720c9a804d26728d730b93748072ffa6df7ee3d"
dependencies: [
"binutils"
"gmp"
"mpc"
"mpfr"
]
require './lib/package'
require 'package'
class Gcc < Package
version '4.8.1-baseline'
......
module.exports =
version: "2.17.90-baseline"
binary_url: "https://dl.dropboxusercontent.com/s/dic47f8eqxhpf89/glibc-2.17.90-baseline-chromeos-i686.tar.gz?token_hash=AAHx_77YtWLLnkjCJRaCJt7RsdKrfkT6lgKS9BZc4O-0Pg&dl=1"
binary_sha1: "defebdeeafd71c40193debf3b786938399ece844"
require './lib/package'
require 'package'
class Glibc < Package
version '2.17.90-baseline'
......@@ -6,6 +6,6 @@ class Glibc < Package
i686: "https://dl.dropboxusercontent.com/s/dic47f8eqxhpf89/glibc-2.17.90-baseline-chromeos-i686.tar.gz?token_hash=AAHx_77YtWLLnkjCJRaCJt7RsdKrfkT6lgKS9BZc4O-0Pg&dl=1"
})
binary_sha1 ({
i686: "defebdeeafd71c40193debf3b786938399ece844"
i686: "3c3a0b86ed4591ec59daeb24d2dcda139574de1b"
})
end
module.exports =
version: "5.1.2"
binary_url: "https://dl.dropboxusercontent.com/s/9cwila1kaomsyl2/gmp-5.1.2-chromeos-i686.tar.gz?token_hash=AAHO9VxBpvXU2GPWBwimsp4hL8DADIItfNnIaFbfcyynMg&dl=1"
binary_sha1: "b03b9508463588bfe9d09303c0725068cddd8810"
require './lib/package'
require 'package'
class Gmp < Package
version "5.1.2"
......
module.exports =
version: "3.4.0"
binary_url: "https://dl.dropboxusercontent.com/s/mdzdoyq7dtnz682/linux-headers-3.4.0-chromeos-i686.tar.gz?token_hash=AAE4yw5oH_SfZ3lAx02mFP603rnjmoB9Gp4vqTY14NsA-A&dl=1"
binary_sha1: "31c933f3a4e82fd9310b0f5b32d79c9a51514fee"
require './lib/package'
require 'package'
class Linuxheaders < Package
version '3.4.0'
......
module.exports =
version: "3.82"
binary_url: "https://dl.dropboxusercontent.com/s/f6pg4bkg6m3vn7q/make-3.82-chromeos-i686.tar.gz?token_hash=AAHP__I3leN8BCLdP0pLbkNopoFGGhDuKX0sN-I6Zx4JYg&dl=1"
binary_sha1: "86321098f3f31daa49abb1bb38045dffb1f168b4"
require './lib/package'
require 'package'
class Make < Package
version '3.82'
......
module.exports =
version: "1.0.1"
binary_url: "https://dl.dropboxusercontent.com/s/3o6uc8n4uy3oved/mpc-1.0.1-chromeos-i686.tar.gz?token_hash=AAH_OlvQWGUF7lyFhV3DXXgYRM1fupgKoHIwyiVmmVyWUQ&dl=1"
binary_sha1: "86321098f3f31daa49abb1bb38045dffb1f168b4"
dependencies: [
"mpfr"
"gmp"
]
require './lib/package'
require 'package'
class Mpc < Package
version '1.0.1'
......@@ -6,6 +6,6 @@ class Mpc < Package
i686: "https://dl.dropboxusercontent.com/s/3o6uc8n4uy3oved/mpc-1.0.1-chromeos-i686.tar.gz?token_hash=AAH_OlvQWGUF7lyFhV3DXXgYRM1fupgKoHIwyiVmmVyWUQ&dl=1"
})
binary_sha1 ({
i686: "86321098f3f31daa49abb1bb38045dffb1f168b4"
i686: "f11c6e74e9059bf400b0978e6e05fe67c7f3dfe9"
})
end
module.exports =
version: "3.1.2"
binary_url: "https://dl.dropboxusercontent.com/s/lo9ks3g7ar3zpfu/mpfr-3.1.2-chromeos-i686.tar.gz?token_hash=AAH1GlLfYtUs4uxl1ayeGTBe8RJ5uTXzOAsXgSlv8G5rrA&dl=1"
binary_sha1: "eb81b9bb83ebb43b94ab33e43293f1df3bcbad7c"
require './lib/package'
require 'package'
class Mpfr < Package
version '3.1.2'
......
require './packages/buildessential'
#require './packages/buildessential'
require 'json'
require 'pathname'
......@@ -7,4 +7,15 @@ require 'pathname'
@device[key] = @device[key].to_sym rescue @device[key]
end
@device[:installed_packages].any? { |pkg| pkg[:name] == 'gcc' }
Dir.chdir './meta' do
File.open("make.directorylist").each_line do |line|
#puts line
system "mkdir -p " + line.chomp
end
File.open("make.filelist").each_line do |line|
Dir.chdir '../tmp' do
system "mv", '.' + line.chomp, line.chomp
end
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