Add scripts to create packages, working splits. Needs grooming.

This commit is contained in:
Philippe Pittoli 2021-03-13 04:02:23 +01:00
parent e3f6b5fd15
commit eb1c56744a
10 changed files with 156 additions and 18 deletions

13
bin/create-manifest Executable file
View File

@ -0,0 +1,13 @@
#!/bin/sh
find . | while read F ; do
if [ -f $F ]; then
sum=$(sha256sum $F | cut -d ' ' -f 1)
echo "f:$F:$sum"
elif [ -d $F ]; then
echo "d:$F"
else
# Don't know the type, could be a problem
exit 1
fi
done

20
bin/create-meta Executable file
View File

@ -0,0 +1,20 @@
#!/bin/sh
du_sk=`du -sk . | sed "s/[ \t].*//g"`
size=$(echo "$du_sk * 1024" | bc)
cat <<END
name = $name
version = $version
release = $release
size = $size
slot = $SLOT
url = $URL
description = $description
dependencies = $dependencies
conflicts = $conflicts
provides = $provides
END

10
bin/create-package Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
package=$1
tar cvf data.tar .
zstd --ultra data.tar
rm data.tar
create-manifest > package-manifest
create-meta > package-info
tar cvf $package package-manifest package-info data.tar.zst

11
bin/create-split-dev Executable file
View File

@ -0,0 +1,11 @@
#!/bin/sh
. $(dirname $(which create-split-dev))/create-split.subr
# Usage: create-split-dev
# dev split package targets developers content, which means
# - /include/ and /pkgconfig/ directories
# - .h and .hpp files
create_split ${pkg_fake_root_dev_dir} "(/pkgconfig|/include|\.h|\.hpp)$"

10
bin/create-split-doc Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
. $(dirname $(which create-split-man))/create-split.subr
# Usage: create-split-doc
# For documentation, move any file or directory matching:
# - "/share/doc"
create_split ${pkg_fake_root_doc_dir} "/share/doc/"

9
bin/create-split-libs Executable file
View File

@ -0,0 +1,9 @@
#!/bin/sh
. $(dirname $(which create-split-man))/create-split.subr
# Usage: create-split-libs
# For library split, move .a files (static libraries).
create_split ${pkg_fake_root_libs_dir} "\.a$"

10
bin/create-split-man Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
. $(dirname $(which create-split-man))/create-split.subr
# Usage: create-split-man
# For manuals, move any file or directory matching
# "/share/man"
create_split ${pkg_fake_root_man_dir} "/share/man"

10
bin/create-split-src Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
# Usage: create-split-src
# Currently in ${pkg_fake_root_dir}
# Should send files in ${pkg_fake_root_src_dir}
# First, list files
find . | while read F; do
done

31
bin/create-split.subr Normal file
View File

@ -0,0 +1,31 @@
#!/bin/sh
move_content(){
new_root=$1
content=$2
# Recreate the whole path into the new directory.
new_dir="${new_root}/$(dirname $content)"
[ -d "${new_dir}" ] || (
echo mkdir -p "${new_dir}"
mkdir -p "${new_dir}"
)
mv -v "${content}" "${new_dir}"
}
# usage: create_split new_root regex [regex...]
create_split(){
new_root=$1 ; shift
find . | while read F; do
if [ -e "${F}" ]; then
for regex in $* ; do
echo $F | grep -E "${regex}" >/dev/null 2>/dev/null
if [ $? -eq 0 ] ; then
move_content "${new_root}" "${F}"
fi
: # Do not end the function with a potential error.
done
fi
done
}

View File

@ -65,7 +65,7 @@ pkg_build_par_dir = $(pkg_working_dir)/build/
pkg_build_dir = $(pkg_build_par_dir)/$(name)-$(version) pkg_build_dir = $(pkg_build_par_dir)/$(name)-$(version)
pkg_fake_root_dir = $(pkg_working_dir)/root pkg_fake_root_dir = $(pkg_working_dir)/root
pkg_working_log = $(WORKING_DIR)/$(UUID).log log_file = $(WORKING_DIR)/$(UUID).log
# shortcut # shortcut
bdir ?= $(pkg_build_dir) bdir ?= $(pkg_build_dir)
@ -84,7 +84,7 @@ download_tool ?= wget
# #
pre_configure pre_build pre_fake_root_install post_fake_root_install: pre_configure pre_build pre_fake_root_install post_fake_root_install:
@echo $@ => do nothing @echo "$@ => do nothing"
# #
# Misc # Misc
@ -96,8 +96,9 @@ create_source_dir:
create_build_dir: create_build_dir:
mkdir -p $(pkg_build_par_dir) mkdir -p $(pkg_build_par_dir)
mkdir -p $(pkg_fake_root_dir) mkdir -p $(pkg_fake_root_dir)
create_repository_dir:
mkdir -p $(repository_directory)/$(ARCH)
# TODO: use these targets
# Clean directories # Clean directories
clean_build_dir: clean_build_dir:
$(keep_build_env) || rm -rf $(pkg_build_par_dir) $(keep_build_env) || rm -rf $(pkg_build_par_dir)
@ -212,40 +213,50 @@ package_base = $(repository_directory)/$(ARCH)/$(name)-$(version)-r$(release).$(
package_base: $(package_base) package_base: $(package_base)
$(package_base): $(package_base):
@echo "Packaging $@" @echo "Packaging $@"
@# strip binaries
cd $(pkg_fake_root_dir) && find . -type f | while read F ; do strip $F 2>/dev/null ; done ; :
cd $(pkg_fake_root_dir) && create-package $@ cd $(pkg_fake_root_dir) && create-package $@
pkg_fake_root_src_dir = $(pkg_fake_root_dir)-src export pkg_fake_root_src_dir = $(pkg_fake_root_dir)-src
pkg_fake_root_man_dir = $(pkg_fake_root_dir)-man export pkg_fake_root_doc_dir = $(pkg_fake_root_dir)-doc
pkg_fake_root_dev_dir = $(pkg_fake_root_dir)-dev export pkg_fake_root_man_dir = $(pkg_fake_root_dir)-man
pkg_fake_root_doc_dir = $(pkg_fake_root_dir)-doc export pkg_fake_root_dev_dir = $(pkg_fake_root_dir)-dev
export pkg_fake_root_libs_dir = $(pkg_fake_root_dir)-libs
# src split
package_src = $(repository_directory)/$(ARCH)/$(name)-src-$(version)-r$(release).$(baguette_ext) package_src = $(repository_directory)/$(ARCH)/$(name)-src-$(version)-r$(release).$(baguette_ext)
package_src: $(package_src) package_src: $(package_src)
$(package_src): $(package_src):
@echo "Packaging $@" @echo "Packaging $@ (work in progress)"
cd $(pkg_fake_root_src_dir) && dependencies="" conflicts="" provides="" create-package $@ @#cd $(pkg_fake_root_dir) && create-split-src
@#cd $(pkg_fake_root_src_dir) && dependencies="" conflicts="" provides="" create-package $@
# doc split
package_doc = $(repository_directory)/$(ARCH)/$(name)-doc-$(version)-r$(release).$(baguette_ext) package_doc = $(repository_directory)/$(ARCH)/$(name)-doc-$(version)-r$(release).$(baguette_ext)
package_doc: $(package_doc) package_doc: $(package_doc)
$(package_doc): $(package_doc):
@echo "Packaging $@" @echo "Packaging $@"
cd $(pkg_fake_root_src_dir) && dependencies="" conflicts="" provides="" create-package $@ cd $(pkg_fake_root_dir) && create-split-doc
cd $(pkg_fake_root_doc_dir) && dependencies="" conflicts="" provides="" create-package $@
# man split
package_man = $(repository_directory)/$(ARCH)/$(name)-man-$(version)-r$(release).$(baguette_ext) package_man = $(repository_directory)/$(ARCH)/$(name)-man-$(version)-r$(release).$(baguette_ext)
package_man: $(package_man) package_man: $(package_man)
$(package_man): $(package_man):
@echo "Packaging $@" @echo "Packaging $@"
cd $(pkg_fake_root_src_dir) && dependencies="" conflicts="" provides="" create-package $@ cd $(pkg_fake_root_dir) && create-split-man
cd $(pkg_fake_root_man_dir) && dependencies="" conflicts="" provides="" create-package $@
# dev split
package_dev = $(repository_directory)/$(ARCH)/$(name)-dev-$(version)-r$(release).$(baguette_ext) package_dev = $(repository_directory)/$(ARCH)/$(name)-dev-$(version)-r$(release).$(baguette_ext)
package_dev: $(package_dev) package_dev: $(package_dev)
$(package_dev): $(package_dev):
@echo "Packaging $@" @echo "Packaging $@"
cd $(pkg_fake_root_src_dir) && dependencies="" conflicts="" provides="" create-package $@ cd $(pkg_fake_root_dir) && create-split-dev
cd $(pkg_fake_root_dev_dir) && dependencies="" conflicts="" provides="" create-package $@
package_libs = $(repository_directory)/$(ARCH)/$(name)-libs-$(version)-r$(release).$(baguette_ext)
package_libs: $(package_libs)
$(package_libs):
@echo "Packaging $@"
cd $(pkg_fake_root_dir) && create-split-libs
cd $(pkg_fake_root_libs_dir) && dependencies="" conflicts="" provides="" create-package $@
check_binaries_wget_or_ftp: check_binaries_wget_or_ftp:
@ -256,9 +267,12 @@ check_binaries_zip:
@which unzip @which unzip
check_binaries: check_binaries_wget_or_ftp check_binaries_tar check_binaries_zip check_binaries: check_binaries_wget_or_ftp check_binaries_tar check_binaries_zip
splits: package_src package_doc package_man package_dev package_base splits: package_src package_doc package_man package_dev package_libs
# The main package is the last to be created since it includes
# all content that wasn't matched by splits.
packages: create_repository_dir splits package_base
getting-build-env: check_binaries download extract getting-build-env: check_binaries download extract
create: getting-build-env configure build fake_root_install splits clean_working_dir create: getting-build-env configure build fake_root_install packages clean_working_dir
# Targets not representing a file on the FS. # Targets not representing a file on the FS.