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'
CREW_LIB_PATH
=
CREW_PREFIX
+
'/lib/crew/'
CREW_CONFIG_PATH
=
CREW_PREFIX
+
'/etc/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`
if
ENV
[
"CREW_NPROC"
].
to_s
==
''
...
...
@@ -130,7 +130,6 @@ def upgrade
end
if
currentVersion
!=
@pkg
.
version
search
@pkg
.
name
puts
"Updating
#{
@pkg
.
name
}
..."
remove
@pkg
.
name
resolveDependenciesAndInstall
...
...
@@ -185,6 +184,77 @@ def download
return
{
source:
source
,
filename:
filename
}
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
begin
origin
=
@pkg
.
name
...
...
@@ -261,81 +331,27 @@ def install
unless
@pkg
.
is_fake?
meta
=
download
topdir
=
""
Dir
.
chdir
CREW_BREW_DIR
do
puts
"Unpacking archive, this may take a while..."
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
target_dir
=
unpack
meta
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"
)
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"
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
# prepare filelist and dlist at CREW_DEST_DIR
prepare_package
CREW_DEST_DIR
File
.
open
(
CREW_CONFIG_PATH
+
"meta/
#{
@pkg
.
name
}
.filelist"
).
each_line
do
|
line
|
system
"sudo"
,
"mv"
,
CREW_BREW_DIR
+
line
.
chomp
,
line
.
chomp
end
# use CREW_DEST_DIR
dest_dir
=
CREW_DEST_DIR
else
# use extracted binary directory
dest_dir
=
target_dir
end
# install filelist, dlist and binary files
puts
"Installing..."
install_package
dest_dir
end
#add to installed packages
...
...
packages/llvm.rb
View file @
6a07d0eb
...
...
@@ -10,14 +10,14 @@ class Llvm < Package
def
self
.
build
system
"mkdir mybuilddir"
Dir
.
chdir
CREW_BREW_DIR
+
"llvm-"
+
version
+
".src/
mybuilddir"
do
Dir
.
chdir
"
mybuilddir"
do
system
"cmake .."
system
"cmake --build ."
end
end
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"
end
end
...
...
packages/nethack4.rb
View file @
6a07d0eb
...
...
@@ -14,7 +14,7 @@ class Nethack4 < Package
def
self
.
build
target
=
CREW_BREW_DIR
+
"nethack4-4.3-beta2/
build"
target
=
"
build"
system
"mkdir -p "
+
target
Dir
.
chdir
target
do
#build with rpath pointing at /usr/local
...
...
@@ -24,7 +24,7 @@ class Nethack4 < Package
end
def
self
.
install
target
=
CREW_BREW_DIR
+
"nethack4-4.3-beta2/
build"
target
=
"
build"
Dir
.
chdir
target
do
#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"
...
...
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