LoginSignup
2
1

More than 5 years have passed since last update.

[メモ] 最小限の手間で、debパッケージ作成 (非推奨)

Posted at

最小限の手間で、debパッケージを作成する(非推奨)

概要

環境

  • Debian Stretch

とりあえず実行例

  1. 以下をコピペすると、hellodeb.debができるハズ。

    以下コピペする
    #フォルダ作成
    mkdir -p hellodeb/DEBIAN
    mkdir -p hellodeb/usr/local/bin
    
    # インストールする実行ファイル作成
    cat <<'EOF' > hellodeb/usr/local/bin/hellodeb.sh
    #!/bin/sh
    echo 'Hello Deb!'
    EOF
    chmod a+x hellodeb/usr/local/bin/hellodeb.sh
    
    # DEBIAN/controlファイル作成
    cat <<'EOF' > hellodeb/DEBIAN/control
    Package: hellodeb
    Version: 1
    Architecture: all
    Maintainer: mt08
    Description: Hello Deb!
    EOF
    
    dpkg-deb --build hellodeb
    
    # hellodeb.debができているハズ
    
  2. 作成したdebファイルを使ってみる

    使用例
    vagrant@stretch:~$ pwd
    /home/vagrant
    vagrant@stretch:~$ dpkg-deb --build hellodeb
    dpkg-deb: building package 'hellodeb' in 'hellodeb.deb'.
    vagrant@stretch:~$ sudo apt install -y ./hellodeb.deb
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    Note, selecting 'hellodeb' instead of './hellodeb.deb'
    The following NEW packages will be installed:
      hellodeb
    0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
    Need to get 0 B/668 B of archives.
    After this operation, 0 B of additional disk space will be used.
    Get:1 /home/vagrant/hellodeb.deb hellodeb all 1 [668 B]
    Selecting previously unselected package hellodeb.
    (Reading database ... 27807 files and directories currently installed.)
    Preparing to unpack /home/vagrant/hellodeb.deb ...
    Unpacking hellodeb (1) ...
    Setting up hellodeb (1) ...
    vagrant@stretch:~$ hellodeb.sh
    Hello Deb!
    vagrant@stretch:~$ which hellodeb.sh
    /usr/local/bin/hellodeb.sh
    vagrant@stretch:~$ sudo apt remove -y hellodeb
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    The following packages will be REMOVED:
      hellodeb
    0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
    After this operation, 0 B of additional disk space will be used.
    (Reading database ... 27810 files and directories currently installed.)
    Removing hellodeb (1) ...
    dpkg: warning: while removing hellodeb, directory '/usr/local' not empty so not removed
    vagrant@stretch:~$ hash -r
    vagrant@stretch:~$ hellodeb.sh
    -bash: hellodeb.sh: command not found
    

ちょっとした手順説明

  1. パッケージ名のフォルダを作成
  2. パッケージ名フォルダの中に、/(ルート)へコピーされるフォルダ構成で、ファイルを入れる。
  3. パッケージ名フォルダ/DEBIANフォルダを作成し、その中に controlというファイルを以下の内容で作る

    パッケージ名フォルダ/DEBIAN/control
    Package: hellodeb
    Version: 0.1
    Architecture: all
    Maintainer: mt08 <mt08@email.address.dayo>
    Description: Hello Deb!
    
  4. dpkg-deb --build パッケージ名 を実行

その他

  • 依存パッケージ(Depends:)とかもあるので、そのへんは、ググる。
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1