-
Notifications
You must be signed in to change notification settings - Fork 375
Creating a package
-
Create an empty file in
/usr/local/lib/crew/packages/
with a.rb
extension. If you want to add a recipe for a package called bc, name the filebc.rb
. -
Update the content of the file to conform with the following template:
require 'package'
class Bc < Package # The first character of the class name must be upper case
description 'bc is an arbitrary precision numeric processing language.'
homepage 'http://www.gnu.org/software/bc/'
version '1.07.1'
license 'GPL-3' # license of source
compatibility 'all'
source_url 'https://ftp.gnu.org/gnu/bc/bc-1.07.1.tar.gz'
source_sha256 '62adfca89b0a1c0164c2cdca59ca210c1d44c3ffc46daf9931cf4942664cb02a' # Use the command "sha256sum"
depends_on 'readline' # packages required by this package
depends_on 'flex' => :build # packages with "=> :build" are only required if you're building from source
depends_on 'ed' => :build
def self.build # the steps required to build the package
system "./configure #{CREW_OPTIONS} --with-readline"
system "make"
end
def self.install # the steps required to install the package
system "make", "DESTDIR=#{CREW_DEST_DIR}", "install"
end
def self.check # the steps required to check if the package was built ok
system "make", "check"
end
end
-
Use
#{CREW_OPTIONS}
on./configure
andDESTDIR=#{CREW_DEST_DIR}
on install to make sure everything ends up in the correct place. -
Try your recipe via
crew install <pkgName>
, e.g.crew install bc
. -
Ensure your package was successfully installed. To confirm, execute
crew files <pkgName>
and make sure there are files listed and they appear to be in the correct location. -
Ensure your package can be uninstalled without leaving file residue behind. To confirm, execute
crew remove <pkgName>
and make sure there are no errors produced by the command. -
Upload your package from
/usr/local/lib/crew/packages/<pkgName>.rb
to your own fork of this repository. -
Commit your changes and create a pull request. Please add a short description in the PR to explain the new package and any helpful links for more information.
To test a pre-compiled binary file of your new package or to an existing one, you must first create a source-only package like above if it does not exist. After that:
-
Use
crew build <pkgName>
, e.g.crew build bc
. -
If you see
<pkgname>-<version>-chromeos-<arch>.tpxz is built!
, it means everything worked fine and the compressed file has everything you need. It will also create a.sha256
file that has the sha256 of the.tpxz
file. -
Test your new binary. Add the following in your pkgname.rb file right below the
source_url
andsource_sha256
lines:
binary_url ({
<arch>: 'file:///path/to/your/pre-compiled/binary/<pkgname>-<version>-chromeos-<arch>.tar.xz'
})
binary_sha256 ({
<arch>: '<sha256 hash here>'
})
-
Make sure to add to the correct architecture. It could be
x86_64
,i686
,armv7l
oraarch64
(binary generated inaarch64
can be also used inarmv7l
since they are all running on 32-bit userspace) (the name will be included in the.tpxz
filename). There may be more than one type of pre-compiled binary; each for a different architecture. -
Copy
<pkgName>.rb
to/usr/local/lib/crew/packages/
and then attempt to install.
$ cp <pkgName>.rb /usr/local/lib/crew/packages
$ crew install <pkgName>
- Test the installation:
$ crew files <pkgName>
$ <pkgCmd> --version
$ <pkgCmd> --help
$ <pkgCmd> ...
Replace <pkgCmd>
with any binary executable(s) installed from the package, if applicable.
PS. Some useful templates for source code build:
- Building package from source code using
cmake
def self.build
FileUtils.mkdir_p 'build'
Dir.chdir("build") do
system "cmake -G Ninja #{CREW_CMAKE_OPTIONS} .."
system 'samu'
end
end
def self.install # the steps required to install the package
Dir.chdir("build") do
system { 'DESTDIR' => CREW_DEST_DIR }, 'samu', 'install'
end
end