<commit_before>function lp_create_function() {
    # Create an interface function that must be defined
    # by the underlying package specific library
    local -r F="$1() {
        cp_error \"$1 is not defined for $CPKG_TYPE\"
    }"
    eval "$F"
}

function lp_create_interface() {
    local -a INTERFACE=(
        lp_init
        lp_prepare_package_directory
        lp_handle_manpage
        lp_handle_system_file
        lp_handle_package_files
        lp_install_local_package
        lp_install_packages
        lp_configure_package
        lp_build_package
        lp_make_pkg_map
        lp_make_pkg_header_map
        lp_make_pkgconfig_map
        lp_get_pkgconfig
        lp_find_c_lib
        lp_clean_packages_scripts
    )

    local F

    for F in ${INTERFACE[@]}; do
        lp_create_function $F
    done
}

lp_create_interface

function lp_load_conf() {
    if [ -f $CPKG_ETCDIR/package/$CPKG_TYPE.conf ]; then
        . $CPKG_ETCDIR/package/$CPKG_TYPE.conf
    fi
}

. $CPKG_LIBDIR/$CPKG_TYPE/pkg_vars.sh
lp_load_conf
. $CPKG_LIBDIR/$CPKG_TYPE/libpackage.sh

lp_init

function lp_process_package_files() {
    local PHASE
    local CPKG_SCRIPT_BASE

    # Process directories
    # 1. User directories
    # 2. Any directory created by a support module in PKG_BUILDDIR
    for DIR in $PKG_SOURCEDIR $PKG_SUPPORTDIR; do
        # Process templates
        local TEMPLATE_DIR

        for TEMPLATE_DIR in ${!CPKG_TEMPLATE_DIRS[@]}; do
            if [ -d $DIR/$TEMPLATE_DIR ]; then
                mkdir -p ${CPKG_TEMPLATE_DIRS[$TEMPLATE_DIR]}

                # Process .tmpl files
                cp_process_templates \
                    $DIR/$TEMPLATE_DIR \
                    ${CPKG_TEMPLATE_DIRS[$TEMPLATE_DIR]}

                # Copy other files
                $RSYNC \
                    $RSYNC_OPTS $RSYNC_NO_TMPL \
                    $DIR/$TEMPLATE_DIR/ ${CPKG_TEMPLATE_DIRS[$TEMPLATE_DIR]}
            fi
        done

        local OTHER_DIR

        for OTHER_DIR in ${!CPKG_OTHER_DIRS[@]}; do
            if [ -d $DIR/$OTHER_DIR ]; then
                mkdir -p $PKG_STAGEDIR${CPKG_OTHER_DIRS[$OTHER_DIR]}
                $RSYNC \
                    $RSYNC_OPTS \
                    $DIR/$OTHER_DIR/ $PKG_STAGEDIR${CPKG_OTHER_DIRS[$OTHER_DIR]}/
            fi
        done
    done

    # Special processing for utilities/scripts
    if [ -d $PKG_STAGEDIR$PKG_BINDIR ]; then
        CPKG_DIRS=/tmp/cpkg-dirs.$$

        cat > $CPKG_DIRS <<__EOCPKG_DIRS__
ROOTETCDIR=$PKG_SYSETCDIR
ETCDIR=$PKG_ETCDIR
BINDIR=$PKG_BINDIR
ROOTLIBDIR=$PKG_SYSLIBDIR
LIBDIR=$PKG_LIBDIR
SHAREDIR=$PKG_SHAREDIR
VARDIR=$PKG_VARDIR
LOGDIR=$PKG_LOGDIR
__EOCPKG_DIRS__

        chmod 755 $PKG_STAGEDIR$PKG_BINDIR/*

        # Trick to keep subst vars intact when self-bootstrapping
        TAG="##"

        # Replace CPKG_DIRS with package generated directories
        for SCRIPT in `grep -l '#!.*sh' $PKG_STAGEDIR$PKG_BINDIR/*`; do
            cp_reinplace "/${TAG}CPKG_DIRS${TAG}/ {
                r $CPKG_DIRS
                d
            }" $SCRIPT
            cp_reinplace "s,^#\!.*bash,#\!$SHELL," $SCRIPT
        done

        rm -f $CPKG_DIRS

        # Process inlined POD documentation
        local SCRIPTS=$(grep -l '=cut' $PKG_STAGEDIR$PKG_BINDIR/*)
        local MANDIR=$PKG_STAGEDIR/$PKG_MANDIR/man1

        [[ -n "$SCRIPTS" ]] && mkdir -p $MANDIR

        for SCRIPT in $SCRIPTS; do
            MANPAGE=`basename $SCRIPT`
            pod2man $SCRIPT $MANDIR/$MANPAGE.1
        done
    fi

    # Build manpages
    if [ -d $PKG_SOURCEDIR/pod ]; then
        local MANDIR=$PKG_STAGEDIR/$PKG_MANDIR/man
        PODS=$(find $PKG_SOURCEDIR/pod -name \*.pod | xargs)

        [[ -n "$PODS" ]] && mkdir -p $MANDIR

        for POD in $PODS; do
            MANPAGE=$(basename $POD .pod)
            MANDIR+="$(man_section $MANPAGE)"
            pod2man $POD $MANDIR/$MANPAGE
        done
    fi

    # Prepare package install script
    for PHASE in configure remove purge; do
        if [ -f $PKG_SOURCEDIR/$CPKG_TYPE/$PKG_PARTNAME.$PHASE ]; then
            cp \
                $PKG_SOURCEDIR/$CPKG_TYPE/$PKG_PARTNAME.$PHASE \
                $PKG_ROOTDIR/$PKG_PARTNAME.$PHASE
        fi
    done

    # Copy user-provided system configuration
    local SYSCONF

    for SYSCONF in cron.d init logrotate; do
        if [ -f $PKG_SOURCEDIR/$CPKG_TYPE/$PKG_PARTNAME.$SYSCONF ]; then
            cp \
                $PKG_SOURCEDIR/$CPKG_TYPE/$PKG_PARTNAME.$SYSCONF \
                $PKG_ROOTDIR/$PKG_NAME.$SYSCONF

            lp_handle_system_file \
                $PKG_ROOTDIR/$PKG_NAME.$SYSCONF \
                $SYSCONF
        fi
    done

    lp_handle_package_files
}
<commit_msg>man pages cleanup<commit_after>function lp_create_function() {
    # Create an interface function that must be defined
    # by the underlying package specific library
    local -r F="$1() {
        cp_error \"$1 is not defined for $CPKG_TYPE\"
    }"
    eval "$F"
}

function lp_create_interface() {
    local -a INTERFACE=(
        lp_init
        lp_prepare_package_directory
        lp_handle_system_file
        lp_handle_package_files
        lp_install_local_package
        lp_install_packages
        lp_configure_package
        lp_build_package
        lp_make_pkg_map
        lp_make_pkg_header_map
        lp_make_pkgconfig_map
        lp_get_pkgconfig
        lp_find_c_lib
        lp_clean_packages_scripts
    )

    local F

    for F in ${INTERFACE[@]}; do
        lp_create_function $F
    done
}

lp_create_interface

function lp_load_conf() {
    if [ -f $CPKG_ETCDIR/package/$CPKG_TYPE.conf ]; then
        . $CPKG_ETCDIR/package/$CPKG_TYPE.conf
    fi
}

. $CPKG_LIBDIR/$CPKG_TYPE/pkg_vars.sh
lp_load_conf
. $CPKG_LIBDIR/$CPKG_TYPE/libpackage.sh

lp_init

function lp_process_package_files() {
    local PHASE
    local CPKG_SCRIPT_BASE

    # Process directories
    # 1. User directories
    # 2. Any directory created by a support module in PKG_BUILDDIR
    for DIR in $PKG_SOURCEDIR $PKG_SUPPORTDIR; do
        # Process templates
        local TEMPLATE_DIR

        for TEMPLATE_DIR in ${!CPKG_TEMPLATE_DIRS[@]}; do
            if [ -d $DIR/$TEMPLATE_DIR ]; then
                mkdir -p ${CPKG_TEMPLATE_DIRS[$TEMPLATE_DIR]}

                # Process .tmpl files
                cp_process_templates \
                    $DIR/$TEMPLATE_DIR \
                    ${CPKG_TEMPLATE_DIRS[$TEMPLATE_DIR]}

                # Copy other files
                $RSYNC \
                    $RSYNC_OPTS $RSYNC_NO_TMPL \
                    $DIR/$TEMPLATE_DIR/ ${CPKG_TEMPLATE_DIRS[$TEMPLATE_DIR]}
            fi
        done

        local OTHER_DIR

        for OTHER_DIR in ${!CPKG_OTHER_DIRS[@]}; do
            if [ -d $DIR/$OTHER_DIR ]; then
                mkdir -p $PKG_STAGEDIR${CPKG_OTHER_DIRS[$OTHER_DIR]}
                $RSYNC \
                    $RSYNC_OPTS \
                    $DIR/$OTHER_DIR/ $PKG_STAGEDIR${CPKG_OTHER_DIRS[$OTHER_DIR]}/
            fi
        done
    done

    # Special processing for utilities/scripts
    if [ -d $PKG_STAGEDIR$PKG_BINDIR ]; then
        CPKG_DIRS=/tmp/cpkg-dirs.$$

        cat > $CPKG_DIRS <<__EOCPKG_DIRS__
ROOTETCDIR=$PKG_SYSETCDIR
ETCDIR=$PKG_ETCDIR
BINDIR=$PKG_BINDIR
ROOTLIBDIR=$PKG_SYSLIBDIR
LIBDIR=$PKG_LIBDIR
SHAREDIR=$PKG_SHAREDIR
VARDIR=$PKG_VARDIR
LOGDIR=$PKG_LOGDIR
__EOCPKG_DIRS__

        chmod 755 $PKG_STAGEDIR$PKG_BINDIR/*

        # Trick to keep subst vars intact when self-bootstrapping
        TAG="##"

        # Replace CPKG_DIRS with package generated directories
        for SCRIPT in `grep -l '#!.*sh' $PKG_STAGEDIR$PKG_BINDIR/*`; do
            cp_reinplace "/${TAG}CPKG_DIRS${TAG}/ {
                r $CPKG_DIRS
                d
            }" $SCRIPT
            cp_reinplace "s,^#\!.*bash,#\!$SHELL," $SCRIPT
        done

        rm -f $CPKG_DIRS

        # Process inlined POD documentation
        local SCRIPTS=$(grep -l '=cut' $PKG_STAGEDIR$PKG_BINDIR/*)
        local MANDIR=$PKG_STAGEDIR/$PKG_MANDIR/man1

        [[ -n "$SCRIPTS" ]] && mkdir -p $MANDIR

        for SCRIPT in $SCRIPTS; do
            MANPAGE=`basename $SCRIPT`
            pod2man $SCRIPT $MANDIR/$MANPAGE.1
        done
    fi

    # Build manpages
    if [ -d $PKG_SOURCEDIR/pod ]; then
        local MANDIR=$PKG_STAGEDIR/$PKG_MANDIR/man
        PODS=$(find $PKG_SOURCEDIR/pod -name \*.pod | xargs)

        [[ -n "$PODS" ]] && mkdir -p $MANDIR

        for POD in $PODS; do
            MANPAGE=$(basename $POD .pod)
            MANDIR+="$(man_section $MANPAGE)"
            pod2man $POD $MANDIR/$MANPAGE
        done
    fi

    # Prepare package install script
    for PHASE in configure remove purge; do
        if [ -f $PKG_SOURCEDIR/$CPKG_TYPE/$PKG_PARTNAME.$PHASE ]; then
            cp \
                $PKG_SOURCEDIR/$CPKG_TYPE/$PKG_PARTNAME.$PHASE \
                $PKG_ROOTDIR/$PKG_PARTNAME.$PHASE
        fi
    done

    # Copy user-provided system configuration
    local SYSCONF

    for SYSCONF in cron.d init logrotate; do
        if [ -f $PKG_SOURCEDIR/$CPKG_TYPE/$PKG_PARTNAME.$SYSCONF ]; then
            cp \
                $PKG_SOURCEDIR/$CPKG_TYPE/$PKG_PARTNAME.$SYSCONF \
                $PKG_ROOTDIR/$PKG_NAME.$SYSCONF

            lp_handle_system_file \
                $PKG_ROOTDIR/$PKG_NAME.$SYSCONF \
                $SYSCONF
        fi
    done

    lp_handle_package_files
}

{'fraction_non_alphanumeric': 0.0913338997451147, 'fraction_numerical': 0.002336448598130841, 'mean_word_length': 1.9781783681214422, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5486779', 'n_tokens_mistral': 3467, 'n_tokens_neox': 3304, 'n_words': 637}