Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
chromebrew
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
chromebrew
Commits
6a07d0eb
Commit
6a07d0eb
authored
Feb 18, 2017
by
lyxell
Committed by
GitHub
Feb 18, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #443 from jam7/refactor-archive-extraction
Change crew to use same logic for zip and tar
parents
2fb4668a
91cd2803
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
93 additions
and
77 deletions
+93
-77
crew
crew
+89
-73
packages/llvm.rb
packages/llvm.rb
+2
-2
packages/nethack4.rb
packages/nethack4.rb
+2
-2
No files found.
crew
View file @
6a07d0eb
...
@@ -13,7 +13,7 @@ CREW_PREFIX = '/usr/local'
...
@@ -13,7 +13,7 @@ CREW_PREFIX = '/usr/local'
CREW_LIB_PATH
=
CREW_PREFIX
+
'/lib/crew/'
CREW_LIB_PATH
=
CREW_PREFIX
+
'/lib/crew/'
CREW_CONFIG_PATH
=
CREW_PREFIX
+
'/etc/crew/'
CREW_CONFIG_PATH
=
CREW_PREFIX
+
'/etc/crew/'
CREW_BREW_DIR
=
CREW_PREFIX
+
'/tmp/crew/'
CREW_BREW_DIR
=
CREW_PREFIX
+
'/tmp/crew/'
CREW_DEST_DIR
=
CREW_BREW_DIR
+
'
/
dest'
CREW_DEST_DIR
=
CREW_BREW_DIR
+
'dest'
# Set CREW_NPROC from environment variable or `nproc`
# Set CREW_NPROC from environment variable or `nproc`
if
ENV
[
"CREW_NPROC"
].
to_s
==
''
if
ENV
[
"CREW_NPROC"
].
to_s
==
''
...
@@ -130,7 +130,6 @@ def upgrade
...
@@ -130,7 +130,6 @@ def upgrade
end
end
if
currentVersion
!=
@pkg
.
version
if
currentVersion
!=
@pkg
.
version
search
@pkg
.
name
puts
"Updating
#{
@pkg
.
name
}
..."
puts
"Updating
#{
@pkg
.
name
}
..."
remove
@pkg
.
name
remove
@pkg
.
name
resolveDependenciesAndInstall
resolveDependenciesAndInstall
...
@@ -185,6 +184,77 @@ def download
...
@@ -185,6 +184,77 @@ def download
return
{
source:
source
,
filename:
filename
}
return
{
source:
source
,
filename:
filename
}
end
end
def
unpack
(
meta
)
extract_dir
=
"
#{
meta
[
:filename
]
}
.dir"
target_dir
=
nil
Dir
.
chdir
CREW_BREW_DIR
do
puts
"Unpacking archive, this may take a while..."
Dir
.
mkdir
(
"
#{
extract_dir
}
"
)
unless
Dir
.
exist?
(
"
#{
extract_dir
}
"
)
if
meta
[
:filename
][
-
4
,
4
]
==
".zip"
system
"unzip"
,
"-qq"
,
"-d"
,
"
#{
extract_dir
}
"
,
meta
[
:filename
]
else
system
"tar"
,
"xf"
,
meta
[
:filename
],
"-C"
,
"
#{
extract_dir
}
"
end
if
meta
[
:source
]
==
true
# Check the number of directories in the archive
entries
=
Dir
[
"
#{
extract_dir
}
/*"
]
if
entries
.
length
==
0
abort
"empty archive:
#{
meta
[
:filename
]
}
"
elsif
entries
.
length
==
1
&&
File
.
directory?
(
entries
.
first
)
# Use `extract_dir/dir_in_archive` if there is only one directory.
target_dir
=
entries
.
first
else
# Use `extract_dir` otherwise
target_dir
=
extract_dir
end
else
# Use `extract_dir` for binary distribution
target_dir
=
extract_dir
end
end
return
CREW_BREW_DIR
+
target_dir
end
def
build_and_preconfigure
(
target_dir
)
Dir
.
chdir
target_dir
do
puts
"Building from source, this may take a while..."
@pkg
.
build
system
"rm -rf"
,
CREW_DEST_DIR
+
"/*"
#wipe crew destdir
puts
"Preconfiguring package..."
@pkg
.
install
end
end
def
prepare_package
(
destdir
)
Dir
.
chdir
destdir
do
#create directory list
system
"find . -type f > ../filelist"
system
"find . -type l >> ../filelist"
system
"cut -c2- ../filelist > filelist"
#create file list
system
"find . -type d > ../dlist"
system
"cut -c2- ../dlist > dlistcut"
system
"tail -n +2 dlistcut > dlist"
#remove temporary files
system
"rm dlistcut ../dlist ../filelist"
end
end
def
install_package
(
pkgdir
)
Dir
.
chdir
pkgdir
do
FileUtils
.
mv
'dlist'
,
CREW_CONFIG_PATH
+
"meta/
#{
@pkg
.
name
}
.directorylist"
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
end
File
.
open
(
CREW_CONFIG_PATH
+
"meta/
#{
@pkg
.
name
}
.filelist"
).
each_line
do
|
line
|
system
"sudo"
,
"mv"
,
pkgdir
+
line
.
chomp
,
line
.
chomp
end
end
end
def
resolveDependenciesAndInstall
def
resolveDependenciesAndInstall
begin
begin
origin
=
@pkg
.
name
origin
=
@pkg
.
name
...
@@ -261,81 +331,27 @@ def install
...
@@ -261,81 +331,27 @@ def install
unless
@pkg
.
is_fake?
unless
@pkg
.
is_fake?
meta
=
download
meta
=
download
topdir
=
""
target_dir
=
unpack
meta
Dir
.
chdir
CREW_BREW_DIR
do
if
meta
[
:source
]
==
true
puts
"Unpacking archive, this may take a while..."
abort
"You don't have a working C compiler. Run 'crew install buildessential' to get one and try again."
unless
system
(
"gcc"
,
"--version"
)
if
meta
[
:filename
][
-
4
,
4
]
==
".zip"
system
"unzip"
,
"-qq"
,
"-d"
,
"tmpzip"
,
meta
[
:filename
]
else
system
"tar"
,
"xf"
,
meta
[
:filename
]
end
if
meta
[
:source
]
==
true
abort
"You don't have a working C compiler. Run 'crew install buildessential' to get one and try again."
unless
system
(
"gcc"
,
"--version"
)
if
meta
[
:filename
][
-
4
,
4
]
==
".zip"
Dir
.
chdir
"tmpzip"
do
entries
=
Dir
[
"*"
]
if
entries
.
length
==
0
abort
"empty zip archive:
#{
meta
[
:filename
]
}
"
elsif
entries
.
length
==
1
topdir
=
"tmpzip/"
+
entries
.
first
else
topdir
=
"tmpzip/"
end
end
else
topdir
=
`tar -tf
#{
meta
[
:filename
]
}
| sed -e 's@/.*@@' | uniq`
.
chomp!
end
Dir
.
chdir
CREW_BREW_DIR
+
topdir
do
puts
"Building from source, this may take a while..."
@pkg
.
build
system
"rm -rf"
,
CREW_DEST_DIR
+
"/*"
#wipe crew destdir
puts
"Preconfiguring package..."
@pkg
.
install
end
Dir
.
chdir
CREW_DEST_DIR
do
#create directory list
system
"find . -type f > ../filelist"
system
"find . -type l >> ../filelist"
system
"cut -c2- ../filelist > filelist"
#create file list
system
"find . -type d > ../dlist"
system
"cut -c2- ../dlist > dlistcut"
system
"tail -n +2 dlistcut > dlist"
#remove temporary files
system
"rm dlistcut ../dlist ../filelist"
#create resulting folders list
directories
=
[]
Dir
.
glob
(
'*'
).
select
do
|
fn
|
if
File
.
directory?
(
fn
)
directories
.
push
(
fn
)
end
end
#wipe directories with the same name in brew dir to avoid conflicts
directories
.
each
do
|
dir
|
system
"rm -rf ../"
+
dir
.
chomp
end
#move result files and directories to brew dir
system
"mv * ../"
end
end
puts
"Installing..."
# build from source and place binaries at CREW_DEST_DIR
# CREW_DEST_DIR contains usr/local/... hierarchy
build_and_preconfigure
target_dir
FileUtils
.
mv
'dlist'
,
CREW_CONFIG_PATH
+
"meta/
#{
@pkg
.
name
}
.directorylist"
# prepare filelist and dlist at CREW_DEST_DIR
FileUtils
.
mv
'filelist'
,
CREW_CONFIG_PATH
+
"meta/
#{
@pkg
.
name
}
.filelist"
prepare_package
CREW_DEST_DIR
File
.
open
(
CREW_CONFIG_PATH
+
"meta/
#{
@pkg
.
name
}
.directorylist"
).
each_line
do
|
line
|
system
"sudo"
,
"mkdir"
,
"-p"
,
line
.
chomp
end
File
.
open
(
CREW_CONFIG_PATH
+
"meta/
#{
@pkg
.
name
}
.filelist"
).
each_line
do
|
line
|
# use CREW_DEST_DIR
system
"sudo"
,
"mv"
,
CREW_BREW_DIR
+
line
.
chomp
,
line
.
chomp
dest_dir
=
CREW_DEST_DIR
end
else
# use extracted binary directory
dest_dir
=
target_dir
end
end
# install filelist, dlist and binary files
puts
"Installing..."
install_package
dest_dir
end
end
#add to installed packages
#add to installed packages
...
...
packages/llvm.rb
View file @
6a07d0eb
...
@@ -10,14 +10,14 @@ class Llvm < Package
...
@@ -10,14 +10,14 @@ class Llvm < Package
def
self
.
build
def
self
.
build
system
"mkdir mybuilddir"
system
"mkdir mybuilddir"
Dir
.
chdir
CREW_BREW_DIR
+
"llvm-"
+
version
+
".src/
mybuilddir"
do
Dir
.
chdir
"
mybuilddir"
do
system
"cmake .."
system
"cmake .."
system
"cmake --build ."
system
"cmake --build ."
end
end
end
end
def
self
.
install
def
self
.
install
Dir
.
chdir
CREW_BREW_DIR
+
"llvm-"
+
version
+
".src/
mybuilddir"
do
Dir
.
chdir
"
mybuilddir"
do
system
"cmake -DCMAKE_INSTALL_PREFIX=
#{
CREW_DEST_DIR
}
/usr/local -P cmake_install.cmake"
system
"cmake -DCMAKE_INSTALL_PREFIX=
#{
CREW_DEST_DIR
}
/usr/local -P cmake_install.cmake"
end
end
end
end
...
...
packages/nethack4.rb
View file @
6a07d0eb
...
@@ -14,7 +14,7 @@ class Nethack4 < Package
...
@@ -14,7 +14,7 @@ class Nethack4 < Package
def
self
.
build
def
self
.
build
target
=
CREW_BREW_DIR
+
"nethack4-4.3-beta2/
build"
target
=
"
build"
system
"mkdir -p "
+
target
system
"mkdir -p "
+
target
Dir
.
chdir
target
do
Dir
.
chdir
target
do
#build with rpath pointing at /usr/local
#build with rpath pointing at /usr/local
...
@@ -24,7 +24,7 @@ class Nethack4 < Package
...
@@ -24,7 +24,7 @@ class Nethack4 < Package
end
end
def
self
.
install
def
self
.
install
target
=
CREW_BREW_DIR
+
"nethack4-4.3-beta2/
build"
target
=
"
build"
Dir
.
chdir
target
do
Dir
.
chdir
target
do
#install in destdir so package manager can keep track
#install in destdir so package manager can keep track
system
"/usr/local/bin/perl ../aimake --install-only -i
#{
CREW_DEST_DIR
}
/usr/local/ --directory-layout=prefix --without=gui"
system
"/usr/local/bin/perl ../aimake --install-only -i
#{
CREW_DEST_DIR
}
/usr/local/ --directory-layout=prefix --without=gui"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment