You are not logged in.

#1 2005-08-09 15:40:02

moret
Member
From: València, Països Catalans
Registered: 2005-01-25
Posts: 26

creapkg - Create pkgs easyly

Hi!

I made a script that it lets you install software in your PC cleanly, creating a pkg.

You must configure, compile and finally install the program in the directory "pkg" and run "creapkg". An example:

./configure --prefix=/usr
make
make prefix=`pwd`/pkg install
creapkg

After you do this, the script will ask you some questions and will create a package in ./pkg.

You can find PKGBUILD in aur.

I'll wait your opinions.

Thanks and sorry for my poor english.

<B>UPDATE</B>

Version 0.3
=======

I added some options and fix some bugs. Now you can compile/install an autoconf program easyly.

[root@localhost thinkeramik-3.2.1]# creapkg -h
creapkg 0.3
usage: /usr/bin/creapkg pkgname pkgversion [OPTIONS]
OPTIONS:
  -i,  --install     Install package after successful build
  -r <release>       Package release
  -d <description>   Package description
  -u <url>           Program URL
  -l <license>       Program license
  -p <packager>      Package packager
  -c,  --cleanbuild  Clean building directory
  -n,  --nocolor     Disable colorized output messages
  -h,  --help        Show this help

BUILDING OPTIONS:
  -a,  --autoconf    Build autoconf program
  -w <prefix>        Set program prefix

An example:

[root@localhost thinkeramik-3.2.1]# creapkg kde-theme-thinkeramik 3.2.1 -iaw /opt/kde
==> Building program with autoconf...
==> Running configure script...
==> Configure script executed successful!
==> Starting compilation...
==> Compiling...
==> Compilation successful!
==> Locating files in pkg directory...
==> Location successful!
==> Building a package for kde-theme-thinkeramik 3.2.1...
==> Generating .FILELIST...
==> Generating .PKGINFO...
==> Compressing package...
.PKGINFO
.FILELIST
opt/
opt/kde/
opt/kde/lib/
opt/kde/lib/kde3/
opt/kde/lib/kde3/kwin_thinkeramik_config.la
opt/kde/lib/kde3/kwin_thinkeramik_config.so
opt/kde/lib/kde3/kwin3_thinkeramik.la
opt/kde/lib/kde3/kwin3_thinkeramik.so
opt/kde/lib/kde3/kstyle_thinkeramik_config.la
opt/kde/lib/kde3/kstyle_thinkeramik_config.so
opt/kde/lib/kde3/plugins/
opt/kde/lib/kde3/plugins/styles/
opt/kde/lib/kde3/plugins/styles/thinkeramik.la
opt/kde/lib/kde3/plugins/styles/thinkeramik.so
opt/kde/share/
opt/kde/share/apps/
opt/kde/share/apps/kwin/
opt/kde/share/apps/kwin/thinkeramik.desktop
opt/kde/share/apps/kstyle/
opt/kde/share/apps/kstyle/themes/
opt/kde/share/apps/kstyle/themes/thinkeramik.themerc
opt/kde/share/apps/kdisplay/
opt/kde/share/apps/kdisplay/color-schemes/
opt/kde/share/apps/kdisplay/color-schemes/thinkeramik.kcsrc
opt/kde/share/apps/kdisplay/color-schemes/thinkeramik-II.kcsrc
==> The package kde-theme-thinkeramik 3.2.1-1 has been built successful (Sun Aug 14 16:32:59 2005)
==> You can find the package in /home/moret/src/thinkeramik-3.2.1/pkg/kde-theme-thinkeramik-3.2.1-1.pkg.tar.gz
==> Installing kde-theme-thinkeramik-3.2.1-1...
loading package data... done.
checking for file conflicts... done.
installing kde-theme-thinkeramik... done.

Opinions please!


ArchLinux
2.6.11.7-ARCH
KDE 3.4
ADSL 512/128

Offline

#2 2005-08-09 15:49:52

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: creapkg - Create pkgs easyly

isn't this exactly what "makepkg" does?

Offline

#3 2005-08-09 15:52:26

arooaroo
Member
From: London, UK
Registered: 2005-01-13
Posts: 1,268
Website

Re: creapkg - Create pkgs easyly

Maybe this presumably bypasses the need for a PKGBUILD though which makepkg does need.

Offline

#4 2005-08-09 15:58:45

moret
Member
From: València, Països Catalans
Registered: 2005-01-25
Posts: 26

Re: creapkg - Create pkgs easyly

phrakture wrote:

isn't this exactly what "makepkg" does?

Not exactly, you don't need edit any file and you can build a package faster.


ArchLinux
2.6.11.7-ARCH
KDE 3.4
ADSL 512/128

Offline

#5 2005-08-09 18:00:05

cmp
Member
Registered: 2005-01-03
Posts: 350

Re: creapkg - Create pkgs easyly

It's nice, but why not try to make sth. like:

./configure --prefix /usr
make
creapkg 

which then directly uses make prefix=`pwd`/pkg install. but you could overwrite the default behaviour:
creapkg use make DESTDIR=/$(pwd)/pkg
creapkg python (which then uses python setup.py --prefix=$(pwd)/pkg)

Offline

#6 2005-08-09 20:26:32

moret
Member
From: València, Països Catalans
Registered: 2005-01-25
Posts: 26

Re: creapkg - Create pkgs easyly

mm, it's good idea but if for example is "destdir" and not "DESTDIR" or "prefix" o another... Maybe:

creapkg -> make DESTDIR=$(pwd)/pkg
creapkg python -> python setup.py --prefix=$(pwd)/pkg
creapkg --prefix=usr/share/program -> cp -R * $(pwd)/pkg/usr/share/program

Ideas please!!  roll  wink


ArchLinux
2.6.11.7-ARCH
KDE 3.4
ADSL 512/128

Offline

#7 2005-08-09 22:12:43

T-Dawg
Forum Fellow
From: Wilmington, NC
Registered: 2005-01-29
Posts: 2,734

Re: creapkg - Create pkgs easyly

so does this pass off the the neccessary package info to pacman's database?

Offline

#8 2005-08-09 22:27:31

laddiebuck
Member
Registered: 2005-08-03
Posts: 14

Re: creapkg - Create pkgs easyly

I would guess then you have to do pacman -A <new_pkg_name>. But then you can also contribute it, and the PKGBUILD.

Offline

#9 2005-08-10 00:06:31

moret
Member
From: València, Països Catalans
Registered: 2005-01-25
Posts: 26

Re: creapkg - Create pkgs easyly

Penguin wrote:

so does this pass off the the neccessary package info to pacman's database?

Yes, it's a valid package  wink


ArchLinux
2.6.11.7-ARCH
KDE 3.4
ADSL 512/128

Offline

#10 2005-08-10 01:15:12

Snowman
Developer/Forum Fellow
From: Montreal, Canada
Registered: 2004-08-20
Posts: 5,212

Re: creapkg - Create pkgs easyly

moret wrote:
Penguin wrote:

so does this pass off the the neccessary package info to pacman's database?

Yes, it's a valid package  wink

Really?   It doesn't take into account  dependencies, install files, etc.

Offline

#11 2005-08-10 10:19:46

moret
Member
From: València, Països Catalans
Registered: 2005-01-25
Posts: 26

Re: creapkg - Create pkgs easyly

Yes, this method is for install programs easyly, so the dependences and others are unnecessary. However, I can add the option in order to we can add dependences and other options:

creapkg --dep=bash,python

What do you think?


ArchLinux
2.6.11.7-ARCH
KDE 3.4
ADSL 512/128

Offline

#12 2005-08-10 11:04:59

Gullible Jones
Member
Registered: 2004-12-29
Posts: 4,863

Re: creapkg - Create pkgs easyly

I think that it is already included in Arch... Hey, what's so hard about writing a PKGBUILD? Sorry if I sound rude, I don't intend to; but I'm afraid this idea is a tad unnecessary, no?

Offline

#13 2005-08-10 12:05:10

cmp
Member
Registered: 2005-01-03
Posts: 350

Re: creapkg - Create pkgs easyly

it's nice to have a choice, so keep up the good work, moret.

Offline

#14 2005-08-10 14:51:49

jerem
Member
From: France
Registered: 2005-01-15
Posts: 310

Re: creapkg - Create pkgs easyly

Your tool is like Slack's checkinstall...

It would be nice to install quickly a package and see if it is worth writing a PKGBUILD for it...

Nice idea.

Offline

#15 2005-08-10 15:07:37

sweiss
Member
Registered: 2004-02-16
Posts: 635

Re: creapkg - Create pkgs easyly

Would be nice if you could somehow make it like checkinstall.

Offline

#16 2005-08-10 15:19:27

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: creapkg - Create pkgs easyly

sweiss wrote:

Would be nice if you could somehow make it like checkinstall.

a) good work moret - I didn't get the difference at first, but this makes alot of sense, so thanks

b) checkinstall is waaaay too complicated - for the install, it hooks into the standard C library calls to move and copy files - that's the only way to know for sure what it's doing.

Offline

#17 2005-08-10 15:42:04

cmp
Member
Registered: 2005-01-03
Posts: 350

Re: creapkg - Create pkgs easyly

I created a simple clone of creapkg for python packages. most of the code is just ripped from creapkg, but it uses a temporary directory, so there can be a pkg directory.
For the install it just calls the setup.py script with build and then install. this is completly sufficient as most packages seem to be installable with distutils.
usgae:
pypkg $pkgname $pkgver [$pkgdesc] [$pkgver]
example

[17:41] police:pypkg tar xzf linda-0.5.1.tar.gz 
[17:41] police:pypkg cd linda-0.5.1
[17:41] police:linda-0.5.1 ../pypkg pylinda 0.5.1
::creating a package for pylinda (0.5.1)
::creating a temporary package directory
::running the python setup
::generating the filelist
::generating the package info
::compressing the package
::removing package directory
[17:41] police:linda-0.5.1 sudo pacman -A pylinda-0.5.1-1.pkg.tar.gz 
loading package data... done.
checking for file conflicts... done.
installing pylinda... done.
[17:42] police:linda-0.5.1 

pypkg:

#!/bin/bash

# check arguments:
if [ $# -lt 2 ]
then
    echo "usage: $0 pkgname version"
    exit
fi

pkgname="$1"
pkgver="$2"

if [ $# -ge 3 ]
then
    pkgdesc="$3"
else
    pkgdesc="autogenerated python package"
fi

if [ $# -ge 4 ]
then
    pkgrel=$4
else
    pkgrel=1
fi

startdir=$(pwd)
builddate=`LC_ALL= ; LANG= ; date -u "+%a %b %e %H:%M:%S %Y"`
version=0.1

echo "::creating a package for $pkgname ($pkgver)"
echo "::creating a temporary package directory"
pkg=$(mktemp -d -p "$startdir")

echo "::running the python setup"
(
python setup.py build && python setup.py install --prefix="$pkg"
) > /dev/null || (echo " ::error build failed"; exit)

echo "::generating the filelist"
cd $pkg
tar cvf /dev/null * | sort | >.FILELIST

echo "::generating the package info"
touch .PKGINFO
echo "# Generated by pypkg $version"     >> .PKGINFO
echo "# $builddate"            >> .PKGINFO
echo "pkgname = $pkgname"        >> .PKGINFO
echo "pkgver = ${pkgver}-${pkgrel}"    >> .PKGINFO
echo "pkgdesc = $pkgdesc"         >> .PKGINFO
echo "builddate = $builddate"         >> .PKGINFO

size=$(du -cb $pkg | tail -n 1 | awk '{print $1}')
echo "size = $size"             >> .PKGINFO

if [ "$CARCH" != "" ]; then
    echo "arch = $CARCH"         >> .PKGINFO
fi

echo "::compressing the package"
tar czf "$startdir/$pkgname-$pkgver-$pkgrel.pkg.tar.gz" .PKGINFO .FILELIST *


echo "::removing package directory"
cd $startdir
rm -r $pkg

Offline

#18 2005-08-10 15:50:21

moret
Member
From: València, Països Catalans
Registered: 2005-01-25
Posts: 26

Re: creapkg - Create pkgs easyly

Yes, it's like checkinstall, but the Arch packages are easy to build, so with a simple script we can build one. This script is for installing programs quickly, so the dependences, I think, are unnecessary, like conflicts, source, md5sum...
Now, the script is very simple and I would want to know what ideas do you have to apply to script  wink


ArchLinux
2.6.11.7-ARCH
KDE 3.4
ADSL 512/128

Offline

#19 2005-08-10 15:59:25

moret
Member
From: València, Països Catalans
Registered: 2005-01-25
Posts: 26

Re: creapkg - Create pkgs easyly

Nice script! I think we must create one that builds package of all kind of program! I've sent you a pm  wink


ArchLinux
2.6.11.7-ARCH
KDE 3.4
ADSL 512/128

Offline

#20 2005-08-11 20:52:54

moret
Member
From: València, Països Catalans
Registered: 2005-01-25
Posts: 26

Re: creapkg - Create pkgs easyly


ArchLinux
2.6.11.7-ARCH
KDE 3.4
ADSL 512/128

Offline

#21 2005-08-12 00:00:20

alecthomas
Member
Registered: 2005-08-11
Posts: 3

Re: creapkg - Create pkgs easyly

moret wrote:

Nice script! I think we must create one that builds package of all kind of program! I've sent you a pm  wink

Hi moret. This is pretty much what bpkg does. It will download a tarball, extract it, try to figure out what mechanism to use to build a package, build it, then create and install an Arch package. It uses installwatch (from checkinstall) to track the installation and handles dependencies and configuration files automatically. An older version (0.2, current is 0.3) is in the AUR.

There are a few other similar programs, such as checkinstall, but none support Arch except yours and mine! smile

Offline

#22 2005-08-12 09:35:43

moret
Member
From: València, Països Catalans
Registered: 2005-01-25
Posts: 26

Re: creapkg - Create pkgs easyly

Oohh, it's seems great! But my script was done in order to create packages quickly, without specify URL, without source... It's nice to have alternatives wink but, maybe, I'll add some functions extras like autocompile, I'll see... hehe

Bye!


ArchLinux
2.6.11.7-ARCH
KDE 3.4
ADSL 512/128

Offline

#23 2005-08-12 09:45:39

moret
Member
From: València, Països Catalans
Registered: 2005-01-25
Posts: 26

Re: creapkg - Create pkgs easyly

I was working with bpkg and I think it's too simple, it don't detect any build method :S and I think it only works with autoconf... Too restricted...


ArchLinux
2.6.11.7-ARCH
KDE 3.4
ADSL 512/128

Offline

#24 2005-08-12 16:32:08

cmp
Member
Registered: 2005-01-03
Posts: 350

Re: creapkg - Create pkgs easyly

I did update (and rename) my script. it's now allmost feature complete, but I need a nice error function (printing in red) and the normal make install command (I'm too lazy to look it up wink).
You now can build a package of python programms or just package a specific directory (usefull for scripts).
Of course I'am not responsible for any damage done by this script, bla, bla, bla.
examples:
the installation of autopkg as a package

[11:26] police:pypkg ls
autopkg
[11:26] police:pypkg mkdir -p pkg/usr/bin
[11:26] police:pypkg cp autopkg pkg/usr/bin/
[11:26] police:pypkg autopkg autopkg 0.2 "a package creating tool for archlinux" --pkg-dir pkg/ --install
==> ::running the setup
==> warning: no build command issued
==> ::generating the filelist
==> ::trying to retrive information about the package
==> ::generating the package info
==> ::compressing the package
==> installing package
loading package data... done.
checking for file conflicts... done.
upgrading autopkg... done.
==> ::finished
[11:27] police:pypkg 

creating a package for pylinda

[11:30] police:linda ls
linda-0.5.1.tar.gz
[11:30] police:linda tar xzf linda-0.5.1.tar.gz 
[11:30] police:linda cd linda-0.5.1
[11:30] police:linda-0.5.1 autopkg pylinda 0.5.1 "an implementation of a linda system in python" --python
==> ::creating a temporary directory
==> ::running the setup
==> ::generating the filelist
==> ::trying to retrive information about the package
==> ::generating the package info
==> ::compressing the package
==> ::removing package directory
==> ::finished
[11:31] police:linda-0.5.1 

the script (autopkg)

#!/bin/bash
# 12.08.05 8:00 am    created file

[ -f /etc/makepkg.conf ] && source /etc/makepkg.conf

# infos about this script
NAME="pypkg"
VERSION="0.2"

# global vars - w/ defaults
pkg=""            # the package directory
pkgname=""        # the name of the package
pkgver=""        # the version of the package
pkgdesc=""        # the description of the package
pkgrel="1"        # the package release

builddate=`LC_ALL= ; LANG= ; date -u "+%a %b %e %H:%M:%S %Y"`
startdir=$(pwd)        # the directory the build has started

allready_installed="n"    # wether the package was allready installed

BUILD=""
INSTALL="n"
NO_TMP="n"

# some functions
function msg() {
    #if [ "$USE_COLOR" = "Y" -o "$USE_COLOR" = "y" ]; then
    #    echo -e "33[1;32m==>33[1;0m 33[1;1m$*33[1;0m" >&2
    #else
        echo "==> $@" >&2
    #fi
}

function gen_filelist(){
    # 12.8.05 8:07 am    created function
    # args: $1 target file
    
    msg "::generating the filelist"
    cd $pkg
    tar cvf /dev/null * | sort | >.FILELIST

}

function create_tmp_dir(){
    # 12.8.05 8:07 am    created function    
    
    if [ $NO_TMP == "y" ]; then return; fi
     
    msg "::creating a temporary directory"
    pkg=$(mktemp -d -p "$startdir")
}

function run_setup(){
    # 12.8.05 8:07 am    created function
    msg "::running the setup"
    cd $startdir
    
    if [ "$BUILD" == "python" ]
    then
        (
        python setup.py install --prefix="$pkg/usr"
        ) > /dev/null || (echo " ::error build failed"; exit -1)
    elif [ "$BUILD" == "make" ]
    then
        msg "::currently unsported"; 
        remove_tmp_dir
        exit
        #(
        #make install
        #) > /dev/null || (echo "::error build failed"; exit -1)
    elif [ "$BUILD" == "use" ]
    then
        ($USE) > /dev/null || (echo "::error build failed"; exit -1)
    else
        msg "warning: no build command issued"
    fi
}

function gen_pkginfo(){
    # 12.08.05 8:07 am    created function
    
    msg "::generating the package info"
    cd $pkg
    touch .PKGINFO

    size=$(du -cb $pkg | tail -n 1 | awk '{print $1}')
    echo "size = $size"             >> .PKGINFO

    echo "# Generated by pypkg $version"     >> .PKGINFO
    echo "# $builddate"            >> .PKGINFO
    echo "pkgname = $pkgname"        >> .PKGINFO
    echo "pkgver = ${pkgver}-${pkgrel}"    >> .PKGINFO
    echo "pkgdesc = $pkgdesc"         >> .PKGINFO
    echo "builddate = $builddate"         >> .PKGINFO


    if [ "$CARCH" != "" ]; then
        echo "arch = $CARCH"         >> .PKGINFO
    fi
}

function compress_pkg(){
    # 12.08.05 8:07 am    created function
    
    msg "::compressing the package"
    cd $pkg
    pkg_file="$startdir/$pkgname-$pkgver-$pkgrel.pkg.tar.gz"
    tar czf $pkg_file .PKGINFO .FILELIST *

}

function remove_tmp_dir(){
    # 12.08.05 8:07 am    created function    
    
    if [ $NO_TMP == "y" ]; then return; fi
    
    msg "::removing package directory"
    cd $startdir
    rm -r $pkg
}



function __get_info(){
    # 12.08.05 8:30 am    created function
    pacman -Qi $pkgname | grep $1 | sed 's/.*:s*/(w.*)/1/'
}

function get_pkginfo(){
    # 12.08.05 8:30 am    created function
    # if the package is allready installed, retrive it's information

    msg "::trying to retrive information about the package"
    (pacman -Qi $pkgname 2>/dev/null > /dev/null && installed=y) || installed=n

    if [ -z "$pkgdesc" ]
    then
        if [ "$installed" == "y" ]
        then
            pkgdesc=$(__get_info 'Description')    
        else
            pkgdesc="Autogenerated by autopkg"
        fi
    fi

    if [ -z "$pkgrel" ]
    then
        if [ "$installed" == "y" ]
        then
            pkgrel=$(__get_info 'Version' | sed 's/-(d*)/1/')
        else
            pkgrel=1
        fi
    fi
}

function install_pkg(){
    # 12.08.05 09:20    created function
    if [ $INSTALL != 'y' ] || [ -z "$pkg_file" ]; then return; fi

    msg "installing package"    
    sudo pacman -U $pkg_file
}

function mk_abs_path(){
    
    if [ ${1:0:1} == "/" ]
    then
        echo $1
    else
        echo $(pwd)/$1
    fi
}

# parse the options
function usage(){
    # 12.08.05 08:50    created function
    echo "usage: $0 pkgname pkgver [pkgdesc] [pkgrel] OPTIONS"
    echo "OPTIONS: "
    echo "--python         installs the programm via distutils"
    echo "--make        installs the programm via make"
    echo "--use CMD        installs the programm via CMD" 
    echo "                (has to be the last option)"
    echo "--pkg-dir DIR    uses the directory pkg for package installation" 
    echo "                (else a temporary director is used)"
    echo "--install        directly installs the programm via pacman (needs sudo)"
    echo "--help        prints this message"
}

function set_non_build(){
    # 12.08.05 08:40    created function
    # usage set_non_build option arg    

    if [ -z "$1" ] || [ $# -lt 2 ]
    then
        return -1
    fi
    
    if [ "${1:0:2}" != "--" ]
    then
        eval "$2="$1""
        return 0
    fi

    return -1
}

#if [ $# -lt 2 ] || [ -z "$(echo $@ | grep -- --help)" ]
#then
#    usage; exit
#fi
 

pkgname=$1
pkgver=$2

shift 2

set_non_build "$1" "pkgdesc" && shift
set_non_build "$1" "pkgrel" && shift

while [ $# -ne 0 ]
do
    case $1 in
        --python)    BUILD="python";;
        --make)        BUILD="make";;
        --use)        BUILD="use";shift;USE="$@";exit;;
        --pkg-dir)    NO_TMP="y";shift;pkg=$(mk_abs_path "$1");;
        --install)    INSTALL="y";;
        *)        usage; exit;;
    esac
    shift
done 

create_tmp_dir
run_setup || exit
gen_filelist
get_pkginfo
gen_pkginfo
compress_pkg
remove_tmp_dir
install_pkg

msg "::finished"

Offline

#25 2005-08-14 17:02:19

moret
Member
From: València, Països Catalans
Registered: 2005-01-25
Posts: 26

Re: creapkg - Create pkgs easyly

New version! Read first post!


ArchLinux
2.6.11.7-ARCH
KDE 3.4
ADSL 512/128

Offline

Board footer

Powered by FluxBB