2015年1月19日 星期一

[Ubuntu] Make deb package and own local package repository

1. write a c code
#include <stdio.h>

int main()
{
   printf("happy.org\n");

    return 0;
}


2. Compile c code
gcc happy.c -o happy


3. Creating a Debian package
$ mkdir happy-0.0.1/DEBIAN -p


4. Edit control file
$ vim happy-0.0.1/DEBIAN/control
Package: happy
Version: 0.0.11
Section: custom
Priority: optional
Architecture: all
Essential: no
Installed-Size: 1024
Maintainer: happy.org
Description: Print happy.org on the screen


5. Copy binary file into happy-0.0.1/usr/bin/
$ mkdir  happy-0.0.1/usr/bin/ -p
$ cp happy happy-0.0.1/usr/bin/


6. Create a debian package.
dpkg-deb –build happy-0.0.1

  1. Remove debian package
    dpkg -P happy-0.0.1

Make own reporsitory

1. Install apache
sudo apt-get install apache2 apache2-doc apache2-utils
$ mkdir cd /var/www/debian


2. copy deb package to /var/www/debian
cp /path/to/happy-0.0.1.deb /var/www/debian/


3. Create a package list using dpkg-scanpackages
$ dpkg-scanpackages debian /dev/null | gzip -9c > debian/Packages.gz
dpkg-scanpackages: warning: Packages in archive but missing from override file:
dpkg-scanpackages: warning:   happy-0.0.1
dpkg-scanpackages: info: Wrote 1 entries to output Packages file.

4. Upload the folder of debian you web sever on internet
scp /var/www/debian xxx@123.123.123.123:/var/www

5. Add new repository address to local list
echo “deb http://123.123.123.123 debian/” >> /etc/apt/sources.list
apt-get update


6. Install happy-0.0.1 package
sudo apt-get install linuxconfig




Reference:
1. Easy way to create a Debian package and local package repository
2. [Raspberry pi] Install LAMP

0 意見:

張貼留言