diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/README.busybox | 10 | ||||
-rw-r--r-- | tools/inc/colors | 17 | ||||
-rw-r--r-- | tools/inc/files.config | 2 | ||||
-rw-r--r-- | tools/inc/files.core | 11 | ||||
-rw-r--r-- | tools/inc/files.share | 9 | ||||
-rw-r--r-- | tools/inc/perl.modules.base | 29 | ||||
l--------- | tools/inc/perl.modules.debian | 1 | ||||
-rw-r--r-- | tools/inc/perl.modules.ubuntu | 29 | ||||
-rwxr-xr-x | tools/installer | 563 | ||||
-rwxr-xr-x | tools/mksquashfs | bin | 88416 -> 0 bytes | |||
-rw-r--r-- | tools/mksquashfs-filter-patch | 201 | ||||
-rwxr-xr-x | tools/uclibc-wrapper | 28 | ||||
-rwxr-xr-x | tools/updateDistroInfo.suse | 347 |
13 files changed, 1008 insertions, 239 deletions
diff --git a/tools/README.busybox b/tools/README.busybox deleted file mode 100644 index 9c12a65b..00000000 --- a/tools/README.busybox +++ /dev/null @@ -1,10 +0,0 @@ -How busybox (version 1.13.2) is created: - -1. Get our current sources from openslx-src-tools/trunk/busybox -2. bind mount the busybox folder to the correspoding uclibc-build-environment - folder (see http://www.openslx.org/wiki/openslx/GentooUclibcChroot for - how to create such an environment) -3. chroot into the uclibc-build-environment -4. cd into the bind-mounted busybox folder -5. make oldconfig and adjust the configuration if required. -6. build busybox (make) diff --git a/tools/inc/colors b/tools/inc/colors new file mode 100644 index 00000000..984a8640 --- /dev/null +++ b/tools/inc/colors @@ -0,0 +1,17 @@ +Black='\e[0;30m' +DarkGray='\e[1;30m' +Blue='\e[0;34m' +LightBlue='\e[1;34m' +Green='\e[0;32m' +LightGreen='\e[1;32m' +Cyan='\e[0;36m' +LightCyan='\e[1;36m' +Red='\e[0;31m' +LightRed='\e[1;31m' +Purple='\e[0;35m' +LightPurple='\e[1;35m' +Brown='\e[0;33m' +Yellow='\e[1;33m' +LightGray='\e[0;37m' +White='\e[1;37m' +NC='\e[0m' # No Color
\ No newline at end of file diff --git a/tools/inc/files.config b/tools/inc/files.config new file mode 100644 index 00000000..f739624a --- /dev/null +++ b/tools/inc/files.config @@ -0,0 +1,2 @@ +f boot-env/syslinux/pxemenu-*.example /boot-env/syslinux/ +f boot-env/syslinux/README.pxe /boot-env/syslinux/ diff --git a/tools/inc/files.core b/tools/inc/files.core new file mode 100644 index 00000000..38961cee --- /dev/null +++ b/tools/inc/files.core @@ -0,0 +1,11 @@ +f bin/slx* /bin/ +f config-db/slx* /bin/ +f installer/slx* /bin/ +f os-plugins/slx* /bin/ +f tools/uclibc-wrapper /bin/ +d lib/OpenSLX /lib/ +d boot-env/OpenSLX /lib/ +d config-db/OpenSLX /lib/ +d installer/OpenSLX /lib/ +d os-plugins/OpenSLX /lib/ +d os-plugins/plugins /lib/ diff --git a/tools/inc/files.share b/tools/inc/files.share new file mode 100644 index 00000000..ede02d08 --- /dev/null +++ b/tools/inc/files.share @@ -0,0 +1,9 @@ +d initramfs/stage3-stuff /share/initramfs/ +d initramfs/tools /share/ramfstools/ +d initramfs/distro-specs /share/ +d initramfs/uclib-rootfs /share/ +d boot-env /share/ +d initramfs/tpm /share/ +f tools/mksquashfs /share/squashfs/mksquashfs_3_2 +f initramfs/eglibc-packages/mksquashfs/usr/bin/mksquashfs_3_3 /share/squashfs/ +f initramfs/eglibc-packages/mksquashfs/usr/bin/mksquashfs_4 /share/squashfs/ diff --git a/tools/inc/perl.modules.base b/tools/inc/perl.modules.base new file mode 100644 index 00000000..6e6febd1 --- /dev/null +++ b/tools/inc/perl.modules.base @@ -0,0 +1,29 @@ +Carp +Clone +Config::General +Data::Dumper +Cwd +DBI +Digest::MD5 +Digest::SHA1 +Encode +Exporter +Fcntl +File::Basename +File::Find +File::Glob +File::Path +FindBin +Getopt::Long +HTTP::Request::Common +JSON +LWP::UserAgent +List::Util +MIME::Base64 +Pod::Usage +POSIX +Scalar::Util +Socket +Storable +Sys::Hostname +Term::ReadLine
\ No newline at end of file diff --git a/tools/inc/perl.modules.debian b/tools/inc/perl.modules.debian new file mode 120000 index 00000000..61f9d24c --- /dev/null +++ b/tools/inc/perl.modules.debian @@ -0,0 +1 @@ +perl.modules.ubuntu
\ No newline at end of file diff --git a/tools/inc/perl.modules.ubuntu b/tools/inc/perl.modules.ubuntu new file mode 100644 index 00000000..2a520b01 --- /dev/null +++ b/tools/inc/perl.modules.ubuntu @@ -0,0 +1,29 @@ +Carp perl-base +Clone libclone-perl +Config::General libconfig-general-perl +Data::Dumper perl +Cwd perl-base +DBI libdbi-perl +Digest::MD5 perl +Digest::SHA1 libdigest-sha1-perl +Encode perl +Exporter perl-base +Fcntl perl-base +File::Basename perl-modules +File::Find perl-modules +File::Glob perl-base +File::Path perl-modules +FindBin perl-modules +Getopt::Long perl-base +HTTP::Request::Common libwww-perl +JSON libjson-perl +LWP::UserAgent libwww-perl +List::Util perl-base +MIME::Base64 perl +Pod::Usage perl-modules +POSIX perl-base +Scalar::Util perl-base +Socket perl-base +Storable perl +Sys::Hostname perl +Term::ReadLine perl-modules
\ No newline at end of file diff --git a/tools/installer b/tools/installer new file mode 100755 index 00000000..80a380ad --- /dev/null +++ b/tools/installer @@ -0,0 +1,563 @@ +#!/bin/bash + +# include fancy bash color stuff +. tools/inc/colors + + +# determin distribution +DISTRO=$(lsb_release -i| sed 's/^[^:]*:\t//' | tr '[:upper:]' '[:lower:]') + +# get/set default paths +[ -z $USR_BIN_PATH ] && USR_BIN_PATH=/usr/bin +[ -z $SLX_CONFIG_PATH ] && SLX_CONFIG_PATH=/etc/opt/openslx +[ -z $SLX_BASE_PATH ] && SLX_BASE_PATH=/opt/openslx +[ -z $SLX_PRIVATE_PATH ] && SLX_PRIVATE_PATH=/var/opt/openslx +[ -z $SLX_PUBLIC_PATH ] && SLX_PUBLIC_PATH=/srv/openslx +[ -z $SLX_TEMP_PATH ] && SLX_TEMP_PATH=/tmp +[ -z $SLX_INSTALL_LOG ] && SLX_INSTALL_LOG=install.log + +PREPARE_INSTALL_TARGET="./_install/" + + + +# helper functions: +git_version() +{ + if [ -d .git ]; then + GITVERSION=`git describe` + GITMODIFIED=`(git status | grep "modified:\|added:\|deleted:" -q) && echo "-M"` + echo $GITVERSION$GITMODIFIED + echo $GITVERSION > VERSION + else + cat VERSION + fi +} + +check_perl() +{ + echo -n " * checking perl" + if ! perl -e '$x=42' 2>>${SLX_INSTALL_LOG} ; then + echo -e " [${LightRed}failed${NC}]" + echo " Perl is required, please install it."; + exit 1; + else + echo -e " [${LightGreen}ok${NC}]" + fi; +} + + +check_perl_dep() +{ + echo -n " * checking perl module dependencies" + PERL_MODULES=$(cat tools/inc/perl.modules.base) + [ -e .perl_modules_missing ] && rm .perl_modules_missing + [ -e .perl_deps_guess ] && rm .perl_deps_guess + for pm in $PERL_MODULES; do + perl -e "use $pm" 2>>/dev/null || echo $pm >> .perl_modules_missing; + done + if [ -e .perl_modules_missing ]; then + echo -e " [${LightRed}failed${NC}]" + echo " Following perl modules are required and could not be found on your system:" + for pm in $(cat .perl_modules_missing); do + echo -n " $pm" + if [ -e tools/inc/perl.modules.$DISTRO ]; then + GUESS_INSTALL=$(cat tools/inc/perl.modules.$DISTRO|grep $pm| awk '{print $2}') + if [ ! -z $GUESS_INSTALL ]; then + echo " ($GUESS_INSTALL)" + echo "$GUESS_INSTALL" >> .perl_deps_guess + else + echo "" + fi + else + echo "" + fi + done + if [ -e .perl_deps_guess ]; then + echo " To install the missing dependencies run:" + echo -n " apt-get install" + for d in $(cat .perl_deps_guess | sort -u); do + echo -n " $d" + done + echo "" + exit 1 + fi + else + echo -e " [${LightGreen}ok${NC}]" + fi +} + +check_perl_db() +{ + echo -n " * checking perl db abstraction" + DEFAULT_DB_TYPE=""; + if test -e ${SLX_CONFIG_PATH}/settings; then + sed ${SLX_CONFIG_PATH}/settings -e "s,=,=\"," -e "s,$,\"," > /tmp/slxsettings; + . /tmp/slxsettings; + rm /tmp/slxsettings; + fi; + + for m in ${SLX_DB_TYPE} SQLite mysql; do + if ! perl -Isrc/lib -Isrc/config-db -e "use OpenSLX::MetaDB::$m" 2>>${SLX_INSTALL_LOG} ; then + echo -e " 'DBD::$m' not found (or too old), so $m-databases will not be supported."; + else + if test "${DEFAULT_DB_TYPE}X" = "X"; then + DEFAULT_DB_TYPE=$m; + echo -e " [${LightGreen}ok${NC}]" + echo " * selected db backend: $m"; + break; + fi; + fi; + done; + if test "${DEFAULT_DB_TYPE}X" = "X"; then + echo -e " [${LightRed}failed${NC}]" + echo " None of the DB-modules is available! Please install one of them."; + exit 1; + else + echo $${DEFAULT_DB_TYPE} >DEFAULT-DB-TYPE; + fi; +} + +check_helper_apps() +{ + echo -n " * checking for required linux tools" + if ! which rsync >/dev/null 2>&1; then + echo -e " [${LightRed}failed${NC}]" + echo " rsync is required, please install it."; + exit 1; + fi; + echo -e " [${LightGreen}ok${NC}]" +} + +_install(){ + FILE=$1 + BASE_TARGET=$2 + ADDOPTS=$3 + [ "$BASE_TARGET" = "config" ] && BASE_TARGET_PATH=${PREPARE_INSTALL_TARGET}${SLX_CONFIG_PATH} + [ "$BASE_TARGET" = "base" ] && BASE_TARGET_PATH=${INSTALL_BASE} + while read TYPE SOURCE TARGET; do + if [ "$TYPE" = "f" ]; then + cp src/${SOURCE} ${BASE_TARGET_PATH}/${TARGET} + elif [ "$TYPE" = "d" ]; then + SOURCE_DIRNAME=$(echo $SOURCE | sed -e 's,^.*/,,' ) + SOURCE_BASE=$(echo $SOURCE | sed -e 's,\(^.*/\).*,\1,') + [ "$SOURCE_DIRNAME" = "$SOURCE" ] && SOURCE_BASE="" + tar -cp $ADDOPTS -C src/${SOURCE_BASE} ${SOURCE_DIRNAME} \ + | tar -xp -C ${BASE_TARGET_PATH}/$TARGET + fi + done < $FILE + +} + +prepare_install() +{ + echo -n " * prepare OpenSLX installation" + [ "${TRACE_INSTALLATION}" = "1" ] && set -x + INSTALL_BASE=${PREPARE_INSTALL_TARGET}${SLX_BASE_PATH} + [ -e $PREPARE_INSTALL_TARGET ] && rm -rf $PREPARE_INSTALL_TARGET + mkdir -p ${PREPARE_INSTALL_TARGET} + mkdir -p ${PREPARE_INSTALL_TARGET}${SLX_CONFIG_PATH}/boot-env/syslinux/themes \ + -p ${INSTALL_BASE}/lib \ + -p ${INSTALL_BASE}/bin \ + -p ${INSTALL_BASE}/share/boot-env \ + -p ${INSTALL_BASE}/share/initramfs \ + -p ${INSTALL_BASE}/share/squashfs \ + -p ${INSTALL_BASE}/share/templates \ + -p ${INSTALL_BASE}/share/ramfstools \ + -p ${PREPARE_INSTALL_TARGET}${USR_BIN_PATH} \ + -p ${PREPARE_INSTALL_TARGET}/lib; + + # copy license + cp COPYING ${INSTALL_BASE}/ + + #### copy OpenSLX perl scripts & required modules #### + _install ./tools/inc/files.core base + + #### copy OpenSLX shared data #### + opts="--exclude=OpenSLX --exclude=*.example" # --strip-components 1" + _install ./tools/inc/files.share base $opts + + #### copy OpenSLX config data #### + opts="--exclude=OpenSLX" + _install ./tools/inc/files.config config $opts + + # copy distro-info + tar --exclude=*.example -cp -C src/lib distro-info \ + | tar -xp -C ${PREPARE_INSTALL_TARGET}${SLX_BASE_PATH}/share + tar --exclude=prereqfiles --exclude=trusted-package-keys/* \ + --exclude=*.default --exclude=mirrors \ + -cp -C src/lib distro-info \ + | tar -xp -C ${PREPARE_INSTALL_TARGET}${SLX_CONFIG_PATH} + + ### link slx binarires ### + ln -sf ${SLX_BASE_PATH}/bin/slx* ${PREPARE_INSTALL_TARGET}${USR_BIN_PATH}/ + + ### deprecated.. ### + ln -sf ${SLX_BASE_PATH}/share/uclib-rootfs/lib/ld-uClibc.so.0 \ + ${PREPARE_INSTALL_TARGET}/lib/ld-uClibc.so.0 + + echo -e " [${LightGreen}ok${NC}]" + +} + +make_install_tarball() +{ + local COMPRESSION=$1 + local ALTERNATIVE_PREFIX=$2 + [ "x$COMPRESSION" = "x" ] && \ + echo -n " * create OpenSLX install tarball" + [ "x$COMPRESSION" = "x" ] || \ + echo -n " * create OpenSLX install tarball (compressed with $COMPRESSION)" + VERSIONSTRING="openslx-$(git_version)" + if [ ! -f $VERSIONSTRING.tar ]; then + cd $PREPARE_INSTALL_TARGET + if [ "x$ALTERNATIVE_PREFIX" = "x" ]; then + OPT="" + else + OPT=" --transform \"s,^,/$ALTERNATIVE_PREFIX/,S\" " + fi + #HACK .. otherwise tar doesn't like parameters.. + CMD="tar $OPT -c -f ../$VERSIONSTRING.tar *" + sh -c "$CMD" + cd - 2>&1 >/dev/null + fi + COMPRESSION_KEEP_ORIG="-k" + [ "x$COMPRESSION" = "xgzip" ] && COMPRESSION_KEEP_ORIG="" + [ "x$COMPRESSION" = "x" ] || $COMPRESSION -f $COMPRESSION_KEEP_ORIG $VERSIONSTRING.tar + echo -e " [${LightGreen}ok${NC}]" +} + +make_source_tarball() +{ + local COMPRESSION=$1 + local ALTERNATIVE_PREFIX=$2 + [ "x$COMPRESSION" = "x" ] && \ + echo -n " * create OpenSLX source tarball" + [ "x$COMPRESSION" = "x" ] || \ + echo -n " * create OpenSLX source tarball (compressed with $COMPRESSION)" + VERSIONSTRING="openslx-$(git_version)-src" + if [ "x$ALTERNATIVE_PREFIX" = "x" ]; then + PREFIX="openslx-$(git_version)-src" + else + PREFIX=$ALTERNATIVE_PREFIX + fi + git archive --format=tar --prefix=$PREFIX/ -o $VERSIONSTRING.tar HEAD + [ "x$COMPRESSION" = "x" ] || $COMPRESSION -f $VERSIONSTRING.tar + echo -e " [${LightGreen}ok${NC}]" +} + +prepare_upgrade() +{ + echo -n " * cleanup old OpenSLX installation before upgrade" + rm -rf ${SLX_BASE_PATH} + rm -f ${USR_BIN_PATH}/slx* + echo -e " [${LightGreen}ok${NC}]" +} + +do_install() +{ + echo -n " * installing OpenSLX" + if [ ! "$(whoami)" = "root" ]; then + echo -e " [${LightRed}failed${NC}]" + echo " you need to be root" + exit 1 + fi + check_upgrade + make_install_tarball + VERSIONSTRING="openslx-$(git_version)" + check_upgrade + INSTALL_HOME=$(pwd) + cd ${SLX_BUILD_PATH}/; tar xf $INSTALL_HOME/$VERSIONSTRING.tar + cd $INSTALL_HOME +} + +uninstall() +{ + echo -n " * Uninstalling OpenSLX project files but keeping configs and stage1" + rm -rf ${SLX_BASE_PATH} + rm -rf ${SLX_PUBLIC_PATH} + rm -f ${USR_BIN_PATH}/slx* + rm -f /lib/ld-uClibc.so.0 + echo -e " [${LightGreen}ok${NC}]" + echo " left config files in ${SLX_CONFIG_PATH} untouched" + echo " left config files in ${SLX_PRIVATE_PATH} untouched" +} + +mrproper() +{ + echo -n " * Wiping all!" + rm -rf ${SLX_BASE_PATH} + rm -rf ${SLX_CONFIG_PATH} + rm -rf ${SLX_PRIVATE_PATH} + rm -rf ${SLX_PUBLIC_PATH} + rm -f ${USR_BIN_PATH}/slx* + echo -e " [${LightGreen}ok${NC}]" +} + +check_upgrade() +{ + # find out if there is an older version installed and, if so, clean that + INSTALLED_VERSION=$(slxversion 2>/dev/null) + if ! test -z "${INSTALLED_VERSION}"; then + if test -e REVISION; then + . REVISION + else + OPENSLX_VERSION_REV=$(git_version) + fi; + test "${OPENSLX_SVN_SNAPSHOT}" = "0" && + unset OPENSLX_SVN_SNAPSHOT || OPENSLX_SVN_SNAPSHOT="1" + . ./VERSIONS; + if test ${INSTALLED_VERSION} != ${OPENSLX_VERSION_STRING}; then + echo " * preparing upgrade from version (${INSTALLED_VERSION})" + prepare_upgrade; + fi; + fi +} + +postinstall() +{ + # create default config folder hierarchy: +# perl -Ilib -e 'use OpenSLX::ConfigFolder; createConfigFolderForDefaultSystem();' +# +# # create complete default settings and empty local settings file: +# echo -e "# default setup for OpenSLX-installation\ +#\n\ +#\n# paths that are fixed at packaging/installation time:\ +#\nSLX_BASE_PATH=${SLX_BASE_PATH}\ +#\nSLX_CONFIG_PATH=${SLX_CONFIG_PATH}\ +#\n\ +#\n# paths which can be adjusted after installation:\ +#\nSLX_PRIVATE_PATH=${SLX_PRIVATE_PATH}\ +#\nSLX_PUBLIC_PATH=${SLX_PUBLIC_PATH}\ +#\nSLX_TEMP_PATH=${SLX_TEMP_PATH}\n" \ +# > $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/share/settings.default; \ +# test -e $(SLX_BUILD_PATH)$(SLX_CONFIG_PATH)/settings || \ +# echo -e "# Local setup for OpenSLX (overrides default settings).\ +#\n#\n# Please look at $(SLX_BASE_PATH)/share/settings.default and the docs to learn\ +#\n# about the available options.\n" \ +# > $(SLX_BUILD_PATH)$(SLX_CONFIG_PATH)/settings; \ +# +# @ # create slxversion script: +# @if test -e REVISION; then \ +# . REVISION; \ +# else \ +# OPENSLX_VERSION_SVNREV=$$(svnversion .); \ +# fi; \ +# test "$${OPENSLX_SVN_SNAPSHOT}" = "0" && \ +# unset OPENSLX_SVN_SNAPSHOT || \ +# OPENSLX_SVN_SNAPSHOT="1"; \ +# . ./VERSIONS; \ +# echo -e "#! /bin/sh\n\necho $${OPENSLX_VERSION_STRING}" \ +# > $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/bin/slxversion; \ +# chmod a+x $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/bin/slxversion; \ +# ln -sf $(SLX_BASE_PATH)/bin/slxversion $(SLX_BUILD_PATH)$(USR_BIN_PATH)/; \ +# +# @ # set default db-type: +# @DEFAULT_DB_TYPE=$$(cat DEFAULT-DB-TYPE); \ +# rm DEFAULT-DB-TYPE; \ +# echo -n ' '; slxsettings set db-type="$${DEFAULT_DB_TYPE}"; +echo "123" +} + +build_dpkg_package() +{ + make_install_tarball + + dpkg_deb=`which dpkg-deb` + if [ -z "$dpkg_deb" ];then + echo "You need the program dpkg-deb (contained in package dpkg) to build a debian package" + exit + fi + + # import default paths for debian installation + . ./packaging/dpkg/debianpaths + + # change into folder where we expect the Makefile: + if [ ! -e ./Makefile ]; then + echo "There is no makefile in this programs directory (`pwd`)." + echo "Please run this script only embedded in the context of an openslx checkout." + exit + fi + + echo -n " * Building DEB Package(s)" + + export SLX_DEPBUILD_PATH=/tmp/slx-dep-$$ + mkdir -p $SLX_DEPBUILD_PATH + + INSTALL_HOME=$(pwd) + VERSIONSTRING="openslx-$(git_version)" + + cd $SLX_DEPBUILD_PATH + tar xf $INSTALL_HOME/$VERSIONSTRING.tar + cd $INSTALL_HOME + + #Create Temporary working directory + mkdir -p $SLX_DEPBUILD_PATH/DEBIAN + cp packaging/dpkg/default_files/control $SLX_DEPBUILD_PATH/DEBIAN/ + cp packaging/dpkg/default_files/pre* $SLX_DEPBUILD_PATH/DEBIAN/ + cp packaging/dpkg/default_files/post* $SLX_DEPBUILD_PATH/DEBIAN/ + + OPENSLX_VERSION=$(git describe) + + + sed -i -e "4r./packaging/dpkg/debianpaths" \ + $SLX_DEPBUILD_PATH/DEBIAN/postinst + + #update control file + sed -e "s/##version##/$OPENSLX_VERSION/" \ + -e "s/##size##/$(du -s $SLX_BUILD_PATH | awk '{print $1}')/" \ + -i $SLX_DEPBUILD_PATH/DEBIAN/control + + #Set permissions + find $SLX_DEPBUILD_PATH -type d|xargs chmod 755 + + #Create the package + dpkg-deb --build $SLX_DEPBUILD_PATH > /dev/null + cd packaging/dpkg + + echo -e " [${LightGreen}ok${NC}]" + + mkdir -p $INSTALL_HOME/pkgs/ + sh -c "find $SLX_DEPBUILD_PATH/ -iname \"*.deb\" -exec cp {} $INSTALL_HOME/pkgs/ \;" + cd $INSTALL_HOME + rm -rf $SLX_DEPBUILD_PATH +} + +build_rpm_package() +{ + + INSTALL_HOME=$(pwd) + VERSIONSTRING="openslx-$(git_version)" + + OPENSLX_VERSION=$(git describe | sed -e 's/-.*$//' -e 's/^v//') + OPENSLX_REVISION=$(git_version | sed -e 's/[^-]*-//' -e 's/-/_/g') + + rpm_builder=`which rpmbuild` + if [ -z "$rpm_builder" ];then + echo "You need the program rpmbuild (contained in package ?!?) to build a rpm package" + exit + fi + + # change into folder where we expect the Makefile: + if [ ! -e ./Makefile ]; then + echo "There is no makefile in this programs directory (`pwd`)." + echo "Please run this script only embedded in the context of an openslx checkout." + exit + fi + + export SLX_RPMBUILD_PATH=/tmp/slx-rpm-$$ + mkdir -p $SLX_RPMBUILD_PATH + mkdir -p $SLX_RPMBUILD_PATH/{BUILD,RPMS,SOURCES,SPECS,SRPMS} + + #make_source_tarball gzip "openslx-$OPENSLX_VERSION" + #make_install_tarball + #tar -tf $VERSIONSTRING.tar > $SLX_RPMBUILD_PATH/FILES + #sed -i $SLX_RPMBUILD_PATH/FILES -e 's,^,/,' + + [ -f $VERSIONSTRING.tar ] && rm $VERSIONSTRING.tar + make_install_tarball gzip "openslx-$OPENSLX_VERSION" + + mv $VERSIONSTRING.tar.gz $SLX_RPMBUILD_PATH/SOURCES/openslx-v$OPENSLX_VERSION-$OPENSLX_REVISION.tar.gz + + echo -n " * Building RPM Package(s)" + + #update control file + sed -e "s/###version###/$OPENSLX_VERSION/" \ + -e "s/###release###/$OPENSLX_REVISION/" \ + -e "/###authors###/r AUTHORS" \ + -e "/###authors###/d" \ + packaging/rpm/openslx.spec \ + > $SLX_RPMBUILD_PATH/SPECS/openslx.spec + [ "x$ARCH" = "x" ] || ARCH="--target=$ARCH" + rpmbuild --nodeps -ba --define "_topdir $SLX_RPMBUILD_PATH" \ + $SLX_RPMBUILD_PATH/SPECS/openslx.spec >>${SLX_INSTALL_LOG} 2>&1 + + if [ "$(ls -1 $SLX_RPMBUILD_PATH/RPMS)" = "x86_64" ]; then + rpmbuild --target="i386" --nodeps -ba --define "_topdir $SLX_RPMBUILD_PATH" \ + $SLX_RPMBUILD_PATH/SPECS/openslx.spec >>${SLX_INSTALL_LOG} 2>&1 + fi + + echo -e " [${LightGreen}ok${NC}]" + + mkdir -p $INSTALL_HOME/pkgs/ + echo "find $SLX_RPMBUILD_PATH/RPMS/ -iname *.rpm -exec cp {} $INSTALL_HOME/pkgs/ \;" + sh -c "find $SLX_RPMBUILD_PATH/RPMS/ -iname \"*.rpm\" -exec cp {} $INSTALL_HOME/pkgs/ \;" + rm -rf $SLX_RPMBUILD_PATH + +} + +clean() +{ + echo -n " * Cleanup OpenSLX source directory" + for file in ${SLX_INSTALL_LOG} openslx-*.tar.bz2; do + rm -f ${file} + done + echo -e " [${LightGreen}ok${NC}]" +} + +cmd_usage() +{ + echo "Usage: ..." + echo " plain-install" + echo " install" + echo " build_rpm" + echo " build_deb" +} + +cmd_plain_install() +{ + echo "running plain install:" + prepare_install + do_install +} + +cmd_install() +{ + echo "running full install" + check_perl + check_perl_dep + check_perl_db + check_helper_apps + prepare_install + do_install +} + +cmd_build_rpm() +{ + echo "creating rpm package(s)" + build_rpm_package +} + +cmd_build_dep() +{ + echo "creating deb package" + build_dpkg_package +} + + +case "$1" in + "plain-install") + cmd_plain_install + ;; + "install") + cmd_install + ;; + "build-rpm") + cmd_build_rpm + ;; + "build-dep") + cmd_build_dep + ;; + *) + cmd_usage + ;; +esac + +#make_install_tarball +#make_install_tarball gzip +#make_install_tarball bzip2 +#make_install_tarball lzma +#make_source_tarball +#make_source_tarball gzip +#make_source_tarball bzip2 +#make_source_tarball lzma +#git_version
\ No newline at end of file diff --git a/tools/mksquashfs b/tools/mksquashfs Binary files differdeleted file mode 100755 index e65a35a5..00000000 --- a/tools/mksquashfs +++ /dev/null diff --git a/tools/mksquashfs-filter-patch b/tools/mksquashfs-filter-patch deleted file mode 100644 index 5cb4ba24..00000000 --- a/tools/mksquashfs-filter-patch +++ /dev/null @@ -1,201 +0,0 @@ ---- squashfs-tools/mksquashfs.c 2007-01-16 09:24:40.000000000 +0100 -+++ squashfs-tools-vito/mksquashfs.c 2007-01-17 08:34:17.000000000 +0100 -@@ -44,6 +44,7 @@ - #include <sys/mman.h> - #include <pthread.h> - #include <math.h> -+#include <regex.h> - - #ifndef linux - #define __BYTE_ORDER BYTE_ORDER -@@ -162,15 +163,19 @@ - struct file_info *dupl[65536]; - int dup_files = 0; - --/* list of exclude dirs/files */ --struct exclude_info { -+/* list of include/exclude files/regexes */ -+struct filter_info { - dev_t st_dev; - ino_t st_ino; -+ regex_t *preg; -+ int action; - }; - --#define EXCLUDE_SIZE 8192 --int exclude = 0; --struct exclude_info *exclude_paths = NULL; -+#define EXCLUDE 0 -+#define INCLUDE 1 -+#define FILTER_SIZE 8192 -+int filter_count = 0; -+struct filter_info *filters = NULL; - int excluded(char *filename, struct stat *buf); - - /* fragment block data structures */ -@@ -2606,20 +2611,32 @@ - { - int i; - -- for(i = 0; i < exclude; i++) -- if((exclude_paths[i].st_dev == buf->st_dev) && (exclude_paths[i].st_ino == buf->st_ino)) -- return TRUE; -+ for(i = 0; i < filter_count; i++) { -+ struct filter_info f = filters[i]; -+ -+ if(f.preg == NULL) { -+ if((f.st_dev == buf->st_dev) && (f.st_ino == buf->st_ino)) -+ return TRUE; -+ } else if(regexec(f.preg, filename, (size_t)0, NULL, 0) == 0) -+ if(f.action == EXCLUDE) -+ return TRUE; -+ else -+ return FALSE; -+ } -+ - return FALSE; - } - - --#define ADD_ENTRY(buf) \ -- if(exclude % EXCLUDE_SIZE == 0) {\ -- if((exclude_paths = (struct exclude_info *) realloc(exclude_paths, (exclude + EXCLUDE_SIZE) * sizeof(struct exclude_info))) == NULL)\ -- BAD_ERROR("Out of memory in exclude dir/file table\n");\ -+#define ADD_ENTRY(b, a, p) \ -+ if(filter_count % FILTER_SIZE == 0) {\ -+ if((filters = (struct filter_info *) realloc(filters, (filter_count + FILTER_SIZE) * sizeof(struct filter_info))) == NULL)\ -+ BAD_ERROR("Out of memory in the include/exclude file/regex table\n");\ - }\ -- exclude_paths[exclude].st_dev = buf.st_dev;\ -- exclude_paths[exclude++].st_ino = buf.st_ino; -+ filters[filter_count].action = a;\ -+ filters[filter_count].preg = p;\ -+ filters[filter_count].st_dev = b.st_dev;\ -+ filters[filter_count++].st_ino = b.st_ino; - int add_exclude(char *path) - { - int i; -@@ -2632,7 +2649,7 @@ - perror(buffer); - return TRUE; - } -- ADD_ENTRY(buf); -+ ADD_ENTRY(buf, EXCLUDE, NULL); - return TRUE; - } - -@@ -2645,11 +2662,47 @@ - } - continue; - } -- ADD_ENTRY(buf); -+ ADD_ENTRY(buf, EXCLUDE, NULL); - } - return TRUE; - } - -+void add_pattern(char *pattern) -+{ -+ struct stat dummy; -+ int action = -1; -+ -+ if(pattern[0] == '#') -+ return; -+ -+ if(strlen(pattern) < 3) -+ goto bad_pattern; -+ -+ if(strncmp(pattern, "+ ", 2) == 0) -+ action = INCLUDE; -+ -+ if(strncmp(pattern, "- ", 2) == 0) -+ action = EXCLUDE; -+ -+ if(action != -1) { -+ regex_t *preg = (regex_t*)malloc(sizeof(regex_t)); -+ char message[1024]; -+ int error = regcomp(preg, pattern+2, REG_EXTENDED|REG_NOSUB); -+ regerror(error, preg, message, 1024); -+ -+ if(error) { -+ fprintf(stderr, "Ignoring invalid regex \"%s\" (%s)\n", pattern+2, message); -+ return; -+ } -+ -+ ADD_ENTRY(dummy, action, preg); -+ return; -+ } -+ -+bad_pattern: -+ fprintf(stderr, "Ignoring wrong filter pattern \"%s\"\n", pattern); -+} -+ - - void add_old_root_entry(char *name, squashfs_inode inode, int inode_number, int type) - { -@@ -2849,6 +2902,11 @@ - ERROR("%s: -ef missing filename\n", argv[0]); - exit(1); - } -+ } else if(strcmp(argv[i], "-ff") == 0) { -+ if(++i == argc) { -+ ERROR("%s: -ff missing filename\n", argv[0]); -+ exit(1); -+ } - } else if(strcmp(argv[i], "-no-duplicates") == 0) - duplicate_checking = FALSE; - -@@ -2991,6 +3049,10 @@ - ERROR("\t\t\tfile or dir with priority per line. Priority -32768 to\n"); - ERROR("\t\t\t32767, default priority 0\n"); - ERROR("-ef <exclude_file>\tlist of exclude dirs/files. One per line\n"); -+ ERROR("-ff <filter_file>\tlist of include/exclude patterns. One per line.\n"); -+ ERROR("\t\t\tThe first pattern that matches a dir/file is applied.\n"); -+ ERROR("\t\t\tExclude patterns are written '+ regex', include patterns\n"); -+ ERROR("\t\t\tare written '- regex'. Comments start with #\n"); - exit(1); - } - } -@@ -3048,7 +3110,7 @@ - signal(SIGINT, sighandler2); - } - -- /* process the exclude files - must be done afer destination file has been possibly created */ -+ /* process the include/exclude files/patterns - must be done afer destination file has been possibly created */ - for(i = source + 2; i < argc; i++) - if(strcmp(argv[i], "-ef") == 0) { - FILE *fd; -@@ -3060,6 +3122,16 @@ - while(fscanf(fd, "%16384[^\n]\n", filename) != EOF) - add_exclude(filename); - fclose(fd); -+ } else if(strcmp(argv[i], "-ff") == 0) { -+ FILE *fd; -+ char pattern[16385]; -+ if((fd = fopen(argv[++i], "r")) == NULL) { -+ perror("Could not open filter file..."); -+ EXIT_MKSQUASHFS(); -+ } -+ while(fscanf(fd, "%16384[^\n]\n", pattern) != EOF) -+ add_pattern(pattern); -+ fclose(fd); - } else if(strcmp(argv[i], "-e") == 0) - break; - else if(strcmp(argv[i], "-b") == 0 || strcmp(argv[i], "-root-becomes") == 0 || strcmp(argv[i], "-sort") == 0) -@@ -3073,14 +3145,14 @@ - while(i < argc && add_exclude(argv[i++])); - } - -- /* process the sort files - must be done afer the exclude files */ -+ /* process the sort files - must be done afer processing the include/exclude files/patterns */ - for(i = source + 2; i < argc; i++) - if(strcmp(argv[i], "-sort") == 0) { - read_sort_file(argv[++i], source, source_path); - sorted ++; - } else if(strcmp(argv[i], "-e") == 0) - break; -- else if(strcmp(argv[i], "-b") == 0 || strcmp(argv[i], "-root-becomes") == 0 || strcmp(argv[i], "-ef") == 0) -+ else if(strcmp(argv[i], "-b") == 0 || strcmp(argv[i], "-root-becomes") == 0 || strcmp(argv[i], "-ef") == 0 || strcmp(argv[i], "-ff") == 0) - i++; - - initialise_threads(); diff --git a/tools/uclibc-wrapper b/tools/uclibc-wrapper deleted file mode 100755 index 08934f32..00000000 --- a/tools/uclibc-wrapper +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh -# Copyright (c) 2008..2009 - OpenSLX GmbH -# -# This program is free software distributed under the GPL version 2. -# See http://openslx.org/COPYING -# -# If you have any feedback please consult http://openslx.org/feedback and -# send your feedback to feedback@openslx.org -# -# General information about OpenSLX can be found under http://openslx.org -# -# Wrapper script for OpenSLX environments used with server and client stage4 - -if [ -d /opt/openslx/share/uclib-rootfs ]; then - SLX_UCLIB_PATH=/opt/openslx/share/uclib-rootfs -elif [ -d /opt/openslx/uclib-rootfs ]; then - SLX_UCLIB_PATH=/opt/openslx/uclib-rootfs -else - echo "Can't find OpenSLX Environment." && exit 1 -fi - -[ -f /lib/ld-uClibc.so.0 ] || \ - ln -sf $SLX_PATH/uclib-rootfs/lib/ld-uClibc.so.0 /lib/ld-uClibc.so.0 - -PATH=$SLX_UCLIB_PATH/bin:$SLX_UCLIB_PATH/usr/bin:$SLX_UCLIB_PATH/sbin:\ -$SLX_UCLIB_PATH/usr/sbin -LD_LIBRARY_PATH=$SLX_UCLIB_PATH/lib:$SLX_UCLIB_PATH/usr/lib -LD_LIBRARY_PATH=$LD_LIBRARY_PATH PATH=$PATH PS1="#" $@ diff --git a/tools/updateDistroInfo.suse b/tools/updateDistroInfo.suse new file mode 100755 index 00000000..b877ab55 --- /dev/null +++ b/tools/updateDistroInfo.suse @@ -0,0 +1,347 @@ +#!/usr/bin/perl +# Copyright (c) 2009 - OpenSLX GmbH +# +# This program/file is free software distributed under the GPL version 2. +# See http://openslx.org/COPYING +# +# If you have any feedback please consult http://openslx.org/feedback and +# send your feedback to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org +# + +use strict; +use warnings; + +use threads ('yield', + 'stack_size' => 64*4096, + 'exit' => 'threads_only', + 'stringify'); +use Time::HiRes qw(sleep); +use Switch; +use Net::HTTP; +use Net::FTP; +#use Data::Dumper; + + +# Configuration ############################################################### + +my @supportedVersions = ( + { + ver => + '10.3', + source => + 'http://mirrors.opensuse.org/list/all.html', + supporedArch => + 'i586 x86_64', + packageKeysLocation => + 'http://download.opensuse.org/distribution/10.3/repo/oss/' + }, + { + ver => + '11.0', + source => + 'http://mirrors.opensuse.org/list/11.0.html', + supporedArch => + 'i586 x86_64', + packageKeysLocation => + 'http://download.opensuse.org/distribution/11.0/repo/oss/' + }, + { + ver => + '11.1', + source => + 'http://mirrors.opensuse.org/list/11.1.html', + supporedArch => + 'i586 x86_64', + packageKeysLocation => + 'http://download.opensuse.org/distribution/11.1/repo/oss/' + } + { + ver => + '11.2', + source => + 'http://mirrors.opensuse.org/list/11.2.html', + supporedArch => + 'i586 x86_64', + packageKeysLocation => + 'http://download.opensuse.org/distribution/11.2/repo/oss/' + } + { + ver => + '11.3', + source => + 'http://mirrors.opensuse.org/list/11.3.html', + supporedArch => + 'i586 x86_64', + packageKeysLocation => + 'http://download.opensuse.org/distribution/11.3/repo/oss/' + } +); + +my %sourceLists = ( + 'base' => + { + path => 'distribution/#ver#/repo/oss', + archpath => 'distribution/#ver#/repo/oss/suse/#arch#' + }, + 'base_non-oss' => + { + path => 'distribution/#ver#/repo/non-oss', + archpath => 'distribution/#ver#/repo/oss/suse/#arch#' + }, + 'base_update' => + { + path => 'update/#ver#', + archpath => 'update/#ver#/rpm/#arch#' + }, +); + +############################################################################### + +my $cmd; +my $out = {}; +my $statistics = {}; + +# set autoflush +$| = 1; + +sub checkHttpMirror { + my $checkurl = shift; + my $mirrorurl = shift; + my $outfile = shift; + + $SIG{'KILL'} = sub { threads->exit(); }; + + $checkurl = m/http:\/\/([^\/]*)(\/.*)/; + my $s = Net::HTTP->new(Host => $1, Timeout => 10, Debug => 0) or return ( "status:1" ); + $s->write_request(GET => $2, 'User-Agent' => "Mozilla/5.0"); + + my($code, $mess, %h) = $s->read_response_headers; + + if ($code == 200) { + return ( "status:0", "mirror:$mirrorurl", "outfile:$outfile" ); + } else { + return ( "status:2" ); + } +} + +sub checkFtpMirror { + my $checkurl = shift; + my $mirrorurl = shift; + my $outfile = shift; + + $SIG{'KILL'} = sub { threads->exit(); }; + + $checkurl = m/ftp:\/\/([^\/]*)(\/.*)/; + my $ftp = Net::FTP->new(Host => $1, Timeout => 10, Debug => 0) or return ( "status:1" ); + $ftp->login("anonymous",'-anonymous@') or return ( "status:2" ); + $ftp->cwd($2) or return ( "status:3" ); + $ftp->quit; + + return ( "status:0", "mirror:$mirrorurl", "outfile:$outfile" ); +} + +sub cleanupThreads { + + my @joinable = threads->list(threads::joinable); + while (@joinable) { + my @ret = shift(@joinable)->join(); + my $response = {}; + + while (my $param = shift(@ret)) { + $param =~ m/^([^:]*):(.*)$/; + $response->{$1} = $2; + } + + switch ($response->{status}) { + case 0 { + push(@{$out->{$response->{outfile}}}, + $response->{mirror}); + print "o" + } + else { + print "x"; + $statistics->{errors}++; + } + } + #print "j"; + } + + my $running = threads->list(threads::running); + return $running; +} + +my $startTime = time(); +my $endTime; + +my $oldtime; +if ( -e "$ENV{'HOME'}/.update-suse-distro-info" ) { + $oldtime = qx(cat $ENV{'HOME'}/.update-suse-distro-info); +} + +# cleanup +system ("rm -rf out"); + +print "\n ** OpenSLX distro-info Updater - OpenSUSE **\n\n"; +print "Notice: running the checks takes some time, so it's enough time for a coffee\n break ;)"; + +if ($oldtime) { + my ($min, $sec) = split(/:/, $oldtime); + printf (" - last run took %i min %i sec ..\n", $min, $sec); +} else { + print "\n"; +} + +while (my $version = shift(@supportedVersions)) { + print "\nopenSUSE $version->{ver} \n"; + + print "fetching mirror list..\n"; + system("wget -q -O suse-$version->{ver} $version->{source}"); + + print "extracting mirrors.. \n"; + $cmd = "grep -P -e \"<a href=.*>(HT|F)TP</a>\" suse-$version->{ver} | "; + $cmd .= "sed -e \"s/^[^\\\"]*\\\"//\" -e \"s/\\\".*\$//\" >"; + $cmd .= "suse-$version->{ver}-mirrors && rm suse-$version->{ver}"; + system $cmd; + + my @sa = split(/ /,$version->{supporedArch}); + + # empty out + $out = {}; + $statistics = {}; + + + while (my $arch = shift(@sa)) { + $arch = "_$arch"; + # if we have ix86 arch name is not used.. + $arch =~ s/_i.?86//; + $cmd = "mkdir -p out/suse-$version->{ver}$arch/mirrors"; + $cmd .= " out/suse-$version->{ver}$arch/trusted-package-keys"; + system ($cmd); + } + + print "check mirrors .. \n"; + my $running; + $statistics->{numMirrors} = qx(cat suse-$version->{ver}-mirrors | wc -l); + open FILE, "< suse-$version->{ver}-mirrors", or die "couldn't open file: $!"; + while (<FILE>) { + chomp; + my $mirror = $_; + my $skipmirror = 0; + @sa = split(/ /,$version->{supporedArch}); + while (my $arch = shift(@sa)) { + while (my($type, $parameters) = each %sourceLists) { + my $checkpath = $parameters->{archpath}; + $checkpath =~ s/#ver#/$version->{ver}/; + $checkpath =~ s/#arch#/$arch/; + + my $mirrorpath = $parameters->{path}; + $mirrorpath =~ s/#ver#/$version->{ver}/; + + my $local_arch = "_$arch"; + # if we have ix86 arch name is not used.. + $local_arch =~ s/_i.?86//; + + my @running = threads->list(threads::running); + my $numRunning = scalar @running; + $running = cleanupThreads(); + + while( $running > 50 ) { sleep 0.1; $running = cleanupThreads();} + if ($mirror =~ m/^http:/) { + threads->create({context => 'list'}, + 'checkHttpMirror', + "$mirror$checkpath", + "$mirror$mirrorpath", + "suse-$version->{ver}$local_arch/mirrors/$type" + ); + } + if ($mirror =~ m/^ftp:/) { + threads->create({context => 'list'}, + 'checkFtpMirror', + "$mirror$checkpath", + "$mirror$mirrorpath", + "suse-$version->{ver}$local_arch/mirrors/$type" + ); + } + } + } + #print "$mirror \n"; + } + close FILE; + system ("rm suse-$version->{ver}-mirrors"); + + $running = cleanupThreads(); + printf ("\n-- waiting for %i unfinished check(s) ..\n", $running); + my $counter = 120; + my $exit = 0; + while( $exit == 0 ) { + sleep 0.5; + $running = cleanupThreads(); + $counter--; + if ( $counter < 1 && $running > 0 ) { + printf ("\n-- %i check(s) still running.. \n", $running); + print ("\n-- cleanup remaining check(s).."); + my @runningthreads = threads->list(); + while (@runningthreads) { + shift(@runningthreads)->kill('KILL')->detach(); + } + $exit = 1; + } + } + + print "\nfinished.\n\n"; + print "writing active mirrors to file.\n"; + + while (my($file, $mirrorlist) = each %{$out}) { + open(OUTFILE, ">>", "out/$file") or die ("something went wrong"); + while (@$mirrorlist) { + #print Dumper($mirrorlist); + $statistics->{files}->{$file}++; + print OUTFILE shift(@$mirrorlist); + print OUTFILE "\n"; + } + close(OUTFILE); + } + + print "\nStatistics:\n"; + printf ("-- checked %i mirrors \n", $statistics->{numMirrors}); + while (my($f, $num) = each(%{$statistics->{files}})) { + printf ("-- found %i entries for: %s \n", $num, $f); + } + + print "\nGet package keys\n"; + system("wget -q -O index http://download.opensuse.org/distribution/$version->{ver}/repo/oss/"); + my @files = qx(cat index | grep -P -e "(gpg-pubkey|pubring)"); + while (@files) { + my $file = shift(@files); + $file =~ m/href=\"([^\"]*)\"/; + my $cmd = "wget -q -O out/suse-$version->{ver}/trusted-package-keys/$1 "; + $cmd .= "http://download.opensuse.org/distribution/$version->{ver}/repo/oss/$1"; + system ("sh", "-c", $cmd); + } + system ("rm index"); + + @sa = split(/ /,$version->{supporedArch}); + while (@sa) { + my $arch = shift(@sa); + my $cmd = "cp out/suse-$version->{ver}/trusted-package-keys/* "; + $cmd .= " out/suse-$version->{ver}_$arch/trusted-package-keys/"; + $arch =~ m/i.?86/ or system ($cmd); + } +} + +$endTime = time(); +my $totalTime = $endTime - $startTime; + +system("cd out && tar cf ../distro-info.suse.tar * && cd .."); +system("rm -rf out"); + +printf ("\nUpdated distro info in %i min %i sec \n", $totalTime/60, $totalTime%60); +printf ("Data written to distro-info.suse.tar, go to <oslx-source>/lib/distro-info \n and extract it."); + +open(FH, ">", "$ENV{'HOME'}/.update-suse-distro-info") or die ($!); +printf FH ("%i:%i", $totalTime/60, $totalTime%60); +close(FH); + +exit 1; |