Commit f69606f5 authored by Ed Reel's avatar Ed Reel

Update crew and install.sh to remove the need for sudo

parent 3995b637
......@@ -104,7 +104,7 @@ def update
system "git reset --hard origin/master"
end
puts "Package lists, crew, and library updated."
#check for outdated installed packages
puts "Checking for package updates..."
puts ""
......@@ -117,7 +117,7 @@ def update
puts @pkg.name + " could be updated from " + package[:version] + " to " + @pkg.version
end
end
if canBeUpdated > 0
puts ""
puts "Run 'crew upgrade' to upgrade everything or 'crew upgrade <packageName>' to upgrade a specific package."
......@@ -136,7 +136,7 @@ def upgrade
currentVersion = package[:version]
end
end
if currentVersion != @pkg.version
puts "Updating #{@pkg.name}..."
@pkg.in_upgrade = true
......@@ -153,7 +153,7 @@ def upgrade
toBeUpdated.push(package[:name])
end
end
if toBeUpdated.length > 0
puts "Updating packages..."
toBeUpdated.each do |package|
......@@ -262,11 +262,11 @@ def install_package (pkgdir)
FileUtils.mv 'filelist', CREW_CONFIG_PATH + "meta/#{@pkg.name}.filelist"
File.open(CREW_CONFIG_PATH + "meta/#{@pkg.name}.directorylist").each_line do |line|
system "sudo", "mkdir", "-p", line.chomp
system "mkdir", "-p", line.chomp
end
File.open(CREW_CONFIG_PATH + "meta/#{@pkg.name}.filelist").each_line do |line|
system "sudo", "mv", pkgdir + line.chomp, line.chomp
system "mv", pkgdir + line.chomp, line.chomp
end
end
end
......@@ -276,10 +276,10 @@ def resolve_dependencies_and_install
origin = @pkg.name
resolveDependencies
search origin, true
install
rescue InstallError => e
rescue InstallError => e
abort "#{@pkg.name} failed to install: #{e.to_s}"
ensure
#cleanup
......@@ -320,7 +320,7 @@ def resolveDependencies
end
end
end
push_dependencies
# Add buildessential and solve its dependencies if any of dependent
......@@ -330,16 +330,16 @@ def resolveDependencies
search 'buildessential', true
end
push_dependencies
return if @dependencies.empty?
puts "Following packages also need to be installed: "
@dependencies.flatten!.uniq!
@dependencies.each do |dep|
print dep + " "
end
puts ""
puts "Do you agree? [Y/n]"
response = STDIN.getc
......@@ -398,7 +398,7 @@ def install
puts "Installing..."
install_package dest_dir
end
#add to installed packages
@device[:installed_packages].push(name: @pkg.name, version: @pkg.version)
File.open(CREW_CONFIG_PATH + 'device.json', 'w') do |file|
......@@ -547,10 +547,9 @@ when "build"
search @pkgName
resolve_dependencies_and_build
when "remove"
abort 'Removing actions must be ran with sudo.' unless USER == 'root'
remove @pkgName
when nil
puts "Chromebrew, version 0.4.1"
puts "Chromebrew, version 0.4.2"
puts "Usage: crew [command] [package]"
puts "Available commands: build, download, install, remove, search, update, upgrade, whatprovides"
else
......
......@@ -25,9 +25,12 @@ case "$architecture" in
exit 1;;
esac
#This will allow things to work without sudo
sudo chown -R `id -u`:`id -g` /usr/local
#prepare directories
for dir in $CREW_LIB_PATH $CREW_CONFIG_PATH $CREW_CONFIG_PATH/meta $CREW_BREW_DIR $CREW_DEST_DIR $CREW_PACKAGES_PATH; do
sudo mkdir -p $dir && sudo chown -R $USER:$USER $dir
mkdir -p $dir
done
#prepare url and sha256
......@@ -96,7 +99,7 @@ function extract_install () {
rm -rf ./usr
tar -xf $2
echo "Installing $1 (this may take a while)..."
sudo tar cf - ./usr/* | (cd /; sudo tar xp --keep-directory-symlink -f -)
tar cf - ./usr/*
mv ./dlist $CREW_CONFIG_PATH/meta/$1.directorylist
mv ./filelist $CREW_CONFIG_PATH/meta/$1.filelist
}
......@@ -156,7 +159,7 @@ rm -rf crew lib packages
wget -N $URL/crew
chmod +x crew
rm -f $CREW_PREFIX/bin/crew
sudo ln -s `pwd`/crew $CREW_PREFIX/bin
ln -s `pwd`/crew $CREW_PREFIX/bin
#install crew library
mkdir -p $CREW_LIB_PATH/lib
cd $CREW_LIB_PATH/lib
......@@ -165,10 +168,7 @@ wget -N $URL/lib/package_helpers.rb
#Making GCC act like CC (For some npm packages out there)
rm -f /usr/local/bin/cc
sudo ln -s /usr/local/bin/gcc /usr/local/bin/cc
#This will allow a lot of things to work without sudo
sudo chown -R `id -u`:`id -g` /usr/local
ln -s /usr/local/bin/gcc /usr/local/bin/cc
#prepare sparse checkout .rb packages directory and do it
cd $CREW_LIB_PATH
......
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