Dragora GNU/Linux-Libre

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
SHA1:468a9238db8e0642542c0f60d26a3bb140c78f79
Date: 2017-10-12 17:57:12
User: selk
Comment:qi: adjust mechanism for replace declared packages via recipe, create TMPDIR if does not exist, minor enhancements
Tags And Properties
Context
2017-10-12
18:10
[213e684339] add gettext-tiny 0.2.0, this will be the replacement for GNU gettext (user: selk, tags: trunk)
17:57
[468a9238db] qi: adjust mechanism for replace declared packages via recipe, create TMPDIR if does not exist, minor enhancements (user: selk, tags: trunk)
2017-10-10
10:50
[5b3a2bd552] libressl upgraded to the version 2.6.2 (user: selk, tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to qi/Makefile.

1
2
3
4
5
6
7
8
9
10

project		= qi
version		= 1.0-rc10

## DO NOT MAKE CHANGES HERE.
#
# Use config.mak to override any of the following variables:
prefix		= /usr/local
exec_prefix	= $(prefix)
bindir		= $(exec_prefix)/bin


|







1
2
3
4
5
6
7
8
9
10

project		= qi
version		= 1.0-rc11

## DO NOT MAKE CHANGES HERE.
#
# Use config.mak to override any of the following variables:
prefix		= /usr/local
exec_prefix	= $(prefix)
bindir		= $(exec_prefix)/bin

Changes to qi/doc/qi.1.

1
2
3
4
5
6
7
8
9
.\" DO NOT MODIFY THIS FILE!  It was generated by help2man 1.46.5.
.TH QI "1" "October 2017" "qi 1.0-rc10" "User Commands"
.SH NAME
qi \- package manager
.SH SYNOPSIS
.B qi
[\fI\,OPTION\/\fR...] [\fI\,FILE\/\fR]...
.SH DESCRIPTION
Qi \- A practical and user\-friendly package manager.

|







1
2
3
4
5
6
7
8
9
.\" DO NOT MODIFY THIS FILE!  It was generated by help2man 1.46.5.
.TH QI "1" "October 2017" "qi 1.0-rc11" "User Commands"
.SH NAME
qi \- package manager
.SH SYNOPSIS
.B qi
[\fI\,OPTION\/\fR...] [\fI\,FILE\/\fR]...
.SH DESCRIPTION
Qi \- A practical and user\-friendly package manager.

Changes to qi/src/qi.in.

485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
...
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606




607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
...
724
725
726
727
728
729
730
731
732
733
734
735
736


737
738
739
740
741


742
743





744
745
746
747



748
749
750
751
752
753
754
...
804
805
806
807
808
809
810
811
812


813
814
815
816



817
818

819
820
821
822
823
824
825


826
827
828
829
830
831
832
833
...
974
975
976
977
978
979
980
981
982
983
984
985

986
987
988
989
990
991
992
....
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183

        if test -n "$replace"
        then
            rm -f "${destdir}/var/lib/qi/${full_pkgname}.replace"

            warn \
             "The following package names has been declared for replacement:" \
             "$replace"

            for item in $replace
            do
                echo "$replace" >> "${destdir}/var/lib/qi/${full_pkgname}.replace"
            done
            unset item
        fi
................................................................................

    # Remove used variables
    unset directory name
}

delete_mode()
{
    name=$1

    # If package is not a fully qualified directory, prepend it with
    # the value of packagedir.  The solely '/' does not qualify here.

    if ! fnmatch '/?*' "$name"
    then
        name=$(basename -- "$name" .tlz)
        name="${packagedir}/$name"
    fi

    # Complain if the package directory does not exist

    test -d "$name" || {
        warn "${PROGRAM}: Package directory '$name' does not exist."
        exit 4
    }





    # Scan for possible conflicts, stop if arise
    if test "$opt_force" != opt_force
    then
        echo "Checking for possible conflicts ..."
        graft -d -n -t "$targetdir" "$name" > /dev/null
        checkstatus_or_exit 6
    fi

    # Ignore some signals up to completing the (de)installation
    trap "" HUP INT QUIT ABRT TERM

    # Remove package from Graft control

    # Remove objects (files, links or directories) from the target
    # directory that are in conflict with the package directory

    echo "Pruning any conflict ..."
    graft -p -D -u -t "$targetdir" "$name"
    checkstatus_or_exit 2

    echo "Disabling links ..."
    graft -d -u $graft_v -t "$targetdir" "$name"
    checkstatus_or_exit 2

    # Delete package directory
    if test "$opt_keep" != opt_keep
    then
        warn "Deleting package directory ..."

        if test -d "$name"
        then
            rm -rf -- "$name" || exit 2
            echo "removed directory: '$name'"
        else
            warn "Package directory '$name' is no longer there."
        fi
    fi

    # Reset given signals
    trap - HUP INT QUIT ABRT TERM

    # Remove used variables
    unset name
}

install_mode()
{
    # Complain if the package cannot be well-read

    is_readable "$1" || exit 4
................................................................................
        then
            echo "Running post-install script for \`${name}' ..."
            (
                cd -- "${targetdir}"/ && /bin/sh \
                 "${packagedir}/${name}/var/lib/qi/${name}.sh"
            )
        fi
    fi

    # Check if there are package names for its replacement

    if test -r "${packagedir}/${name}/var/lib/qi/${name}.replace"
    then


        while read -r line
        do
            (
                for package_name in "${packagedir}/${line}"*
                do


                    test -d "$package_name" || continue;
                    echo "*** Replacing (declared) package [ $package_name ]"





                    delete_mode "$package_name" > /dev/null
                done
            )
        done < "${packagedir}/${name}/var/lib/qi/${name}.replace"



    fi

    # Reset given signals
    trap - HUP INT QUIT ABRT TERM

    # Remove used variables
    unset name
................................................................................

    # Remove old package names if the option -k was not given

    # Restore 'packagedir' first
    packagedir=$save_packagedir
    unset save_packagedir

    echo "Searching for previous installations under the same name ..."
    for previous in "${packagedir}/$(pkgbase $incoming)"*


    do
        # The search of the package to remove cannot be the
        # same to the installation of the temporary package
        test "$previous" = "$PRVDIR" && continue;




        if test -r "$previous"

        then
            echo "${previous}:  Detected."
            delete_mode "$previous" > /dev/null 2>&1
        fi
    done
    unset previous



    # Re-install the package and remove the temporary location

    echo "Upgrading to $incoming ..."
    install_mode "$1"

    echo "Deleting temporary location ..."
    rm -rf -- "$PRVDIR" && echo "removed directory: '$PRVDIR'"

................................................................................

EOF
}

#### Default values

PROGRAM="${0##*/}"
VERSION=1.0-rc6
packagedir=@PACKAGEDIR@
targetdir=@TARGETDIR@
RC=RC
RCFILE=@SYSCONFDIR@/qirc

opt_force=opt_force.off
opt_keep=opt_keep.off
opt_incr_release=opt_incr_release.off
opt_nopkg=opt_nopkg.off
arch="$(uname -m)" || exit 2
jobs=1
mode=""
................................................................................
# We need at least one mode
if test -z "$mode"
then
    usage
    exit 4
fi

# Ensure 'TMPDIR' sanity, we need it to prefix the temporary dir/files

if test ! -d "$TMPDIR"
then
    warn "${PROGRAM}: \$TMPDIR: \`${TMPDIR}' is not a valid directory."
    exit 4
fi
readonly TMPDIR

# Remove write permission for group and other
umask 022

# Process each package or recipe provided on the command-line

for package in "$@"
do
    $mode "$package"
done








|







 







|




|

|
|




|
|


>
>
>
>





|












|



|







|

|
|

|







|







 







<

|

|
|
>
>
|
|
<
|

>
>
|
<
>
>
>
>
>
|

<
|
>
>
>







 







|
|
>
>



|
>
>
>

<
>

|
|


<

>
>
|







 







|




>







 







|



|
|













485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
...
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
...
728
729
730
731
732
733
734

735
736
737
738
739
740
741
742
743

744
745
746
747
748

749
750
751
752
753
754
755

756
757
758
759
760
761
762
763
764
765
766
...
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834

835
836
837
838
839
840

841
842
843
844
845
846
847
848
849
850
851
...
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
....
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202

        if test -n "$replace"
        then
            rm -f "${destdir}/var/lib/qi/${full_pkgname}.replace"

            warn \
             "The following package names has been declared for replacement:" \
             "    $replace"

            for item in $replace
            do
                echo "$replace" >> "${destdir}/var/lib/qi/${full_pkgname}.replace"
            done
            unset item
        fi
................................................................................

    # Remove used variables
    unset directory name
}

delete_mode()
{
    expunge=$1

    # If package is not a fully qualified directory, prepend it with
    # the value of packagedir.  The solely '/' does not qualify here.

    if ! fnmatch '/?*' "$expunge"
    then
        expunge=$(basename -- "$expunge" .tlz)
        expunge="${packagedir}/$expunge"
    fi

    # Complain if the package directory does not exist

    test -d "$expunge" || {
        warn "${PROGRAM}: Package directory '$expunge' does not exist."
        exit 4
    }

    # Complain if the package directory cannot be well-read

    is_readable "$expunge" || exit 4

    # Scan for possible conflicts, stop if arise
    if test "$opt_force" != opt_force
    then
        echo "Checking for possible conflicts ..."
        graft -d -n -t "$targetdir" "$expunge" > /dev/null
        checkstatus_or_exit 6
    fi

    # Ignore some signals up to completing the (de)installation
    trap "" HUP INT QUIT ABRT TERM

    # Remove package from Graft control

    # Remove objects (files, links or directories) from the target
    # directory that are in conflict with the package directory

    echo "Pruning any conflict ..."
    graft -p -D -u -t "$targetdir" "$expunge"
    checkstatus_or_exit 2

    echo "Disabling links ..."
    graft -d -u $graft_v -t "$targetdir" "$expunge"
    checkstatus_or_exit 2

    # Delete package directory
    if test "$opt_keep" != opt_keep
    then
        warn "Deleting package directory ..."

        if test -d "$expunge"
        then
            rm -rf -- "$expunge" || exit 2
            echo "removed directory: '$expunge'"
        else
            warn "Package directory '$expunge' is no longer there."
        fi
    fi

    # Reset given signals
    trap - HUP INT QUIT ABRT TERM

    # Remove used variables
    unset expunge
}

install_mode()
{
    # Complain if the package cannot be well-read

    is_readable "$1" || exit 4
................................................................................
        then
            echo "Running post-install script for \`${name}' ..."
            (
                cd -- "${targetdir}"/ && /bin/sh \
                 "${packagedir}/${name}/var/lib/qi/${name}.sh"
            )
        fi


        # Check if there are declared package names for replacement

        if test -r "${packagedir}/${name}/var/lib/qi/${name}.replace"
        then
            short_name=$(pkgbase $name)

            while read -r line
            do

                for replace in "${packagedir}/${line}"*
                do
                    if test "$(pkgbase $replace)" = "$short_name"
                    then
                        continue;

                    fi

                    warn "Replacing package \`${replace}' ..."

                    opt_force=opt_force opt_keep=opt_keep.off \
                     delete_mode "$replace" > /dev/null
                done

            done < "${packagedir}/${name}/var/lib/qi/${name}.replace"

            unset short_name
        fi
    fi

    # Reset given signals
    trap - HUP INT QUIT ABRT TERM

    # Remove used variables
    unset name
................................................................................

    # Remove old package names if the option -k was not given

    # Restore 'packagedir' first
    packagedir=$save_packagedir
    unset save_packagedir

    echo "Searching for previous installations under the same package name ..."
    short_name=$(pkgbase $incoming)

    for long_name in "${packagedir}/$short_name"*
    do
        # The search of the package to remove cannot be the
        # same to the installation of the temporary package
        if test "$long_name" = "$PRVDIR"
        then
            continue;
        fi


        if test "$short_name" = "$(pkgbase $long_name)"
        then
            echo "${long_name}:  Detected."
            delete_mode "$long_name" > /dev/null 2>&1
        fi
    done


    unset short_name long_name

    # Re-install the package removing the temporary location

    echo "Upgrading to $incoming ..."
    install_mode "$1"

    echo "Deleting temporary location ..."
    rm -rf -- "$PRVDIR" && echo "removed directory: '$PRVDIR'"

................................................................................

EOF
}

#### Default values

PROGRAM="${0##*/}"
VERSION=1.0-rc11
packagedir=@PACKAGEDIR@
targetdir=@TARGETDIR@
RC=RC
RCFILE=@SYSCONFDIR@/qirc
opt_update=""
opt_force=opt_force.off
opt_keep=opt_keep.off
opt_incr_release=opt_incr_release.off
opt_nopkg=opt_nopkg.off
arch="$(uname -m)" || exit 2
jobs=1
mode=""
................................................................................
# We need at least one mode
if test -z "$mode"
then
    usage
    exit 4
fi

# Ensure 'TMPDIR' creation to prefix temporary files

if test ! -d "$TMPDIR"
then
    mkdir -p -- "$TMPDIR" || exit 2
    echo "mkdir: created directory '$TMPDIR'"
fi
readonly TMPDIR

# Remove write permission for group and other
umask 022

# Process each package or recipe provided on the command-line

for package in "$@"
do
    $mode "$package"
done