Commit 6087ab54 authored by Andrey V.Kosteltsev's avatar Andrey V.Kosteltsev

initial version of Radix cross Linux pkgtools

parents
This diff is collapsed.
ACLOCAL_AMFLAGS = -I m4
#
# In build order:
# ==============
#
SUBDIRS = src
EXTRA_DIST = doc LICENSE README.md acsite.m4 bootstrap src/pkglist.html.c src/pkglist.html.v3.c
see README.md instead
# [Pkgtools](https://radix.pro/build-system/pkgtool/)
**Pkgtools** is a set of utilities to create, install, remove, and update
packages on the root file system.
## Table of contents
* [Bootstrap script](#user-content-bootstrap-script)
* [Install](#user-content-install)
* [Configurations](#user-content-configurations)
* [Cross compilation example](#user-content-cross-compilation-example)
* [Dialog](#user-content-dialog)
* [License](#user-content-license)
## Bootstrap script
The bootstrap script aspecialy created for autotools install automation
To install autotools into source directory on build machine (i.e. when
*build == host*) the bootstrap script can be run without arguments. In this
case autotools will be installed from current root file system.
For the cross environment the *--target-dest-dir* options allows to install
some stuf from development root file system:
```Bash
$ TARGET_DEST_DIR=/home/developer/prog/trunk-672/dist/.s9xx-glibc/enybox-x2 \
./bootstrap --target-dest-dir=${TARGET_DEST_DIR}
```
For example, in this case the dialog.m4 script will be taken from the
${TARGET_DEST_DIR}/usr/share/aclocal directory.
## Install
On the build machine the installation process seems like that
```Bash
$ tar xJvf pkgtools-0.0.9.tar.xz
$ mkdir build
$ cd build
$ ../pkgtools-0.0.9/configure --prefix=/usr
$ make
$ make install DESTDIR=$PKG exec_prefix=/
Note that the exec_prefix=/ used for canonical installation of
pkgtools utilities into ${DESTDIR}/sbin directory instead of
${DESTDIR}/usr/sbin/ which is not corresponds to FHS.
```
## Configurations
Pkgtools support OpenPGP signing of packages and also simple
user interface based on dialog library.
### OpenPGP support options:
```Bash
--with-gpg2=no
--with-gpg2=yes
--with-gpg2=${TARGET_DEST_DIR}/usr
```
If the *--with-gpg2* option is not specified then dialog support
is disabled.
### Dialog options:
```Bash
--with-dialog=no
--with-dialog=yes
--with-dialog=${TARGET_DEST_DIR}/usr
--with-dialog-test=no
--with-dialog-test=yes
```
Dialog support is enabled by default. The option *--with-dialog=no*
disables the dialog support.
### Distribution options:
```Bash
--with-distro-name[=NAME] The name of distribution
--with-distro-version[=VERSION] The distribution version
```
To show all available options you can make use of
```Bash
$ ./configure --help
```
## Cross compilation example
```Bash
TARGET_DEST_DIR=/home/developer/prog/trunk-672/dist/.s9xx-glibc/enybox-x2
TOOLCHAIN_PATH=/opt/toolchains/aarch64-S9XX-linux-glibc/1.1.4/bin
TARGET=aarch64-s9xx-linux-gnu
DIALOG_CONFIG=${TARGET_DEST_DIR}/usr/bin/dialog-config \
STRIP="${TOOLCHAIN_PATH}/${TARGET}-strip" \
CC="${TOOLCHAIN_PATH}/${TARGET}-gcc --sysroot=${TARGET_DEST_DIR}" \
./configure --prefix=/usr
--build=x86_64-pc-linux-gnu \
--host=${TARGET} \
--with-gpg2=${TARGET_DEST_DIR}/usr \
--with-dialog=${TARGET_DEST_DIR}/usr \
--with-dialog-test=yes
Also we can make use of additional variables such as CFLAGS, LDFLAGS:
LDFLAGS="-L${TARGET_DEST_DIR}/lib -L${TARGET_DEST_DIR}/usr/lib"
TARGET_INCPATH="-L${TARGET_DEST_DIR}/usr/include"
CFLAGS="${TARGET_INCPATH}"
CPPFLAGS="${TARGET_INCPATH}"
```
## Dialog
The original dialog sources have some bugs such as memory leaks and also
the dialog package doesn't have correct autotools scripts. If you want to
use libdialog with pkgtools then you have to install the dialog package
with our [patch](doc/dialog/dialog-1.3-20190211.patch). This patch provides
*dialog.m4* and more convenient *dialog-config* script for
[dialog-1.3-20190211.tgz](ftp://ftp.invisible-island.net/dialog/dialog-1.3-20190211.tgz)
source package.
## [License](https://radix.pro/legal/licenses/)
Code and documentation copyright 2009-2019 Andrey V. Kosteltsev.
Code and documentation released under [the **Radix.pro** License](LICENSE).
The text of this license can be found on our website at:
```
[https://radix.pro/licenses/LICENSE-1.0-en_US.txt](https://radix.pro/licenses/LICENSE-1.0-en_US.txt)
[https://radix.pro/licenses/LICENSE-1.0-en_US.txt](https://radix.pro/licenses/LICENSE-1.0-ru_RU.txt)
```
dnl ============================================================
dnl Display Configuration Headers
dnl
dnl configure.in:
dnl AC_MSG_CFG_PART(<text>)
dnl ============================================================
define(AC_MSG_CFG_PART,[dnl
AC_MSG_RESULT()
AC_MSG_RESULT(${TB}$1:${TN})
])dnl
AC_DEFUN(AC_PKGTOOLS_HEADLINE,[dnl
# Use a `Quadrigaph'. @<:@ gives you [ and @:>@ gives you ] :
TB=`echo -n -e '\033@<:@1m'`
TN=`echo -n -e '\033@<:@0m'`
echo ""
echo "Configuring ${TB}$1${TN} ($2), Version ${TB}${PACKAGE_VERSION}${TN}"
echo "$3"
])dnl
dnl ============================================================
dnl Test for build_host `ln -s' .
dnl ============================
dnl
dnl Usage:
dnl -----
dnl AC_PATH_PROG_LN_S
dnl AC_SUBST(LN)
dnl AC_SUBST(LN_S)
dnl
dnl ============================================================
AC_DEFUN(AC_PATH_PROG_LN_S,
[AC_PATH_PROG(LN, ln, no, /usr/local/bin:/usr/bin:/bin:$PATH)
AC_MSG_CHECKING(whether ln -s works on build host)
AC_CACHE_VAL(ac_cv_path_prog_LN_S,
[rm -f conftestdata
if $LN -s X conftestdata 2>/dev/null
then
rm -f conftestdata
ac_cv_path_prog_LN_S="$LN -s"
else
ac_cv_path_prog_LN_S="$LN"
fi])dnl
LN_S="$ac_cv_path_prog_LN_S"
if test "$ac_cv_path_prog_LN_S" = "$LN -s"; then
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
AC_SUBST(LN)dnl
AC_SUBST(LN_S)dnl
])
#!/bin/sh
CWD=`pwd`
program=`basename $0`
usage() {
cat << EOF
Usage: $program [options]
Options:
-h,--help Display this message.
-d,--target-dest-dir=DIR The target ROOTFS directory
[default: DIR=/].
EOF
}
TARGET_DEST_DIR=/
ACDIR=usr/share/aclocal
INCDIR=usr/include
SYSTEM_ACDIR=
SYSTEM_INCDIR=
while [ 0 ] ; do
if [ "$1" = "-h" -o "$1" = "--help" ] ; then
usage
exit 0
elif [ "$1" = "-d" -o "$1" = "--target-dest-dir" ] ; then
if [ "$2" = "" ] ; then
echo -e "\n${program}: ERROR: --target-dest-dir is not specified.\n"
usage
exit 1
fi
TARGET_DEST_DIR="$2"
shift 2
elif [[ $1 == --target-dest-dir=* ]] ; then
TARGET_DEST_DIR="`echo $1 | cut -f2 -d'='`"
shift 1
else
if [ "$1" != "" ] ; then
echo -e "\n${program}: ERROR: Unknown argument: $1.\n"
usage
exit 1
fi
break
fi
done
if [ ! -d "${TARGET_DEST_DIR}" ] ; then
echo -e "\n${program}: ERROR: --target-dest-dir is not a directory.\n"
usage
exit 1
fi
#
# Absolute path:
#
if [ "${TARGET_DEST_DIR:0:1}" != "/" ] ; then
TARGET_DEST_DIR=${CWD}/${TARGET_DEST_DIR}
fi
#
# Remove last '/' char:
#
if [ "${TARGET_DEST_DIR: -1}" = "/" ] ; then
len=${#TARGET_DEST_DIR}
let "len = len - 1"
tmp="${TARGET_DEST_DIR:0:$len}"
TARGET_DEST_DIR=${tmp}
fi
SYSTEM_ACDIR="${TARGET_DEST_DIR}/${ACDIR}"
SYSTEM_INCDIR="${TARGET_DEST_DIR}/${INCDIR}"
aclocal --install -I m4 --force --system-acdir=${SYSTEM_ACDIR}
autoheader --include=${SYSTEM_INCDIR}
automake --gnu --add-missing --copy --force-missing
autoconf --force
This diff is collapsed.
#!/bin/sh
cd ../..
if [ -f "Makefile" ] ; then
make distclean
fi
rm -rf autom4te.cache m4
rm -f Makefile
rm -f Makefile.in
rm -f config.h
rm -f config.h.in
rm -f config.log
rm -f config.status
rm -f compile config.guess config.sub
rm -f configure
rm -f install-sh
rm -f missing
rm -f stamp-h1
rm -f aclocal.m4
rm -f depcomp
rm -rf src/.deps
rm -f src/Makefile
rm -f src/Makefile.in
#!/bin/sh
TARGET_DEST_DIR=/home/kx/prog/scm/svn/platform/trunk-672/dist/.s9xx-glibc/enybox-x2
cd ../..
./bootstrap --target-dest-dir=${TARGET_DEST_DIR}
#!/bin/sh
cd ../..
./bootstrap
#!/bin/sh
cd ../..
TARGET_DEST_DIR=/home/kx/prog/scm/svn/platform/trunk-672/dist/.s9xx-glibc/enybox-x2
TOOLCHAIN_PATH=/opt/toolchain/aarch64-S9XX-linux-glibc/1.1.4/bin
TARGET=aarch64-s9xx-linux-gnu
TARGET_INCPATH="-L${TARGET_DEST_DIR}/usr/include"
CFLAGS="${TARGET_INCPATH}"
CPPFLAGS="${TARGET_INCPATH}"
LDFLAGS="-L${TARGET_DEST_DIR}/lib -L${TARGET_DEST_DIR}/usr/lib"
DIALOG_CONFIG=${TARGET_DEST_DIR}/usr/bin/dialog-config \
STRIP="${TOOLCHAIN_PATH}/${TARGET}-strip" \
CC="${TOOLCHAIN_PATH}/${TARGET}-gcc --sysroot=${TARGET_DEST_DIR}" \
./configure --prefix=/usr \
--build=x86_64-pc-linux-gnu --host=${TARGET} \
--with-gpg2=${TARGET_DEST_DIR}/usr \
--with-dialog=${TARGET_DEST_DIR}/usr \
--with-dialog-test=yes
#!/bin/sh
cd ../..
./configure --prefix=/usr \
--with-distro-name=radix \
--with-distro-version=1.1 \
--with-gpg2=yes \
--with-dialog=yes
This diff is collapsed.
#
# Run-time configuration file for dialog, matches Radix color scheme.
#
# Types of values:
#
# Number - <number>
# String - "string"
# Boolean - <ON|OFF>
# Attribute - (foreground,background,highlight?)
# Set aspect-ration.
aspect = 0
# Set separator (for multiple widgets output).
separate_widget = ""
# Set tab-length (for textbox tab-conversion).
tab_len = 0
# Make tab-traversal for checklist, etc., include the list.
visit_items = OFF
# Shadow dialog boxes? This also turns on color.
use_shadow = ON
# Turn color support ON or OFF
use_colors = ON
# Screen color
screen_color = (WHITE,BLACK,ON)
# Shadow color
shadow_color = (BLACK,BLACK,OFF)
# Dialog box color
dialog_color = (BLACK,WHITE,OFF)
# Dialog box title color
title_color = (BLACK,WHITE,ON)
# Dialog box border color
border_color = (WHITE,WHITE,ON)
# Active button color
button_active_color = (WHITE,BLACK,ON)
# Inactive button color
button_inactive_color = (BLACK,WHITE,OFF)
# Active button key color
button_key_active_color = (YELLOW,BLACK,ON)
# Inactive button key color
button_key_inactive_color = (RED,WHITE,ON)
# Active button label color
button_label_active_color = (WHITE,BLACK,ON)
# Inactive button label color
button_label_inactive_color = (BLACK,WHITE,ON)
# Input box color
inputbox_color = (BLUE,WHITE,ON)
# Input box border color
inputbox_border_color = (WHITE,WHITE,ON)
# Search box color
searchbox_color = (YELLOW,WHITE,ON)
# Search box title color
searchbox_title_color = (WHITE,WHITE,ON)
# Search box border color
searchbox_border_color = (RED,WHITE,OFF)
# File position indicator color
position_indicator_color = (RED,WHITE,ON)
# Menu box color
menubox_color = dialog_color
# Menu box border color
menubox_border_color = border_color
# Item color
item_color = (BLACK,WHITE,ON)
# Selected item color
item_selected_color = (BLACK,WHITE,OFF)
# Tag color
tag_color = (BLACK,WHITE,ON)
# Selected tag color
tag_selected_color = (BLACK,WHITE,OFF)
# Tag key color
tag_key_color = (RED,WHITE,ON)
# Selected tag key color
tag_key_selected_color = (YELLOW,BLACK,ON)
# Check box color
check_color = dialog_color
# Selected check box color
check_selected_color = (RED,WHITE,ON)
# Up arrow color
uarrow_color = (RED,WHITE,OFF)
# Down arrow color
darrow_color = uarrow_color
# Item help-text color
itemhelp_color = shadow_color
# Active form text color
form_active_text_color = inputbox_color
# Form text color
form_text_color = (BLACK,WHITE,ON)
# Readonly form item color
form_item_readonly_color = (CYAN,WHITE,ON)
# Dialog box gauge color
gauge_color = (BLACK,WHITE,ON)
# Dialog box border2 color
border2_color = dialog_color
# Input box border2 color
inputbox_border2_color = border2_color
# Search box border2 color
searchbox_border2_color = border2_color
# Menu box border2 color
menubox_border2_color = border2_color
noinst_HEADERS = defs.h cmpvers.h dlist.h jsmin.h make-pkglist.h msglog.h pkglist.h system.h dialog-ui.h
sbin_PROGRAMS = chrefs pkginfo pkglog make-package make-pkglist check-db-integrity check-package check-requires \
install-package remove-package update-package install-pkglist
chrefs_SOURCES = chrefs.c system.c msglog.c
pkginfo_SOURCES = pkginfo.c system.c msglog.c
pkglog_SOURCES = pkglog.c system.c msglog.c
check_db_integrity_SOURCES = check-db-integrity.c system.c msglog.c cmpvers.c dlist.c jsmin.c pkglist.c
check_db_integrity_LDADD = -lm
check_requires_SOURCES = check-requires.c system.c msglog.c cmpvers.c dlist.c jsmin.c pkglist.c
check_requires_LDADD = -lm
check_package_SOURCES = check-package.c system.c msglog.c cmpvers.c
make_pkglist_SOURCES = make-pkglist.c system.c msglog.c cmpvers.c dlist.c jsmin.c pkglist.c
make_pkglist_LDADD = -lm
make_package_SOURCES = make-package.c system.c msglog.c dlist.c
make_package_LDADD = -lm
install_package_SOURCES = install-package.c system.c msglog.c cmpvers.c dlist.c
install_package_LDADD = -lm
if USE_DIALOG
install_package_SOURCES += dialog-ui.c
install_package_CFLAFS = $(DIALOG_CFLAGS)
install_package_LDFLAGS = $(DIALOG_LDFLAGS)
install_package_LDADD += $(DIALOG_LIBS)
endif
remove_package_SOURCES = remove-package.c system.c msglog.c cmpvers.c dlist.c
remove_package_LDADD = -lm
if USE_DIALOG
remove_package_SOURCES += dialog-ui.c
remove_package_CFLAFS = $(DIALOG_CFLAGS)
remove_package_LDFLAGS = $(DIALOG_LDFLAGS)
remove_package_LDADD += $(DIALOG_LIBS)
endif
update_package_SOURCES = update-package.c system.c msglog.c cmpvers.c dlist.c
update_package_LDADD = -lm
if USE_DIALOG
update_package_SOURCES += dialog-ui.c
update_package_CFLAFS = $(DIALOG_CFLAGS)
update_package_LDFLAGS = $(DIALOG_LDFLAGS)
update_package_LDADD += $(DIALOG_LIBS)
endif
install_pkglist_SOURCES = install-pkglist.c system.c msglog.c cmpvers.c dlist.c
install_pkglist_LDADD = -lm -lpthread
if USE_DIALOG
install_pkglist_SOURCES += dialog-ui.c
install_pkglist_CFLAFS = $(DIALOG_CFLAGS)
install_pkglist_LDFLAGS = $(DIALOG_LDFLAGS)
install_pkglist_LDADD += $(DIALOG_LIBS)
endif
pkgdata_DATA = .dialogrc
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/**********************************************************************
Copyright 2019 Andrey V.Kosteltsev
Licensed under the Radix.pro License, Version 1.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://radix.pro/licenses/LICENSE-1.0-en_US.txt
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied.
**********************************************************************/
#include <config.h>
#include <stdint.h>
#include <string.h>
#include <ctype.h>
/* states: S_N: normal, S_I: comparing integral part, S_F: comparing
fractionnal parts, S_Z: idem but with leading Zeroes only */
#define S_N 0x0
#define S_I 0x3
#define S_F 0x6
#define S_Z 0x9
/* result_type: CMP: return diff; LEN: compare using len_diff/diff */
#define CMP 2
#define LEN 3
/* Compare S1 and S2 as strings holding indices/version numbers,
returning less than, equal to or greater than zero if S1 is less than,
equal to or greater than S2 (for more info, see the texinfo doc).
*/
int cmp_version( const char *s1, const char *s2 )
{
const unsigned char *p1 = (const unsigned char *)s1;
const unsigned char *p2 = (const unsigned char *)s2;
/* Symbol(s) 0 [1-9] others
Transition (10) 0 (01) d (00) x */
static const uint8_t next_state[] =
{
/* state x d 0 */
/* S_N */ S_N, S_I, S_Z,
/* S_I */ S_N, S_I, S_I,
/* S_F */ S_N, S_F, S_F,
/* S_Z */ S_N, S_F, S_Z
};
static const int8_t result_type[] =
{
/* state x/x x/d x/0 d/x d/d d/0 0/x 0/d 0/0 */
/* S_N */ CMP, CMP, CMP, CMP, LEN, CMP, CMP, CMP, CMP,
/* S_I */ CMP, -1, -1, +1, LEN, LEN, +1, LEN, LEN,
/* S_F */ CMP, CMP, CMP, CMP, CMP, CMP, CMP, CMP, CMP,
/* S_Z */ CMP, +1, +1, -1, CMP, CMP, -1, CMP, CMP
};
if( p1 == p2 ) return 0;
unsigned char c1 = *p1++;
unsigned char c2 = *p2++;
/* Hint: '0' is a digit too. */
int state = S_N + ((c1 == '0') + (isdigit (c1) != 0));
int diff;
while( (diff = c1 - c2) == 0 )
{
if( c1 == '\0' ) return diff;
state = next_state[state];
c1 = *p1++;
c2 = *p2++;
state += (c1 == '0') + (isdigit (c1) != 0);
}
state = result_type[state * 3 + (((c2 == '0') + (isdigit (c2) != 0)))];
switch (state)
{
case CMP:
return diff;
case LEN:
while( isdigit (*p1++) )
if( !isdigit (*p2++) )
return 1;
return isdigit (*p2) ? -1 : diff;
default:
return state;
}
}
const char *max_version( const char *s1, const char *s2 )
{
if( cmp_version( s1, s2 ) < 0 ) return s2;
else return s1;
}
/**********************************************************************
Copyright 2019 Andrey V.Kosteltsev
Licensed under the Radix.pro License, Version 1.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://radix.pro/licenses/LICENSE-1.0-en_US.txt
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied.
**********************************************************************/
#ifndef _CMP_VERSION_H_
#define _CMP_VERSION_H_
#ifdef __cplusplus
extern "C" {
#endif
extern int cmp_version( const char *s1, const char *s2 );
extern const char *max_version( const char *s1, const char *s2 );
#ifdef __cplusplus
} /* ... extern "C" */
#endif
#endif /* _CMP_VERSION_H_ */
/**********************************************************************
Copyright 2019 Andrey V.Kosteltsev
Licensed under the Radix.pro License, Version 1.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://radix.pro/licenses/LICENSE-1.0-en_US.txt
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied.
**********************************************************************/
#ifndef _DEFS_H_
#define _DEFS_H_
#ifdef __cplusplus