forked from artix/artools
		
	Compare commits
	
		
			32 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 8a0168cbe5 | |||
| c2082be241 | |||
| d5d89cf7a4 | |||
| cc8c2fe38e | |||
| 9bf2bd2671 | |||
| eb638abdfe | |||
| 332cc9751b | |||
| f86e36c361 | |||
| 2edcd2fd54 | |||
| 80887fba39 | |||
| bd07105192 | |||
| 02edf46d6a | |||
| 860d2272ba | |||
| 0d9e54c4e3 | |||
| 26bd425d55 | |||
| c08f82044c | |||
| 74af21ca25 | |||
| e3b8439b04 | |||
| e00096d503 | |||
| f7ebc6bd11 | |||
| b5fa7084b2 | |||
| 7eabdb0e46 | |||
| 10c013bf33 | |||
| 74618d77a5 | |||
| 196761740b | |||
| a814655956 | |||
| 7b03050ab9 | |||
| 0b1ff8d060 | |||
| f66761aa57 | |||
| f33d9bdac1 | |||
| f50c66cdd7 | |||
| fd1bc87ef0 | 
							
								
								
									
										25
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								Makefile
									
									
									
									
									
								
							| @@ -1,4 +1,4 @@ | ||||
| V=0.27 | ||||
| V=0.28 | ||||
|  | ||||
| TOOLS = artools | ||||
| PREFIX ?= /usr | ||||
| @@ -41,7 +41,11 @@ PKG_BIN = \ | ||||
| 	bin/pkg/signpkg \ | ||||
| 	bin/pkg/checkrepo \ | ||||
| 	bin/pkg/gitearepo \ | ||||
| 	bin/pkg/tidyarch | ||||
| 	bin/pkg/tidyarch \ | ||||
| 	bin/pkg/mkdepgraph \ | ||||
| 	bin/pkg/diffpkg \ | ||||
| 	bin/pkg/makerepropkg \ | ||||
| 	bin/pkg/export-pkgbuild-keys | ||||
|  | ||||
| LN_COMMITPKG = \ | ||||
| 	extrapkg \ | ||||
| @@ -72,20 +76,6 @@ LN_BUILDPKG = \ | ||||
| 	buildpkg-kde-wobble \ | ||||
| 	buildpkg-gnome-wobble | ||||
|  | ||||
| LN_DEPLOYPKG = \ | ||||
| 	deploypkg-system \ | ||||
| 	deploypkg-world \ | ||||
| 	deploypkg-gremlins \ | ||||
| 	deploypkg-goblins \ | ||||
| 	deploypkg-galaxy \ | ||||
| 	deploypkg-galaxy-gremlins \ | ||||
| 	deploypkg-galaxy-goblins \ | ||||
| 	deploypkg-lib32 \ | ||||
| 	deploypkg-lib32-gremlins \ | ||||
| 	deploypkg-lib32-goblins \ | ||||
| 	deploypkg-kde-wobble \ | ||||
| 	deploypkg-gnome-wobble | ||||
|  | ||||
| PKG_DATA = \ | ||||
| 	data/pacman/makepkg.conf \ | ||||
| 	data/valid-names.conf | ||||
| @@ -156,9 +146,6 @@ install_pkg: | ||||
|  | ||||
| 	for l in $(LN_COMMITPKG); do $(LN) commitpkg $(DESTDIR)$(BINDIR)/$$l; done | ||||
| 	for l in $(LN_BUILDPKG); do $(LN) buildpkg $(DESTDIR)$(BINDIR)/$$l; done | ||||
| 	for l in $(LN_DEPLOYPKG); do $(LN) deploypkg $(DESTDIR)$(BINDIR)/$$l; done | ||||
|  | ||||
| 	$(LN) artix-chroot $(DESTDIR)$(BINDIR)/artools-chroot | ||||
|  | ||||
| 	install $(DIRMODE) $(DESTDIR)$(DATADIR)/$(TOOLS) | ||||
| 	install $(FILEMODE) $(PKG_DATA) $(DESTDIR)$(DATADIR)/$(TOOLS) | ||||
|   | ||||
| @@ -23,7 +23,7 @@ artools | ||||
|  | ||||
| - pkg: | ||||
|   * namcap | ||||
|   * git-subrepo | ||||
|   * ruby-braid | ||||
|   * rsync | ||||
|  | ||||
| - iso: | ||||
|   | ||||
| @@ -18,112 +18,21 @@ m4_include(lib/base/message.sh) | ||||
| m4_include(lib/base/chroot.sh) | ||||
| m4_include(lib/base/mount.sh) | ||||
|  | ||||
| #{{{ functions | ||||
|  | ||||
| chroot_part_mount() { | ||||
|     msg2 "mount: [%s]" "$2" | ||||
|     mount "$@" && CHROOT_ACTIVE_PART_MOUNTS=("$2" "${CHROOT_ACTIVE_PART_MOUNTS[@]}") | ||||
| } | ||||
|  | ||||
| chroot_part_umount() { | ||||
|     chroot_api_umount | ||||
|     msg2 "umount: [%s]" "${CHROOT_ACTIVE_PART_MOUNTS[@]}" | ||||
|     umount "${CHROOT_ACTIVE_PART_MOUNTS[@]}" | ||||
|     unset CHROOT_ACTIVE_PART_MOUNTS | ||||
| } | ||||
|  | ||||
| detect(){ | ||||
|     local detected | ||||
|     detected="$(os-prober | tr ' ' '_' | paste -s -d ' ')" | ||||
|     printf "%s\n" "${detected}" | ||||
| } | ||||
|  | ||||
| # $1: os-prober array | ||||
| get_os_name(){ | ||||
|     local str=$1 | ||||
|     str="${str#*:}" | ||||
|     str="${str#*:}" | ||||
|     str="${str%:*}" | ||||
|     printf "%s\n" "$str" | ||||
| } | ||||
|  | ||||
| mount_os(){ | ||||
|     CHROOT_ACTIVE_PART_MOUNTS=() | ||||
|     CHROOT_ACTIVE_MOUNTS=() | ||||
|  | ||||
|     trap_setup chroot_part_umount | ||||
|  | ||||
|     chroot_part_mount "$2" "$1" | ||||
|  | ||||
|     local mounts | ||||
|     mounts=$(perl -ane 'printf("%s:%s\n", @F[0,1]) if $F[0] =~ m#^UUID=#;' "$1"/etc/fstab) | ||||
|  | ||||
|     for entry in ${mounts}; do | ||||
|         entry=${entry//UUID=} | ||||
|         local dev=${entry%:*} mp=${entry#*:} | ||||
|         case "${entry#*:}" in | ||||
|             '/'|'swap'|'none') continue ;; | ||||
|             *) chroot_part_mount "/dev/disk/by-uuid/${dev}" "$1${mp}" ;; | ||||
|         esac | ||||
|     done | ||||
|  | ||||
|     chroot_setup "$1" true | ||||
|     chroot_add_resolv_conf "$1" | ||||
| } | ||||
|  | ||||
| select_os(){ | ||||
|     local os_list=( "$(detect)" ) count=${#os_list[@]} | ||||
|     if [[ ${count} -gt 1 ]];then | ||||
|         msg "Detected systems:" | ||||
|         local i=0 | ||||
|         for os in "${os_list[@]}"; do | ||||
|             local last=${os##*:} | ||||
|             case $last in | ||||
|                 'efi') count=$((count-1)) ;; | ||||
|                 *) msg2 "$i) $(get_os_name "$os")"; i=$((i+1)) ;; | ||||
|             esac | ||||
|         done | ||||
|         i=0 | ||||
|         msg "Select system to mount [0-%s] : " "$((count-1))" | ||||
|         read -r select | ||||
|     else | ||||
|         select=0 | ||||
|     fi | ||||
|     local os_str=${os_list[$select]} type | ||||
|     type=$os_str | ||||
|     root=${os_str%%:*} | ||||
|     type=${type##*:} | ||||
|     if [[ "${type##*:}" == 'linux' ]];then | ||||
|         msg "Mounting (%s) [%s]" "$(get_os_name "$os_str")" "$root" | ||||
|         mount_os "$1" "$root" | ||||
|     else | ||||
|         die "You can't mount %s!" "$select" | ||||
|     fi | ||||
| } | ||||
|  | ||||
| #}}} | ||||
|  | ||||
| automount=false | ||||
|  | ||||
| usage() { | ||||
|     printf 'usage: %s -a [or] %s chroot-dir [command]\n' "${0##*/}" "${0##*/}" | ||||
|     printf '    -a             Automount detected linux system\n' | ||||
|     printf 'usage: %s chroot-dir [command]\n' "${0##*/}" | ||||
|     printf '    -h             Print this help message\n' | ||||
|     printf '\n' | ||||
|     printf "    If 'command' is unspecified, %s will launch /bin/sh.\n" "${0##*/}" | ||||
|     printf '\n' | ||||
|     printf "    If 'automount' is true, %s will launch /bin/bash\n" "${0##*/}" | ||||
|     printf '    and %s\n' "${chrootdir}" | ||||
|     printf '\n' | ||||
|     printf '\n' | ||||
|     exit "$1" | ||||
| } | ||||
|  | ||||
| opts=':ha' | ||||
| opts=':h' | ||||
|  | ||||
| while getopts ${opts} arg; do | ||||
|     case "${arg}" in | ||||
|         a) automount=true ;; | ||||
|         h|?) usage 0 ;; | ||||
|     esac | ||||
| done | ||||
| @@ -131,20 +40,12 @@ shift $(( OPTIND - 1 )) | ||||
|  | ||||
| check_root | ||||
|  | ||||
| if ${automount};then | ||||
|     chrootdir=/mnt | ||||
|     run_args=(/bin/bash) | ||||
| chrootdir=$1 | ||||
| shift | ||||
|  | ||||
|     select_os "${chrootdir}" | ||||
| else | ||||
|     chrootdir=$1 | ||||
|     shift | ||||
|     run_args=("$@") | ||||
| [[ -d ${chrootdir} ]] || die "Can't create chroot on non-directory %s" "${chrootdir}" | ||||
|  | ||||
|     [[ -d ${chrootdir} ]] || die "Can't create chroot on non-directory %s" "${chrootdir}" | ||||
| chroot_api_mount "${chrootdir}" || die "failed to setup API filesystems in chroot %s" "${chrootdir}" | ||||
| chroot_add_resolv_conf "${chrootdir}" | ||||
|  | ||||
|     chroot_api_mount "${chrootdir}" || die "failed to setup API filesystems in chroot %s" "${chrootdir}" | ||||
|     chroot_add_resolv_conf "${chrootdir}" | ||||
| fi | ||||
|  | ||||
| SHELL=/bin/sh unshare --fork --pid chroot "${chrootdir}" "${run_args[@]}" | ||||
| SHELL=/bin/sh unshare --fork --pid chroot "${chrootdir}" "$@" | ||||
|   | ||||
| @@ -90,11 +90,11 @@ for f in "${files[@]}"; do | ||||
|     cp "$f" "$working_dir$f" | ||||
| done | ||||
|  | ||||
| basestrap -${umode}Mc ${pacman_conf:+-C "$pacman_conf"} "$working_dir" \ | ||||
| unshare --mount basestrap -${umode}Mc ${pacman_conf:+-C "$pacman_conf"} "$working_dir" \ | ||||
|     "${cache_dirs[@]/#/--cachedir=}" "$@" || die 'Failed to install all packages' | ||||
|  | ||||
| printf '%s.UTF-8 UTF-8\n' en_US de_DE > "$working_dir/etc/locale.gen" | ||||
| printf 'LANG=en_US.UTF-8\n' > "$working_dir/etc/locale.conf" | ||||
| printf 'LANG=C.UTF-8\n' > "$working_dir/etc/locale.conf" | ||||
| # printf 'KEYMAP=en\n' > "$working_dir/etc/vconsole.conf" | ||||
| printf "%s\n" "${CHROOTVERSION}" > "$working_dir/.artools" | ||||
|  | ||||
|   | ||||
| @@ -28,9 +28,9 @@ batch_move() { | ||||
|         src=${src#*:} | ||||
|         local dest=${entry%%:*} | ||||
|         if ${runlist}; then | ||||
|             "${dest}"pkg -s "${src}" -u -p "${pkg}" | ||||
|             "${dest}"pkg -s "${src}" -p "${pkg}" | ||||
|         else | ||||
|             msg "%s" "${dest}pkg -s ${src} -u -p ${pkg}" | ||||
|             msg "%s" "${dest}pkg -s ${src} -p ${pkg}" | ||||
|         fi | ||||
|     done < "$pkglist" | ||||
| } | ||||
| @@ -65,10 +65,10 @@ batch_update() { | ||||
|         local dest=${entry%:*} | ||||
|         if ${runlist}; then | ||||
|             buildtree -i -p "${pkg}" | ||||
|             "${dest}"pkg -u -p "${pkg}" | ||||
|             "${dest}"pkg -p "${pkg}" | ||||
|         else | ||||
|             msg "buildtree -i -p ${pkg}" | ||||
|             msg2 "${dest}pkg -u -p ${pkg}" | ||||
|             msg2 "${dest}pkg -p ${pkg}" | ||||
|         fi | ||||
|     done < "$pkglist" | ||||
| } | ||||
| @@ -78,8 +78,8 @@ batch_update() { | ||||
| usage() { | ||||
|     printf 'Usage: %s [optional listname]\n' "${0##*/}" | ||||
|     printf '    -r                 Run generated commands\n' | ||||
|     printf '    -c                 Create subrepos from list\n' | ||||
|     printf '    -u                 Update subrepos from list\n' | ||||
|     printf '    -c                 Create pkgrepos from list\n' | ||||
|     printf '    -u                 Update pkgrepos from list\n' | ||||
|     printf '    -h                 This help\n' | ||||
|     printf '\n' | ||||
|     printf '\n' | ||||
|   | ||||
| @@ -23,23 +23,31 @@ m4_include(lib/pkg/jenkins.sh) | ||||
|  | ||||
| #{{{ new git repo | ||||
|  | ||||
| subrepo_new(){ | ||||
| pkgrepo_new(){ | ||||
|     cd "${TREE_DIR_ARTIX}/${group}" || return | ||||
|  | ||||
|     local org gitname | ||||
|     org=$(get_pkg_org "${package}") | ||||
|     gitname=$(get_compliant_name "${package}") | ||||
|  | ||||
|     gitearepo -cr "$gitname" | ||||
|     if [[ ! -d "${package}" ]]; then | ||||
|         gitearepo -cr "$gitname" | ||||
|  | ||||
|     add_team_to_repo "$gitname" "$org" "${team}" | ||||
|         add_team_to_repo "$gitname" "$org" "${team}" | ||||
|  | ||||
|     msg2 "Subrepo clone [%s] from (%s)" "${package}" "$org/$gitname" | ||||
|     git subrepo clone "${GIT_SSH}":"$org/$gitname".git "${package}" | ||||
|         msg2 "Adding [%s] from (%s)" "${package}" "$org/$gitname" | ||||
|         braid add "${GIT_SSH}":"$org/$gitname".git "${package}" | ||||
|  | ||||
|     prepare_dir "${TREE_DIR_ARTIX}/${group}/${package}/trunk" | ||||
|         prepare_dir "${TREE_DIR_ARTIX}/${group}/${package}/trunk" | ||||
|  | ||||
|     commit_jenkins_files "${package}" | ||||
|         commit_ci "${package}" | ||||
|  | ||||
| #         if braid push "${package}"; then | ||||
| #             braid update "${package}" | ||||
| #         fi | ||||
|     else | ||||
|         die "Package %s already exists!" "${package}" | ||||
|     fi | ||||
| } | ||||
|  | ||||
| #}}} | ||||
| @@ -52,7 +60,7 @@ config_tree() { | ||||
|         Artix) | ||||
|             if "$vars"; then | ||||
|                 dist_tree=("${ARTIX_TREE[@]}") | ||||
|                 dist_url="${GIT_SSH}:artixlinux" | ||||
|                 dist_url="${GIT_SSH}:pkgbuild" | ||||
|                 dist_dir=${TREE_DIR_ARTIX} | ||||
|             else | ||||
|                 git config --bool pull.rebase true | ||||
| @@ -102,11 +110,20 @@ update_tree() { | ||||
|  | ||||
| #{{{ patch | ||||
|  | ||||
| set_maintainer() { | ||||
|     local name email path="$1" | ||||
|     name=$(git -C $path config --get user.name) | ||||
|     email=$(git -C $path config --get user.email) | ||||
|     sed -e "1s|Maintainer:.*|Maintainer: $name <$email>|" \ | ||||
|         -i "$path"/PKGBUILD | ||||
| } | ||||
|  | ||||
| patch_pkg(){ | ||||
|     local pkgpath="$1" | ||||
|     local pkg=${pkgpath%/*} | ||||
|     pkg=${pkg##*/} | ||||
|     sed -e 's|arch-meson|artix-meson|' -i "$pkgpath"/PKGBUILD | ||||
|     set_maintainer "$pkgpath" | ||||
|     case $pkg in | ||||
|         glibc) | ||||
|             msg2 "Patching %s" "$pkg" | ||||
| @@ -188,14 +205,14 @@ from_arch(){ | ||||
|     [[ -z $srcpath ]] && die "Package '%s' does not exist!" "${package}" | ||||
|  | ||||
|     repo=$(find_repo "$srcpath") | ||||
|     msg "repo: %s" "${repo#*/}" | ||||
|     msg "repo: %s" "$repo" | ||||
|  | ||||
|     archpath=$srcpath/$repo | ||||
|     archpath=$srcpath/repos/$repo | ||||
|     artixpath=$(find_pkg "${TREE_DIR_ARTIX}" "${package}") | ||||
|  | ||||
|     show_deps "$archpath" | ||||
|  | ||||
|     if [[ -f "$artixpath"/.gitrepo ]]; then | ||||
|     if [[ -f "$artixpath"/Jenkinsfile ]]; then | ||||
|         artixpath="$artixpath"/trunk | ||||
|  | ||||
|         if [[ -d "$artixpath" ]];then | ||||
| @@ -214,7 +231,7 @@ view_build(){ | ||||
|     archpath=$(find_pkg "${TREE_DIR_ARCH}" "${package}") | ||||
|     [[ -z $archpath ]] && die "Package '%s' does not exist!" "${package}" | ||||
|     repo=$(find_repo "${archpath}") | ||||
|     archpath=$archpath/$repo | ||||
|     archpath=$archpath/repos/$repo | ||||
|     msg "repo: %s" "${repo#*/}" | ||||
|     show_deps "$archpath" | ||||
| } | ||||
| @@ -269,7 +286,7 @@ usage() { | ||||
|     printf "    -a            Don't clone or pull arch repos\n" | ||||
|     printf "    -b            Don't clone or pull artix repos\n" | ||||
|     printf '    -i            Import a package from arch repos\n' | ||||
|     printf '    -n            New remote subrepo and clone it\n' | ||||
|     printf '    -n            New remote pkgrepo and add it\n' | ||||
|     printf '    -v            Check if a package is in the artix tree(s)\n' | ||||
|     printf '    -c            View package depends\n' | ||||
|     printf '    -x            Exclude testing (only with -i)\n' | ||||
| @@ -314,4 +331,4 @@ ${check} && check_tree | ||||
|  | ||||
| ${import} && from_arch | ||||
|  | ||||
| ${createnew} && subrepo_new | ||||
| ${createnew} && pkgrepo_new | ||||
|   | ||||
| @@ -13,77 +13,10 @@ | ||||
| # GNU General Public License for more details. | ||||
|  | ||||
| m4_include(lib/base/message.sh) | ||||
|  | ||||
| shopt -s extglob | ||||
| m4_include(lib/pkg/diff.sh) | ||||
|  | ||||
| load_makepkg_config | ||||
|  | ||||
| #{{{ functions | ||||
|  | ||||
| pkgver_equal() { | ||||
|     if [[ $1 = *-* && $2 = *-* ]]; then | ||||
|         # if both versions have a pkgrel, then they must be an exact match | ||||
|         [[ $1 = "$2" ]] | ||||
|     else | ||||
|         # otherwise, trim any pkgrel and compare the bare version. | ||||
|         [[ ${1%%-*} = "${2%%-*}" ]] | ||||
|     fi | ||||
| } | ||||
|  | ||||
| find_cached_package() { | ||||
|     local searchdirs=("$PKGDEST" "$PWD") results=() | ||||
|     local targetname=$1 targetver=$2 targetarch=$3 | ||||
|     local dir pkg pkgbasename name ver rel arch r results | ||||
|  | ||||
|     for dir in "${searchdirs[@]}"; do | ||||
|         [[ -d $dir ]] || continue | ||||
|  | ||||
|         for pkg in "$dir"/*.pkg.tar?(.!(sig|*.*)); do | ||||
|             [[ -f $pkg ]] || continue | ||||
|  | ||||
|             # avoid adding duplicates of the same inode | ||||
|             for r in "${results[@]}"; do | ||||
|                 [[ $r -ef $pkg ]] && continue 2 | ||||
|             done | ||||
|  | ||||
|             # split apart package filename into parts | ||||
|             pkgbasename=${pkg##*/} | ||||
|             pkgbasename=${pkgbasename%.pkg.tar*} | ||||
|  | ||||
|             arch=${pkgbasename##*-} | ||||
|             pkgbasename=${pkgbasename%-"$arch"} | ||||
|  | ||||
|             rel=${pkgbasename##*-} | ||||
|             pkgbasename=${pkgbasename%-"$rel"} | ||||
|  | ||||
|             ver=${pkgbasename##*-} | ||||
|             name=${pkgbasename%-"$ver"} | ||||
|  | ||||
|             if [[ $targetname = "$name" && $targetarch = "$arch" ]] && | ||||
|                 pkgver_equal "$targetver" "$ver-$rel"; then | ||||
|                 results+=("$pkg") | ||||
|             fi | ||||
|         done | ||||
|     done | ||||
|  | ||||
|     case ${#results[*]} in | ||||
|         0) | ||||
|             return 1 | ||||
|         ;; | ||||
|         1) | ||||
|             printf '%s\n' "${results[0]}" | ||||
|             return 0 | ||||
|         ;; | ||||
|         *) | ||||
|             error 'Multiple packages found:' | ||||
|             printf '\t%s\n' "${results[@]}" >&2 | ||||
|             return 1 | ||||
|         ;; | ||||
|     esac | ||||
| } | ||||
|  | ||||
| #}}} | ||||
|  | ||||
| usage() { | ||||
|     cat <<- _EOF_ | ||||
|         Usage: ${BASH_SOURCE[0]##*/} [OPTIONS] | ||||
|   | ||||
| @@ -22,42 +22,6 @@ m4_include(lib/pkg/repo.sh) | ||||
|  | ||||
| #{{{ functions | ||||
|  | ||||
| push_tree(){ | ||||
|     local tree="$1" | ||||
|     msg "Update (%s)" "${tree}" | ||||
|     git push origin master | ||||
| } | ||||
|  | ||||
| subrepo_push(){ | ||||
|     local pkg="$1" | ||||
|     msg2 "Subrepo push (%s)" "$pkg" | ||||
|     git subrepo push "$pkg" || die "%s push failed" "$pkg" | ||||
| } | ||||
|  | ||||
| subrepo_clean(){ | ||||
|     local pkg="$1" | ||||
|     msg2 "Subrepo clean (%s)" "$pkg" | ||||
|     git subrepo clean "$pkg" | ||||
| } | ||||
|  | ||||
| subrepo_pull(){ | ||||
|     local pkg="$1" | ||||
|     msg2 "Subrepo pull (%s)" "$pkg" | ||||
|     git subrepo pull "$pkg" | ||||
| } | ||||
|  | ||||
| check_rebuild(){ | ||||
|     if [[ -d "$CARCH"/"${valid_names[10]}" ]] \ | ||||
|     && [[ "${repo_dest}" == "${valid_names[7]}" ]]; then | ||||
|         git rm -r "$CARCH"/"${valid_names[10]}" | ||||
|         git commit -m "switch from ${valid_names[10]} to ${valid_names[7]}" | ||||
|     elif [[ -d "$CARCH"/"${valid_names[7]}" ]] \ | ||||
|     && [[ "${repo_dest}" == "${valid_names[10]}" ]]; then | ||||
|         git rm -r "$CARCH"/"${valid_names[7]}" | ||||
|         git commit -m "switch from ${valid_names[7]} to ${valid_names[10]}" | ||||
|     fi | ||||
| } | ||||
|  | ||||
| check_team(){ | ||||
|     if [[ "${repo_src}" == "${valid_names[0]}" && "${repo_dest}" == "${valid_names[1]}" ]] || \ | ||||
|         [[ "${repo_src}" == "${valid_names[1]}" && "${repo_dest}" == "${valid_names[0]}" ]] || \ | ||||
| @@ -74,11 +38,22 @@ check_team(){ | ||||
|     fi | ||||
| } | ||||
|  | ||||
| path_config() { | ||||
|     [[ "${repo_src}" != 'trunk' ]] && pkgbuild="$CARCH/${repo_src}"/PKGBUILD | ||||
| push_super() { | ||||
|     local name="$1" | ||||
|     msg "Update (%s)" "$name" | ||||
|     git push origin master | ||||
|     git prune | ||||
|     [[ "${cmd}" != 'commitpkg' ]] && check_team | ||||
| } | ||||
|  | ||||
|     # shellcheck disable=1090 | ||||
|     . "$pkgbuild" | ||||
| push_pkg() { | ||||
|     local name="$1" | ||||
|     if braid push "${package}"; then | ||||
|         braid update "${package}" | ||||
|         push_super "$name" | ||||
|     else | ||||
|         error "'braid push %s' failed.\n" "${package}" | ||||
|     fi | ||||
| } | ||||
|  | ||||
| get_repo_commit_msg() { | ||||
| @@ -96,15 +71,15 @@ commit_pkg() { | ||||
|         commit_msg=$(get_commit_msg) | ||||
|         msg "Action: %s" "$commit_msg" | ||||
|         if [[ "${repo_src}" == 'trunk' ]];then | ||||
|             git rm -r trunk | ||||
|             git rm -r $package/trunk | ||||
|         else | ||||
|             git rm -r "$CARCH/${repo_src}" | ||||
|             git rm -r "$package/$CARCH/${repo_src}" | ||||
|         fi | ||||
|     else | ||||
|         action='modify' | ||||
|         commit_msg=$(get_commit_msg) | ||||
|         msg "Action: %s" "$commit_msg" | ||||
|         git add . | ||||
|         git add "$package" | ||||
|     fi | ||||
|     git commit -m "$commit_msg" | ||||
| } | ||||
| @@ -112,61 +87,51 @@ commit_pkg() { | ||||
| repo_commit_pkg() { | ||||
|     local commit_msg | ||||
|  | ||||
|     [[ -d "$CARCH/${repo_dest}" ]] && git rm -r "$CARCH/${repo_dest}" | ||||
|     [[ ! -d "$CARCH" ]] && mkdir "$CARCH" | ||||
|     [[ ! -d "$CARCH/${repo_dest}" ]] && mkdir "$CARCH/${repo_dest}" | ||||
|     [[ -d "$package/$CARCH/${repo_dest}" ]] && git rm -r "$package/$CARCH/${repo_dest}" | ||||
|     [[ ! -d "$package/$CARCH" ]] && mkdir "$package/$CARCH" | ||||
|     [[ ! -d "$package/$CARCH/${repo_dest}" ]] && mkdir "$package/$CARCH/${repo_dest}" | ||||
|  | ||||
|     if [[ "${repo_src}" == 'trunk' ]]; then | ||||
|         action='add' | ||||
|         commit_msg=$(get_repo_commit_msg) | ||||
|         msg "Action: %s" "$commit_msg" | ||||
|         check_rebuild | ||||
|         cp trunk/* "$CARCH/${repo_dest}"/ | ||||
|         cp -r "$package"/trunk/* "$package/$CARCH/${repo_dest}"/ | ||||
|     else | ||||
|         action='move' | ||||
|         [[ ! -f $pkgbuild ]] && die "%s does not exist!" "$pkgbuild" | ||||
|         commit_msg=$(get_repo_commit_msg) | ||||
|         msg "Action: %s" "$commit_msg" | ||||
|         cp "$CARCH/${repo_src}"/* "$CARCH/${repo_dest}"/ | ||||
|         git rm -r "$CARCH/${repo_src}" | ||||
|         cp -r "$package/$CARCH/${repo_src}"/* "$package/$CARCH/${repo_dest}"/ | ||||
|         git rm -r "$package/$CARCH/${repo_src}" | ||||
|     fi | ||||
|     git add . | ||||
|     git add "$package" | ||||
|     git commit -m "$commit_msg" | ||||
| } | ||||
|  | ||||
| run(){ | ||||
|     local artixpath head group | ||||
|     local artixpath head tree tree_name | ||||
|     artixpath=$(find_pkg "${TREE_DIR_ARTIX}" "${package}") | ||||
|     if [[ -n ${artixpath} ]];then | ||||
|         group=${artixpath%/*} | ||||
|         cd "${group}" || return | ||||
|         tree=${artixpath%/*} | ||||
|         tree_name=${tree##*/} | ||||
|         cd "$tree" || return | ||||
|         head=$(get_local_head) | ||||
|  | ||||
|         cd "${artixpath}" || return | ||||
|  | ||||
|         path_config | ||||
|  | ||||
|         if [[ "${cmd}" == 'commitpkg' ]];then | ||||
|             commit_pkg | ||||
|         else | ||||
|             repo_commit_pkg | ||||
|         pkgbuild="$package"/trunk/PKGBUILD | ||||
|         if [[ "${repo_src}" != 'trunk' ]]; then | ||||
|             pkgbuild="$package/$CARCH/${repo_src}"/PKGBUILD | ||||
|         fi | ||||
|         # shellcheck disable=1090 | ||||
|         . "$pkgbuild" | ||||
|  | ||||
|         cd "${group}" || return | ||||
|         case "${cmd}" in | ||||
|             'commitpkg') commit_pkg ;; | ||||
|             *) repo_commit_pkg ;; | ||||
|         esac | ||||
|  | ||||
|         if ${push}; then | ||||
|             msg "Checking (%s) (Artix)" "${group##*/}" | ||||
|             pull_tree "${group##*/}" "$head" | ||||
|         fi | ||||
|  | ||||
|         subrepo_push "${package}" | ||||
|         subrepo_clean "${package}" | ||||
|  | ||||
|         ${push} && push_tree "${group##*/}" | ||||
|  | ||||
|         git prune | ||||
|  | ||||
|         [[ "${cmd}" != 'commitpkg' ]] && check_team | ||||
|         msg "Checking (%s) (Artix)" "$tree_name" | ||||
|         pull_tree "$tree_name" "$head" | ||||
|         push_pkg "$tree_name" | ||||
|     else | ||||
|         die "Package '%s' does not exist!" "${package}" | ||||
|     fi | ||||
| @@ -192,9 +157,6 @@ load_valid_names | ||||
| repo_src='trunk' | ||||
| package='' | ||||
| remove=false | ||||
| push=false | ||||
|  | ||||
| pkgbuild=trunk/PKGBUILD | ||||
|  | ||||
| cmd=${0##*/} | ||||
| repo_dest=${cmd%pkg} | ||||
| @@ -204,21 +166,19 @@ usage() { | ||||
|     printf "    -s <name>          Source repository [default: %s]\n" "${repo_src}" | ||||
|     printf '    -p <pkg>           Package name\n' | ||||
|     printf '    -r                 Delete from repo (commitpkg only)\n' | ||||
|     printf '    -u                 Push\n' | ||||
|     printf '    -h                 This help\n' | ||||
|     printf '\n' | ||||
|     printf '\n' | ||||
|     exit "$1" | ||||
| } | ||||
|  | ||||
| opts='p:s:urh' | ||||
| opts='p:s:rh' | ||||
|  | ||||
| while getopts "${opts}" arg; do | ||||
|     case "${arg}" in | ||||
|         s) repo_src="$OPTARG" ;; | ||||
|         p) package="$OPTARG" ;; | ||||
|         r) remove=true ;; | ||||
|         u) push=true ;; | ||||
|         h|?) usage 0 ;; | ||||
|     esac | ||||
| done | ||||
|   | ||||
| @@ -31,23 +31,32 @@ write_list(){ | ||||
|     printf "%s\n" "$line" >> "${TREE_DIR_ARTIX}"/"$name".list | ||||
| } | ||||
|  | ||||
| get_group() { | ||||
|     local group | ||||
|     group="${artixpath%/*}" | ||||
|     group=${group##*/} | ||||
|     printf "%s\n" "${group#*-}" | ||||
| } | ||||
|  | ||||
| compare_m(){ | ||||
|     case ${artixrepo} in | ||||
|         *testing*|*staging*|*rebuild) | ||||
|             if [[ "${a}" == "${b}" ]]; then | ||||
|                 msg_row "${table}" "${a}" "${b}" "$pkg" "$archver" "$artixver" "${group#*-}" | ||||
|             elif [[ "${a}" == 'staging' && "${b}" == 'rebuild' ]]; then | ||||
|                 msg_row_yellow "${table}" "${a}" "${b}" "$pkg" "$archver" "$artixver" "${group#*-}" | ||||
|             else | ||||
|                 msg_row_green "${table}" "${a}" "${b}" "$pkg" "$archver" "$artixver" "${group#*-}" | ||||
|                 if [[ -n "$archrepo" ]]; then | ||||
|                     write_list "${a}:${b}:$pkg" pkg_moves | ||||
| #     if [ "$result" -eq 0 ];then | ||||
|         case "$artixrepo" in | ||||
|             *testing*|*staging*|*rebuild) | ||||
|                 if [[ "${archrepo}" == "${artixrepo}" ]]; then | ||||
|                     msg_row "${table}" "${archrepo}" "${artixrepo}" "$pkg" "$archver" "$artixver" "$(get_group)" | ||||
|                 elif [[ "${archrepo}" == 'staging' && "${artixrepo}" == 'rebuild' ]]; then | ||||
|                     msg_row_yellow "${table}" "${archrepo}" "${artixrepo}" "$pkg" "$archver" "$artixver" "$(get_group)" | ||||
|                 else | ||||
|                     write_list "@repo@:${b}:$pkg" artix | ||||
|                     msg_row_green "${table}" "${archrepo}" "${artixrepo}" "$pkg" "$archver" "$artixver" "$(get_group)" | ||||
|                     if [[ -n "${archrepo}" ]]; then | ||||
|                         write_list "${archrepo}:${artixrepo}:$pkg" pkg_moves | ||||
|                     else | ||||
|                         write_list "@repo@:${artixrepo}:$pkg" artix | ||||
|                     fi | ||||
|                 fi | ||||
|             fi | ||||
|         ;; | ||||
|     esac | ||||
|             ;; | ||||
|         esac | ||||
| #     fi | ||||
| } | ||||
|  | ||||
| compare_u(){ | ||||
| @@ -55,15 +64,15 @@ compare_u(){ | ||||
| #         local arel=${archver##*-} brel=${artixver##*-} | ||||
| #         local reldiff | ||||
| #         reldiff=$(( $arel-${brel%.*} )) | ||||
|         msg_row_red "${table}" "${a}" "${b}" "$pkg" "$archver" "$artixver" "${group#*-}" | ||||
|         write_list "${a}:$pkg" pkg_upgrades | ||||
|         msg_row_red "${table}" "${archrepo}" "${artixrepo}" "$pkg" "$archver" "$artixver" "$(get_group)" | ||||
|         write_list "${archrepo}:$pkg" pkg_upgrades | ||||
|     fi | ||||
| } | ||||
|  | ||||
| compare_d(){ | ||||
|     if [ "$result" -eq 1 ];then | ||||
|         if [[ -n "$archver" ]] && [[ -n "$archrepo" ]];then | ||||
|             msg_row_yellow "${table}" "${a}" "${b}" "$pkg" "$archver" "$artixver" "${group#*-}" | ||||
|         if [[ -n "$archver" ]] && [[ -n "${archrepo}" ]];then | ||||
|             msg_row_yellow "${table}" "${archrepo}" "${artixrepo}" "$pkg" "$archver" "$artixver" "$(get_group)" | ||||
|         fi | ||||
|     fi | ||||
| } | ||||
| @@ -78,27 +87,22 @@ get_archpath(){ | ||||
| } | ||||
|  | ||||
| pre_compare(){ | ||||
|     local func="$1" pkgpath="$2" result group pkg | ||||
|     group="${pkgpath%/*}" | ||||
|     group=${group##*/} | ||||
|     pkg=${pkgpath##*/} | ||||
|     local artixpath="$1" func="$2" pkg | ||||
|     pkg=${artixpath##*/} | ||||
|  | ||||
|     local artixrepo archrepo pkgbuild artixver archver archpath node a b | ||||
|     artixrepo=$(find_repo "$pkgpath") | ||||
|     pkgbuild=$pkgpath/$artixrepo/PKGBUILD | ||||
|     local artixrepo archrepo pkgbuild artixver archver archpath epoch | ||||
|  | ||||
|     if [[ -f $pkgbuild ]]; then | ||||
|     artixrepo=$(find_repo "$artixpath") | ||||
|     pkgbuild=$artixpath/$CARCH/$artixrepo/PKGBUILD | ||||
|  | ||||
|     if [[ -f "$pkgbuild" ]]; then | ||||
|         # shellcheck disable=1090 | ||||
|         . "$pkgbuild" 2>/dev/null | ||||
|         artixver=$(get_full_version) | ||||
|         archpath=$(get_archpath "$pkg") | ||||
|         archrepo=$(find_repo "${archpath}") | ||||
|         pkgbuild=$archpath/$archrepo/PKGBUILD | ||||
|         node=${artixrepo%/*} | ||||
|         a=${archrepo#*/} b=${artixrepo#*/} | ||||
|         a="${a%-*}" | ||||
|  | ||||
|         [[ "$node" != "$CARCH" ]] && b=${b%-*} | ||||
|         archrepo=$(find_repo "$archpath") | ||||
|         pkgbuild=$archpath/repos/$archrepo/PKGBUILD | ||||
|         archrepo="${archrepo%-*}" | ||||
|  | ||||
|         if [[ -f "$pkgbuild" ]]; then | ||||
|             # shellcheck disable=1090 | ||||
| @@ -106,27 +110,26 @@ pre_compare(){ | ||||
|             archver=$(get_full_version) | ||||
|         fi | ||||
|  | ||||
|         local result | ||||
|         result=$(vercmp "$artixver" "$archver") | ||||
|  | ||||
|         "$func" | ||||
|  | ||||
|         unset epoch | ||||
|     fi | ||||
| } | ||||
|  | ||||
| compare_upgrades(){ | ||||
|     local pkgpath="${1%/*}" | ||||
|     pre_compare compare_u "$pkgpath" | ||||
|     local artixpath="${1%/*}" | ||||
|     pre_compare "$artixpath" compare_u | ||||
| } | ||||
|  | ||||
| compare_downgrades(){ | ||||
|     local pkgpath="${1%/*}" | ||||
|     pre_compare compare_d "$pkgpath" | ||||
|     local artixpath="${1%/*}" | ||||
|     pre_compare "$artixpath" compare_d | ||||
| } | ||||
|  | ||||
| compare_move(){ | ||||
|     local pkgpath="${1%/*}" | ||||
|     pre_compare compare_m "$pkgpath" | ||||
|     local artixpath="${1%/*}" | ||||
|     pre_compare "$artixpath" compare_m | ||||
| } | ||||
|  | ||||
| #}}} | ||||
| @@ -165,7 +168,7 @@ upgrades=false | ||||
| downgrades=false | ||||
| move=false | ||||
|  | ||||
| readonly table="%-18s %-18s %-25s %-27s %-27s %-10s" | ||||
| readonly table="%-18s %-18s %-29s %-27s %-27s %-7s" | ||||
|  | ||||
| usage() { | ||||
|     printf 'Usage: %s [options]\n' "${0##*/}" | ||||
|   | ||||
							
								
								
									
										329
									
								
								bin/pkg/diffpkg.in
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										329
									
								
								bin/pkg/diffpkg.in
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,329 @@ | ||||
| #!/bin/bash | ||||
| # | ||||
| # SPDX-License-Identifier: GPL-3.0-or-later | ||||
|  | ||||
| m4_include(lib/base/message.sh) | ||||
| m4_include(lib/pkg/diff.sh) | ||||
|  | ||||
| usage() { | ||||
|     cat <<- _EOF_ | ||||
|     Usage: ${BASH_SOURCE[0]##*/} [OPTIONS] [MODES] [FILE|PKGNAME...] | ||||
|  | ||||
|     Searches for a locally built package corresponding to the PKGBUILD, and | ||||
|     downloads the last version of that package from the Pacman repositories. | ||||
|     It then compares the package archives using different modes while using | ||||
|     simple tar content list by default. | ||||
|  | ||||
|     When given one package, use it to diff against the locally built one. | ||||
|     When given two packages, diff both packages against each other. | ||||
|  | ||||
|     In either case, a package name will be converted to a filename from the | ||||
|     cache, and diffpkg will proceed as though this filename was initially | ||||
|     specified. | ||||
|  | ||||
|     OPTIONS | ||||
|         -M, --makepkg-config Set an alternate makepkg configuration file | ||||
|         -v, --verbose        Provide more detailed/unfiltered output | ||||
|         -h, --help           Show this help text | ||||
|  | ||||
|     MODES | ||||
|         -l, --list           Activate content list diff mode (default) | ||||
|         -d, --diffoscope     Activate diffoscope diff mode | ||||
|         -p, --pkginfo        Activate .PKGINFO diff mode | ||||
|         -b, --buildinfo      Activate .BUILDINFO diff mode | ||||
| _EOF_ | ||||
| } | ||||
|  | ||||
| MAKEPKG_CONF=/etc/makepkg.conf | ||||
| POOLDIR=/srv/pkgpool | ||||
|  | ||||
| VERBOSE=0 | ||||
| TARLIST=0 | ||||
| DIFFOSCOPE=0 | ||||
| PKGINFO=0 | ||||
| BUILDINFO=0 | ||||
|  | ||||
| DIFFMODE=--side-by-side | ||||
| DIFFCOLOR=--color=auto | ||||
| DIFFWIDTH=--width=auto | ||||
| DIFFOPTIONS=(--expand-tabs) | ||||
|  | ||||
| # option checking | ||||
| while (( $# )); do | ||||
|     case $1 in | ||||
|         -h|--help) | ||||
|             usage | ||||
|             exit 0 | ||||
|         ;; | ||||
|         -M|--makepkg-config) | ||||
|             (( $# <= 1 )) && die "missing argument for %s" "$1" | ||||
|             MAKEPKG_CONF="$2" | ||||
|             shift 2 | ||||
|         ;; | ||||
|         -l|--list) | ||||
|             TARLIST=1 | ||||
|             shift | ||||
|         ;; | ||||
|         -d|--diffoscope) | ||||
|             DIFFOSCOPE=1 | ||||
|             shift | ||||
|         ;; | ||||
|         -p|--pkginfo) | ||||
|             PKGINFO=1 | ||||
|             shift | ||||
|         ;; | ||||
|         -b|--buildinfo) | ||||
|             BUILDINFO=1 | ||||
|             shift | ||||
|         ;; | ||||
|         -v|--verbose) | ||||
|             VERBOSE=1 | ||||
|             shift | ||||
|         ;; | ||||
|         -u|-U|--unified) | ||||
|             DIFFMODE=--unified | ||||
|             shift | ||||
|         ;; | ||||
|         -y|--side-by-side) | ||||
|             DIFFMODE=--side-by-side | ||||
|             shift | ||||
|         ;; | ||||
|         --color|--color=*) | ||||
|             if [[ $2 == never || $2 == always || $2 == auto ]]; then | ||||
|                 DIFFCOLOR="--color=$2" | ||||
|                 shift 2 | ||||
|                 continue | ||||
|             fi | ||||
|             if [[ $1 == --color ]]; then | ||||
|                 DIFFCOLOR="--color=auto" | ||||
|             else | ||||
|                 DIFFCOLOR="$1" | ||||
|             fi | ||||
|             shift | ||||
|         ;; | ||||
|         -W|--width) | ||||
|             (( $# <= 1 )) && die "missing argument for %s" "$1" | ||||
|             DIFFWIDTH="--width=$2" | ||||
|             shift 2 | ||||
|         ;; | ||||
|         --width=*) | ||||
|             DIFFWIDTH="$1" | ||||
|             shift | ||||
|         ;; | ||||
|         -P|--pool) | ||||
|             (( $# <= 1 )) && die "missing argument for %s" "$1" | ||||
|             POOLDIR="$2" | ||||
|             shift 2 | ||||
|         ;; | ||||
|         --pool=*) | ||||
|             POOLDIR="${1#*=}" | ||||
|             shift | ||||
|         ;; | ||||
|         --) | ||||
|             shift | ||||
|             break | ||||
|         ;; | ||||
|         -*|--*) | ||||
|             die "invalid argument: %s" "$1" | ||||
|         ;; | ||||
|         *) | ||||
|             break | ||||
|         ;; | ||||
|     esac | ||||
| done | ||||
|  | ||||
| # Set options based on flags or magic values | ||||
| if (( VERBOSE )); then | ||||
|     if [[ $DIFFMODE == --unified ]]; then | ||||
|         DIFFMODE="--unified=99999" | ||||
|     fi | ||||
| else | ||||
|     DIFFOPTIONS+=(--suppress-common-lines) | ||||
| fi | ||||
| if [[ $DIFFWIDTH == --width=columns ]]; then | ||||
|     DIFFWIDTH="--width=${COLUMNS:-130}" | ||||
| fi | ||||
| if [[ $DIFFWIDTH != --width=auto ]]; then | ||||
|     DIFFOPTIONS+=("${DIFFWIDTH}") | ||||
| fi | ||||
| DIFFOPTIONS+=("${DIFFMODE}" "${DIFFCOLOR}") | ||||
|  | ||||
| if ! (( DIFFOSCOPE || TARLIST || PKGINFO || BUILDINFO )); then | ||||
|     TARLIST=1 | ||||
| fi | ||||
|  | ||||
| # Source makepkg.conf; fail if it is not found | ||||
| if [[ -r "${MAKEPKG_CONF}" ]]; then | ||||
|     # shellcheck source=config/makepkg/x86_64.conf | ||||
|     source "${MAKEPKG_CONF}" | ||||
| else | ||||
|     die "${MAKEPKG_CONF} not found!" | ||||
| fi | ||||
|  | ||||
| # Source user-specific makepkg.conf overrides | ||||
| if [[ -r "${XDG_CONFIG_HOME:-$HOME/.config}/pacman/makepkg.conf" ]]; then | ||||
|     # shellcheck source=/dev/null | ||||
|     source "${XDG_CONFIG_HOME:-$HOME/.config}/pacman/makepkg.conf" | ||||
| elif [[ -r "$HOME/.makepkg.conf" ]]; then | ||||
|     # shellcheck source=/dev/null | ||||
|     source "$HOME/.makepkg.conf" | ||||
| fi | ||||
|  | ||||
| STARTDIR=$(pwd) | ||||
| trap 'rm -rf $TMPDIR' EXIT INT TERM QUIT | ||||
| TMPDIR=$(mktemp -d --tmpdir diffpkg-script.XXXXXXXX) | ||||
| export TMPDIR | ||||
|  | ||||
| tar_list() { | ||||
|     bsdtar tf "$*" | if (( VERBOSE )); then | ||||
|         cat | ||||
|     else | ||||
|         sed -E 's|^usr/lib/modules/[0-9][^/]+|usr/lib/modules/[…]|g' | ||||
|     fi | sort | ||||
| } | ||||
|  | ||||
| file_line_length() { | ||||
|     path="$1" | ||||
|     wc -L "${path}" | tail -n1 | sed -E 's/^ +//g' | cut -d' ' -f1 | ||||
| } | ||||
|  | ||||
| file_diff_columns() { | ||||
|     file1="$1" | ||||
|     file2="$2" | ||||
|     file1_length=$(file_line_length "$file1") | ||||
|     file2_length=$(file_line_length "$file2") | ||||
|     echo $(( file1_length + file2_length + 3 )) | ||||
| } | ||||
|  | ||||
| diff_pkgs() { | ||||
|     local oldpkg newpkg | ||||
|     oldpkg=$(readlink -m "$1") | ||||
|     newpkg=$(readlink -m "$2") | ||||
|  | ||||
|     [[ -f $oldpkg ]] || die "No such file: %s" "${oldpkg}" | ||||
|     [[ -f $newpkg ]] || die "No such file: %s" "${newpkg}" | ||||
|  | ||||
|     DIFFOPTIONS+=(--label "${oldpkg}" --label "${newpkg}") | ||||
|  | ||||
|     if (( TARLIST )); then | ||||
|         tar_list "$oldpkg" > "$TMPDIR/old" | ||||
|         tar_list "$newpkg" > "$TMPDIR/new" | ||||
|     fi | ||||
|  | ||||
|     if (( PKGINFO )); then | ||||
|         bsdtar xOqf "$oldpkg" .PKGINFO > "$TMPDIR/old" | ||||
|         bsdtar xOqf "$newpkg" .PKGINFO > "$TMPDIR/new" | ||||
|     fi | ||||
|  | ||||
|     if (( BUILDINFO )); then | ||||
|         bsdtar xOqf "$oldpkg" .BUILDINFO > "$TMPDIR/old" | ||||
|         bsdtar xOqf "$newpkg" .BUILDINFO > "$TMPDIR/new" | ||||
|     fi | ||||
|  | ||||
|     if (( TARLIST || PKGINFO || BUILDINFO )); then | ||||
|     # Resolve dynamic auto width one we know the content to diff | ||||
|         if [[ $DIFFWIDTH == --width=auto ]]; then | ||||
|             AUTOLENGTH=$(file_diff_columns "$TMPDIR/old" "$TMPDIR/new") | ||||
|             DIFFOPTIONS+=("--width=${AUTOLENGTH}") | ||||
|         fi | ||||
|  | ||||
|         # Print a header for side-by-side view as it lacks labels | ||||
|         if [[ $DIFFMODE == --side-by-side ]]; then | ||||
|             printf -- "--- %s\n+++ %s\n" "${oldpkg}" "${newpkg}" | ||||
|         fi | ||||
|  | ||||
|         diff "${DIFFOPTIONS[@]}" "$TMPDIR/old" "$TMPDIR/new" | ||||
|     fi | ||||
|  | ||||
|     if (( DIFFOSCOPE )); then | ||||
|         diffoscope "${DIFFCOLOR/--color/--text-color}" "$oldpkg" "$newpkg" | ||||
|     fi | ||||
| } | ||||
|  | ||||
| shopt -s extglob | ||||
|  | ||||
| fetch_pkg() { | ||||
|     local pkg pkgdest pkgurl | ||||
|     case $1 in | ||||
|         *://*) | ||||
|             pkgurl=$1 ;; | ||||
|         /*|*/*) | ||||
|             pkgurl=$(readlink -m "$1") ;; | ||||
|         *.pkg.tar*) | ||||
|             pkgurl=$1 ;; | ||||
|         '') | ||||
|         ;; | ||||
|         *) | ||||
|             pkg=$1 ;; | ||||
|     esac | ||||
|  | ||||
|     if [[ -z ${pkgurl} ]]; then | ||||
|         # Try to find latest package in pool dir | ||||
|         if [[ -d ${POOLDIR} ]]; then | ||||
|             shopt -s extglob nullglob | ||||
|             pkgurl=$(printf "%s\n" "${POOLDIR}"/*/"${_pkgname}"-!(*-*)-!(*-*)-!(*-*).pkg.tar!(*.sig)|sort -Vr|head -1) | ||||
|             shopt -u extglob nullglob | ||||
|         fi | ||||
|         # Search via pacman database if no pool file exists | ||||
|         if [[ ! -f ${pkgurl} ]]; then | ||||
|             pkgurl=$(pacman -Spdd --print-format '%l' --noconfirm "$pkg") || | ||||
|             die "Couldn't download previous package for %s." "$pkg" | ||||
|         fi | ||||
|     fi | ||||
|  | ||||
|     pkg=${pkgurl##*/} | ||||
|     pkgdest=$(mktemp -t -d "${pkg}-XXXXXX")/${pkg} | ||||
|  | ||||
|     if [[ $pkgurl = file://* || ( $pkgurl = /* && -f $pkgurl ) ]]; then | ||||
|         ln -sf "${pkgurl#file://}" "$pkgdest" | ||||
|     elif [[ -f "$PKGDEST/$pkg" ]]; then | ||||
|         ln -sf "$PKGDEST/$pkg" "$pkgdest" | ||||
|     elif [[ -f "$STARTDIR/$pkg" ]]; then | ||||
|         ln -sf "$STARTDIR/$pkg" "$pkgdest" | ||||
|     elif [[ $pkgurl = *://* ]]; then | ||||
|         curl -fsLC - --retry 3 --retry-delay 3 -o "$pkgdest" "$pkgurl" || \ | ||||
|         die "Couldn't download %s" "$pkgurl" | ||||
|     else | ||||
|         die "File not found: %s" "$pkgurl" | ||||
|     fi | ||||
|  | ||||
|     echo "$pkgdest" | ||||
| } | ||||
|  | ||||
| shopt -u extglob | ||||
|  | ||||
| if (( $# < 2 )); then | ||||
|     if [[ ! -f PKGBUILD ]]; then | ||||
|         die "This must be run in the directory of a built package.\nTry '$(basename "$0") --help' for more information." | ||||
|     fi | ||||
|  | ||||
|     # shellcheck source=contrib/makepkg/PKGBUILD.proto | ||||
|     . ./PKGBUILD | ||||
|     if [[ ${arch[0]} == 'any' ]]; then | ||||
|         CARCH='any' | ||||
|     fi | ||||
|  | ||||
|     for _pkgname in "${pkgname[@]}"; do | ||||
|         comparepkg=$_pkgname | ||||
|         pkgurl= | ||||
|         target_pkgver=$(get_full_version "$_pkgname") | ||||
|         if ! pkgfile=$(find_cached_package "$_pkgname" "$target_pkgver" "$CARCH"); then | ||||
|             die 'tarball not found for package: %s' "${_pkgname}-$target_pkgver" | ||||
|         fi | ||||
|  | ||||
|         ln -s "$pkgfile" "$TMPDIR" | ||||
|  | ||||
|         if (( $# )); then | ||||
|             comparepkg="$1" | ||||
|         fi | ||||
|  | ||||
|         oldpkg=$(fetch_pkg "$comparepkg") || exit 1 | ||||
|  | ||||
|         diff_pkgs "$oldpkg" "$pkgfile" | ||||
|     done | ||||
| else | ||||
|     file1=$(fetch_pkg "$1") || exit 1 | ||||
|     file2=$(fetch_pkg "$2") || exit 1 | ||||
|  | ||||
|     diff_pkgs "$file1" "$file2" | ||||
| fi | ||||
							
								
								
									
										70
									
								
								bin/pkg/export-pkgbuild-keys.in
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										70
									
								
								bin/pkg/export-pkgbuild-keys.in
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,70 @@ | ||||
| #!/bin/bash | ||||
| # | ||||
| # SPDX-License-Identifier: GPL-3.0-or-later | ||||
|  | ||||
| m4_include(lib/base/message.sh) | ||||
|  | ||||
| usage() { | ||||
|     cat <<- _EOF_ | ||||
|         Usage: ${BASH_SOURCE[0]##*/} | ||||
|  | ||||
|         Export the PGP keys from a PKGBUILDs validpgpkeys array into the keys/pgp/ | ||||
|         subdirectory. Useful for distributing packager validated source signing | ||||
|         keys alongside PKGBUILDs. | ||||
|  | ||||
|         OPTIONS | ||||
|             -h, --help      Show this help text | ||||
| _EOF_ | ||||
| } | ||||
|  | ||||
| # option checking | ||||
| while (( $# )); do | ||||
|     case $1 in | ||||
|         -h|--help) usage; exit 0 ;; | ||||
|         *) die "invalid argument: %s" "$1" ;; | ||||
|     esac | ||||
| done | ||||
|  | ||||
| if [[ ! -f PKGBUILD ]]; then | ||||
|     die "This must be run a directory containing a PKGBUILD." | ||||
| fi | ||||
|  | ||||
| mapfile -t validpgpkeys < <( | ||||
|     # shellcheck source=PKGBUILD.proto | ||||
|     . ./PKGBUILD | ||||
|     if (( ${#validpgpkeys[@]} )); then | ||||
|         printf "%s\n" "${validpgpkeys[@]}" | ||||
|     fi | ||||
| ) | ||||
|  | ||||
| msg "Exporting ${#validpgpkeys[@]} PGP keys..." | ||||
| if (( ${#validpgpkeys[@]} == 0 )); then | ||||
|     exit 0 | ||||
| fi | ||||
|  | ||||
| trap 'rm -rf $TEMPDIR' EXIT INT TERM QUIT | ||||
| TEMPDIR=$(mktemp -d --tmpdir export-pkgbuild-keys.XXXXXXXXXX) | ||||
|  | ||||
| mkdir -p keys/pgp | ||||
| error=0 | ||||
|  | ||||
| for key in "${validpgpkeys[@]}"; do | ||||
|     gpg --output "$TEMPDIR/$key.asc" --armor --export --export-options export-minimal "$key" 2>/dev/null | ||||
|  | ||||
|     # gpg does not give a non-zero return value if it fails to export... | ||||
|     if [[ -f $TEMPDIR/$key.asc ]]; then | ||||
|         msg2 "Exported $key" | ||||
|         mv "$TEMPDIR/$key.asc" "keys/pgp/$key.asc" | ||||
|     else | ||||
|         if [[ -f keys/pgp/$key.asc ]]; then | ||||
|             warning "Failed to update key: $key" | ||||
|         else | ||||
|             error "Key unavailable: $key" | ||||
|             error=1 | ||||
|         fi | ||||
|     fi | ||||
| done | ||||
|  | ||||
| if (( error )); then | ||||
|     die "Failed to export all \'validpgpkeys\' entries." | ||||
| fi | ||||
| @@ -15,7 +15,6 @@ | ||||
| m4_include(lib/base/message.sh) | ||||
|  | ||||
| set -e | ||||
| shopt -s extglob | ||||
|  | ||||
| IGNORE_INTERNAL=0 | ||||
|  | ||||
| @@ -51,9 +50,13 @@ else | ||||
|     pushd "$WORKDIR" >/dev/null | ||||
| fi | ||||
|  | ||||
| shopt -s extglob | ||||
|  | ||||
| process_sofile() { | ||||
|     # extract the library name: libfoo.so | ||||
|     shopt -s extglob nullglob | ||||
|     soname="${sofile%.so?(+(.+([0-9])))}".so | ||||
|     shopt -u extglob nullglob | ||||
|     # extract the major version: 1 | ||||
|     soversion="${sofile##*\.so\.}" | ||||
|     if [[ "$soversion" = "$sofile" ]] && ((IGNORE_INTERNAL)); then | ||||
| @@ -66,6 +69,8 @@ process_sofile() { | ||||
|     fi | ||||
| } | ||||
|  | ||||
| shopt -u extglob | ||||
|  | ||||
| case $script_mode in | ||||
|     deps) find_args=(-perm -u+x);; | ||||
|     provides) find_args=(-name '*.so*');; | ||||
|   | ||||
							
								
								
									
										271
									
								
								bin/pkg/makerepropkg.in
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										271
									
								
								bin/pkg/makerepropkg.in
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,271 @@ | ||||
| #!/bin/bash | ||||
| # | ||||
| # makerepropkg - rebuild a package to see if it is reproducible | ||||
| # | ||||
| # Copyright (c) 2019 by Eli Schwartz <eschwartz@archlinux.org> | ||||
| # | ||||
| # SPDX-License-Identifier: GPL-3.0-or-later | ||||
|  | ||||
| m4_include(lib/util-base.sh) | ||||
| m4_include(lib/base/message.sh) | ||||
| m4_include(lib/base/chroot.sh) | ||||
| m4_include(lib/base/chroot.sh) | ||||
|  | ||||
| declare -A buildinfo | ||||
| declare -a buildenv buildopts installed installpkgs | ||||
|  | ||||
| archiveurl='https://archive.artixlinux.org/packages' | ||||
| buildroot="${CHROOTS_DIR}"/reproducible | ||||
| diffoscope=0 | ||||
|  | ||||
| chroot=$USER | ||||
| [[ -n ${SUDO_USER:-} ]] && chroot=$SUDO_USER | ||||
| [[ -z "$chroot" || $chroot = root ]] && chroot=copy | ||||
|  | ||||
| parse_buildinfo() { | ||||
|     local line var val | ||||
|  | ||||
|     while read -r line; do | ||||
|         var="${line%% = *}" | ||||
|         val="${line#* = }" | ||||
|         case ${var} in | ||||
|             buildenv) | ||||
|                 buildenv+=("${val}") | ||||
|                 ;; | ||||
|             options) | ||||
|                 buildopts+=("${val}") | ||||
|                 ;; | ||||
|             installed) | ||||
|                 installed+=("${val}") | ||||
|                 ;; | ||||
|             *) | ||||
|                 buildinfo["${var}"]="${val}" | ||||
|                 ;; | ||||
|         esac | ||||
|     done | ||||
| } | ||||
|  | ||||
| get_pkgfile() { | ||||
|     local cdir=${cache_dirs[0]} | ||||
|     local pkgfilebase=${1} | ||||
|     local mode=${2} | ||||
|     local pkgname=${pkgfilebase%-*-*-*} | ||||
|     local pkgfile ext | ||||
|  | ||||
|     # try without downloading | ||||
|     if [[ ${mode} != localonly ]] && get_pkgfile "${pkgfilebase}" localonly; then | ||||
|         return 0 | ||||
|     fi | ||||
|  | ||||
|     for ext in .zst .xz ''; do | ||||
|         pkgfile=${pkgfilebase}.pkg.tar${ext} | ||||
|  | ||||
|         for c in "${cache_dirs[@]}"; do | ||||
|             if [[ -f ${c}/${pkgfile} ]]; then | ||||
|                 cdir=${c} | ||||
|                 break | ||||
|             fi | ||||
|         done | ||||
|  | ||||
|         for f in "${pkgfile}" "${pkgfile}.sig"; do | ||||
|             if [[ ! -f "${cdir}/${f}" ]]; then | ||||
|                 if [[ ${mode} = localonly ]]; then | ||||
|                     continue 2 | ||||
|                 fi | ||||
|                 msg2 "retrieving '%s'..." "${f}" >&2 | ||||
|                 curl -Llf -# -o "${cdir}/${f}" "${archiveurl}/${pkgname:0:1}/${pkgname}/${f}" || continue 2 | ||||
|             fi | ||||
|         done | ||||
|         printf '%s\n' "file://${cdir}/${pkgfile}" | ||||
|         return 0 | ||||
|     done | ||||
|  | ||||
|     return 1 | ||||
| } | ||||
|  | ||||
| get_makepkg_conf() { | ||||
|     local fname=${1} | ||||
|     local makepkg_conf="${2}" | ||||
|     if ! buildtool_file=$(get_pkgfile "${fname}"); then | ||||
|         error "failed to retrieve ${fname}" | ||||
|         return 1 | ||||
|     fi | ||||
|     msg2 "using makepkg.conf from ${fname}" | ||||
|     bsdtar xOqf "${buildtool_file/file:\/\//}" usr/share/artools/makepkg.conf > "${makepkg_conf}" | ||||
|     return 0 | ||||
| } | ||||
|  | ||||
| usage() { | ||||
|     cat << __EOF__ | ||||
|     usage: ${BASH_SOURCE[0]##*/} [options] <package_file> | ||||
|  | ||||
|     Run this script in a PKGBUILD dir to build a package inside a | ||||
|     clean chroot while attempting to reproduce it. The package file | ||||
|     will be used to derive metadata needed for reproducing the | ||||
|     package, including the .PKGINFO as well as the buildinfo. | ||||
|  | ||||
|     For more details see https://reproducible-builds.org/ | ||||
|  | ||||
|     OPTIONS | ||||
|         -d            Run diffoscope if the package is unreproducible | ||||
|         -c <dir>      Set pacman cache | ||||
|         -M <file>     Location of a makepkg config file | ||||
|         -l <chroot>   The directory name to use as the chroot namespace | ||||
|                     Useful for maintaining multiple copies | ||||
|                     Default: $chroot | ||||
|         -h            Show this usage message | ||||
| __EOF__ | ||||
| } | ||||
|  | ||||
| while getopts 'dM:c:l:h' arg; do | ||||
|     case "$arg" in | ||||
|         d) diffoscope=1 ;; | ||||
|         M) artixroot_args+=(-M "$OPTARG") ;; | ||||
|         c) cache_dirs+=("$OPTARG") ;; | ||||
|         l) chroot="$OPTARG" ;; | ||||
|         h) usage; exit 0 ;; | ||||
|         *|?) usage; exit 1 ;; | ||||
|     esac | ||||
| done | ||||
| shift $((OPTIND - 1)) | ||||
|  | ||||
| check_root | ||||
|  | ||||
| [[ -f PKGBUILD ]] || { error "No PKGBUILD in current directory."; exit 1; } | ||||
|  | ||||
| # without arguments, get list of packages from PKGBUILD | ||||
| if [[ -z $1 ]]; then | ||||
|     mapfile -t pkgnames < <(source PKGBUILD; pacman -Sddp --print-format '%r/%n' "${pkgname[@]}") | ||||
|     wait $! || { | ||||
|         error "No package file specified and failed to retrieve package names from './PKGBUILD'." | ||||
|         plain "Try '${BASH_SOURCE[0]##*/} -h' for more information." >&2 | ||||
|         exit 1 | ||||
|     } | ||||
|     msg "Reproducing all pkgnames listed in ./PKGBUILD" | ||||
|     set -- "${pkgnames[@]}" | ||||
| fi | ||||
|  | ||||
| # check each package to see if it's a file, and if not, try to download it | ||||
| # using pacman -Sw, and get the filename from there | ||||
| splitpkgs=() | ||||
| for p in "$@"; do | ||||
|     if [[ -f ${p} ]]; then | ||||
|         splitpkgs+=("${p}") | ||||
|     else | ||||
|         pkgfile_remote=$(pacman -Sddp "${p}" 2>/dev/null) || { error "package name '%s' not in repos" "${p}"; exit 1; } | ||||
|         pkgfile=${pkgfile_remote#file://} | ||||
|         if [[ ! -f ${pkgfile} ]]; then | ||||
|             msg "Downloading package '%s' into pacman's cache" "${pkgfile}" | ||||
|             sudo pacman -Swdd --noconfirm --logfile /dev/null "${p}" || exit 1 | ||||
|             pkgfile_remote=$(pacman -Sddp "${p}" 2>/dev/null) | ||||
|             pkgfile="${pkgfile_remote#file://}" | ||||
|         fi | ||||
|         splitpkgs+=("${pkgfile}") | ||||
|     fi | ||||
| done | ||||
|  | ||||
| for f in "${splitpkgs[@]}"; do | ||||
|     if ! bsdtar -tqf "${f}" .BUILDINFO >/dev/null 2>&1; then | ||||
|         error "file is not a valid pacman package: '%s'" "${f}" | ||||
|         exit 1 | ||||
|     fi | ||||
| done | ||||
|  | ||||
| if (( ${#cache_dirs[@]} == 0 )); then | ||||
| 	mapfile -t cache_dirs < <(pacman-conf CacheDir) | ||||
| fi | ||||
|  | ||||
| ORIG_HOME=${HOME} | ||||
| IFS=: read -r _ _ _ _ _ HOME _ < <(getent passwd "${SUDO_USER:-$USER}") | ||||
| load_makepkg_config | ||||
| HOME=${ORIG_HOME} | ||||
| [[ -d ${SRCDEST} ]] || SRCDEST=${PWD} | ||||
|  | ||||
| parse_buildinfo < <(bsdtar -xOqf "${splitpkgs[0]}" .BUILDINFO) | ||||
| export SOURCE_DATE_EPOCH="${buildinfo[builddate]}" | ||||
| PACKAGER="${buildinfo[packager]}" | ||||
| BUILDDIR="${buildinfo[builddir]}" | ||||
| BUILDTOOL="${buildinfo[buildtool]}" | ||||
| BUILDTOOLVER="${buildinfo[buildtoolver]}" | ||||
| PKGEXT=${splitpkgs[0]#${splitpkgs[0]%.pkg.tar*}} | ||||
|  | ||||
| # nuke and restore reproducible testenv | ||||
| namespace="$buildroot/$chroot" | ||||
| lock 9 "${namespace}.lock" "Locking chroot namespace '%s'" "${namespace}" | ||||
| for copy in "${namespace}"/*/; do | ||||
|     [[ -d ${copy} ]] || continue | ||||
|     subvolume_delete_recursive "${copy}" | ||||
| done | ||||
| rm -rf --one-file-system "${namespace}" | ||||
| (umask 0022; mkdir -p "${namespace}") | ||||
|  | ||||
| for fname in "${installed[@]}"; do | ||||
|     if ! allpkgfiles+=("$(get_pkgfile "${fname}")"); then | ||||
|         error "failed to retrieve ${fname}" | ||||
|         exit 1 | ||||
|     fi | ||||
| done | ||||
|  | ||||
| trap 'rm -rf $TEMPDIR' EXIT INT TERM QUIT | ||||
| TEMPDIR=$(mktemp -d --tmpdir makerepropkg.XXXXXXXXXX) | ||||
|  | ||||
| makepkg_conf="${TEMPDIR}/makepkg.conf" | ||||
| # anything before buildtool support is pinned to the last none buildtool aware release | ||||
| if [[ -z "${BUILDTOOL}" ]]; then | ||||
|     get_makepkg_conf "artools-pkg-0.28.2-1-any" "${makepkg_conf}" || exit 1 | ||||
| # prefere to assume artools-pkg up until matching makepkg version so repository packages remain reproducible | ||||
| elif [[ "${BUILDTOOL}" = makepkg ]] && (( $(vercmp "${BUILDTOOLVER}" 6.0.1) <= 0 )); then | ||||
|     get_makepkg_conf "artools-pkg-0.28.2-1-any" "${makepkg_conf}" || exit 1 | ||||
| # all artools-pkg builds | ||||
| elif [[ "${BUILDTOOL}" = artools-pkg ]] && get_makepkg_conf "${BUILDTOOL}-${BUILDTOOLVER}" "${makepkg_conf}"; then | ||||
|     true | ||||
| # fallback to current makepkg.conf | ||||
| else | ||||
|     warning "Unknown buildtool (${BUILDTOOL}-${BUILDTOOLVER}), using fallback" | ||||
|     makepkg_conf="${DATADIR}"/makepkg.conf | ||||
| fi | ||||
| printf '%s\n' "${allpkgfiles[@]}" | mkchroot -M "${makepkg_conf}" -U "${artixroot_args[@]}" "${namespace}/root" - || exit 1 | ||||
|  | ||||
| # use makechrootpkg to prep the build directory | ||||
| mkchrootpkg -r "${namespace}" -l build -- --packagelist || exit 1 | ||||
|  | ||||
| # set detected makepkg.conf options | ||||
| { | ||||
|     for var in PACKAGER BUILDDIR BUILDTOOL BUILDTOOLVER PKGEXT; do | ||||
|         printf '%s=%s\n' "${var}" "${!var@Q}" | ||||
|     done | ||||
|     printf 'OPTIONS=(%s)\n' "${buildopts[*]@Q}" | ||||
|     printf 'BUILDENV=(%s)\n' "${buildenv[*]@Q}" | ||||
| } >> "${namespace}/build"/etc/makepkg.conf | ||||
| install -d -o "${SUDO_UID:-$UID}" -g "$(id -g "${SUDO_UID:-$UID}")" "${namespace}/build/${BUILDDIR}" | ||||
|  | ||||
| bindmounts+=("-B:${PWD}:/startdir" "-B:${SRCDEST}:/srcdest") | ||||
|  | ||||
| # kick off the build | ||||
| chroot-run \ | ||||
|     -b "${bindmounts[*]}" \ | ||||
|     "${namespace}/build" \ | ||||
|     /chrootbuild -C --noconfirm --log --holdver --skipinteg | ||||
| ret=$? | ||||
|  | ||||
| if (( ${ret} == 0 )); then | ||||
|     msg2 "built succeeded! built packages can be found in ${namespace}/build/pkgdest" | ||||
|     msg "comparing artifacts..." | ||||
|  | ||||
|     for pkgfile in "${splitpkgs[@]}"; do | ||||
|         comparefiles=("${pkgfile}" "${namespace}/build/pkgdest/${pkgfile##*/}") | ||||
|         if cmp -s "${comparefiles[@]}"; then | ||||
|             msg2 "Package '%s' successfully reproduced!" "${pkgfile}" | ||||
|         else | ||||
|             ret=1 | ||||
|             warning "Package '%s' is not reproducible. :(" "${pkgfile}" | ||||
|             sha256sum "${comparefiles[@]}" | ||||
|             if (( diffoscope )); then | ||||
|                 diffoscope "${comparefiles[@]}" | ||||
|             fi | ||||
|         fi | ||||
|     done | ||||
| fi | ||||
|  | ||||
| # return failure from chrootbuild, or the reproducibility status | ||||
| exit ${ret} | ||||
| @@ -329,13 +329,14 @@ fi | ||||
| # Pass all arguments after -- right to makepkg | ||||
| makepkg_args+=("${@:$OPTIND}") | ||||
|  | ||||
| # See if -R or -e was passed to makepkg | ||||
| # See if -R, -e or -A was passed to makepkg | ||||
| for arg in "${@:$OPTIND}"; do | ||||
|     case ${arg%%=*} in | ||||
|         --skip*|--holdver) verifysource_args+=("$arg") ;; | ||||
|         --skip*|--holdver|--ignorearch) verifysource_args+=("$arg") ;; | ||||
|         --repackage|--noextract) keepbuilddir=1 ;; | ||||
|         --*) ;; | ||||
|         -*R*|-*e*) keepbuilddir=1 ;; | ||||
|         -*A*) verifysource_args+=(-A) ;;& | ||||
|         -*R*|-*e*) keepbuilddir=1 ;;& | ||||
|     esac | ||||
| done | ||||
|  | ||||
|   | ||||
							
								
								
									
										77
									
								
								bin/pkg/mkdepgraph.in
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										77
									
								
								bin/pkg/mkdepgraph.in
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,77 @@ | ||||
| #!/bin/bash | ||||
| # | ||||
| # Copyright (C) 2018-19 artoo@artixlinux.org | ||||
| # Copyright (C) 2018 Artix Linux Developers | ||||
| # | ||||
| # This program is free software; you can redistribute it and/or modify | ||||
| # it under the terms of the GNU General Public License as published by | ||||
| # the Free Software Foundation; version 2 of the License. | ||||
| # | ||||
| # This program is distributed in the hope that it will be useful, | ||||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| # GNU General Public License for more details. | ||||
|  | ||||
| mk_tree_graph(){ | ||||
|     printf "%s\n" "$(pactree "${tree_args[@]}" "${package}")" \ | ||||
|         | dot -T "${ext}" > "${graph_dir}/${package}.${ext}" | ||||
| } | ||||
|  | ||||
| mk_rebuild_graph(){ | ||||
|     local tmpfile | ||||
|     tmpfile=/tmp/rebuild.dot | ||||
|     rebuild_args+=(-d "${tmpfile}") | ||||
|     artix-rebuild-order "${packages[@]}" "${rebuild_args[@]}" | ||||
|     dot -T "${ext}" "${tmpfile}" > "${graph_dir}/rebuild.${ext}" | ||||
|     rm -f "${tmpfile}" | ||||
| } | ||||
|  | ||||
| usage() { | ||||
|     printf "Usage: %s [options] <package|packages>\n" "${0##*/}" | ||||
|     printf "    -m <tree|rebuild>    default mode: [%s]\n" "$mode" | ||||
|     printf "                         rebuild mode accepts packages input\n" | ||||
|     printf "    -r                   list packages that depend on the named package (tree)\n" | ||||
|     printf "    -u                   show dependencies with no duplicates  (tree)\n" | ||||
|     printf "    -d <#>               limit the depth of recursion  (tree)\n" | ||||
|     printf "                         default: [%s]\n" "$depth" | ||||
|     printf "    -o <#>               controls at which depth to stop printing optional deps\n" | ||||
|     printf "                         default: [%s]\n" "$optdepth" | ||||
|     printf "                         (-1 for no limit)  (tree)\n" | ||||
|     printf "    -i                   only use the pkgnames provided as input (rebuild)\n" | ||||
|     printf "    -h                   display this help message\n" | ||||
|     exit "$1" | ||||
| } | ||||
|  | ||||
| graph_dir=${XDG_PICTURES_DIR:-$(xdg-user-dir PICTURES)/artix} | ||||
| ext="png" | ||||
|  | ||||
| mode=tree | ||||
|  | ||||
| tree_args=(-gs) | ||||
| rebuild_args=() | ||||
|  | ||||
| depth=0 | ||||
| optdepth=-1 | ||||
|  | ||||
| opts=':m:d:o:iruh' | ||||
|  | ||||
| while getopts "$opts" arg; do | ||||
|     case "${arg}" in | ||||
|         m) mode="$OPTARG" ;; | ||||
|         r) tree_args+=(-r) ;; | ||||
|         u) tree_args+=(-ul) ;; | ||||
|         d) depth="$OPTARG"; tree_args+=(-d "$depth") ;; | ||||
|         o) optdepth="$OPTARG"; tree_args+=(-o"$optdepth") ;; | ||||
|         i) rebuild_args+=(--no-reverse-depends) ;; | ||||
|         h|?) usage 0 ;; | ||||
|     esac | ||||
| done | ||||
| shift $(( OPTIND - 1 )) | ||||
|  | ||||
| [[ -d "${graph_dir}" ]] || mkdir -p "${graph_dir}" | ||||
|  | ||||
| case "$mode" in | ||||
|     tree) package=("$@"); mk_tree_graph ;; | ||||
|     rebuild) packages=("$@"); mk_rebuild_graph ;; | ||||
|     *) usage 1 ;; | ||||
| esac | ||||
| @@ -7,47 +7,13 @@ | ||||
|  | ||||
| # TREE_DIR_ARTIX=${WORKSPACE_DIR}/artixlinux | ||||
|  | ||||
| # customize buildtree; uncomment to include | ||||
| # TREE_NAMES_ARTIX=( | ||||
| #         packages-kernel | ||||
| #         packages-llvm | ||||
| #         packages-openrc | ||||
| #         packages-runit | ||||
| #         packages-s6 | ||||
| #         packages-suite66 | ||||
| #         packages-dinit | ||||
| #         packages-perl | ||||
| #         packages-java | ||||
| #         packages-ruby | ||||
| #         packages-gtk | ||||
| #         packages-qt5 | ||||
| #         packages-qt6 | ||||
| #         packages-xorg | ||||
| #         packages-plasma | ||||
| #         kde-utils | ||||
| #         kde-devel | ||||
| #         kde-media | ||||
| #         kde-games | ||||
| #         kde-edu | ||||
| #         kde-net | ||||
| #         kde-pim | ||||
| #         packages-gnome | ||||
| #         packages-cinnamon | ||||
| #         packages-lxqt | ||||
| #         packages-lxde | ||||
| #         packages-mate | ||||
| #         packages-xfce | ||||
| #         packages-wm | ||||
| #         packages-devel | ||||
| #         packages-qt6 | ||||
| #         packages-office | ||||
| #         packages-misc | ||||
| #         python-world | ||||
| #         python-galaxy | ||||
| #         python-galaxy-groups | ||||
| #         python-misc | ||||
| #         packages-python | ||||
| #         packages-lib32 | ||||
| # customize buildtree | ||||
| # ARTIX_TREE=( | ||||
| #     main | ||||
| #     initsys | ||||
| #     desktop | ||||
| #     addons | ||||
| #     lib32 | ||||
| # ) | ||||
|  | ||||
| # TREE_DIR_ARCH=${WORKSPACE_DIR}/archlinux | ||||
|   | ||||
| @@ -45,13 +45,14 @@ CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions \ | ||||
|         -fstack-clash-protection -fcf-protection" | ||||
| CXXFLAGS="$CFLAGS -Wp,-D_GLIBCXX_ASSERTIONS" | ||||
| LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now" | ||||
| #RUSTFLAGS="-C opt-level=2" | ||||
| LTOFLAGS="-flto=auto" | ||||
| RUSTFLAGS="" | ||||
| #-- Make Flags: change this for DistCC/SMP systems | ||||
| #MAKEFLAGS="-j2" | ||||
| #-- Debugging flags | ||||
| DEBUG_CFLAGS="-g" | ||||
| DEBUG_CXXFLAGS="-g" | ||||
| #DEBUG_RUSTFLAGS="-C debuginfo=2" | ||||
| DEBUG_CXXFLAGS="$DEBUG_CFLAGS" | ||||
| DEBUG_RUSTFLAGS="-C debuginfo=2" | ||||
|  | ||||
| ######################################################################### | ||||
| # BUILD ENVIRONMENT | ||||
|   | ||||
| @@ -9,8 +9,6 @@ | ||||
|  | ||||
| export LANG=C | ||||
|  | ||||
| shopt -s extglob | ||||
|  | ||||
| if [[ -t 2 && "$TERM" != dumb ]]; then | ||||
|     colorize | ||||
| else | ||||
|   | ||||
| @@ -5,7 +5,8 @@ | ||||
| get_compliant_name(){ | ||||
|     local gitname="$1" | ||||
|     case "$gitname" in | ||||
|         *+) gitname=${gitname//+/plus} | ||||
|         *+) gitname=${gitname//+/plus} ;; | ||||
|         *+*) gitname=${gitname//+/-} ;; | ||||
|     esac | ||||
|     printf "%s\n" "$gitname" | ||||
| } | ||||
|   | ||||
| @@ -2,6 +2,8 @@ | ||||
|  | ||||
| #{{{ functions | ||||
|  | ||||
| shopt -s extglob | ||||
|  | ||||
| find_cached_pkgfile() { | ||||
|     local searchdirs=("$PKGDEST" "$PWD") results=() | ||||
|     local pkg="$1" | ||||
| @@ -25,6 +27,8 @@ find_cached_pkgfile() { | ||||
|     esac | ||||
| } | ||||
|  | ||||
| shopt -u extglob | ||||
|  | ||||
| get_pkgbasename() { | ||||
|     local name="$1" | ||||
|     local rm_pkg=${name%.pkg.tar*} | ||||
|   | ||||
							
								
								
									
										75
									
								
								lib/pkg/diff.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										75
									
								
								lib/pkg/diff.sh
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,75 @@ | ||||
| #!/hint/bash | ||||
|  | ||||
| #{{{ functions | ||||
|  | ||||
| pkgver_equal() { | ||||
|     if [[ $1 = *-* && $2 = *-* ]]; then | ||||
|         # if both versions have a pkgrel, then they must be an exact match | ||||
|         [[ $1 = "$2" ]] | ||||
|     else | ||||
|         # otherwise, trim any pkgrel and compare the bare version. | ||||
|         [[ ${1%%-*} = "${2%%-*}" ]] | ||||
|     fi | ||||
| } | ||||
|  | ||||
| shopt -s extglob | ||||
|  | ||||
| find_cached_package() { | ||||
|     local searchdirs=("$PWD" "$PKGDEST") results=() | ||||
|     local targetname=$1 targetver=$2 targetarch=$3 | ||||
|     local dir pkg packages pkgbasename name ver rel arch r results | ||||
|  | ||||
|     for dir in "${searchdirs[@]}"; do | ||||
|         [[ -d $dir ]] || continue | ||||
|  | ||||
|         shopt -s extglob nullglob | ||||
|         mapfile -t packages < <(printf "%s\n" "$dir"/"${targetname}"-"${targetver}"-*"${targetarch}".pkg.tar?(.!(sig|*.*))) | ||||
|         shopt -u extglob nullglob | ||||
|  | ||||
|         for pkg in "${packages[@]}"; do | ||||
|             [[ -f $pkg ]] || continue | ||||
|  | ||||
|             # avoid adding duplicates of the same inode | ||||
|             for r in "${results[@]}"; do | ||||
|                 [[ $r -ef $pkg ]] && continue 2 | ||||
|             done | ||||
|  | ||||
|             # split apart package filename into parts | ||||
|             pkgbasename=${pkg##*/} | ||||
|             pkgbasename=${pkgbasename%.pkg.tar*} | ||||
|  | ||||
|             arch=${pkgbasename##*-} | ||||
|             pkgbasename=${pkgbasename%-"$arch"} | ||||
|  | ||||
|             rel=${pkgbasename##*-} | ||||
|             pkgbasename=${pkgbasename%-"$rel"} | ||||
|  | ||||
|             ver=${pkgbasename##*-} | ||||
|             name=${pkgbasename%-"$ver"} | ||||
|  | ||||
|             if [[ $targetname = "$name" && $targetarch = "$arch" ]] && | ||||
|                 pkgver_equal "$targetver" "$ver-$rel"; then | ||||
|                 results+=("$pkg") | ||||
|             fi | ||||
|         done | ||||
|     done | ||||
|  | ||||
|     case ${#results[*]} in | ||||
|         0) | ||||
|             return 1 | ||||
|         ;; | ||||
|         1) | ||||
|             printf '%s\n' "${results[0]}" | ||||
|             return 0 | ||||
|         ;; | ||||
|         *) | ||||
|             error 'Multiple packages found:' | ||||
|             printf '\t%s\n' "${results[@]}" >&2 | ||||
|             return 1 | ||||
|         ;; | ||||
|     esac | ||||
| } | ||||
|  | ||||
| shopt -u extglob | ||||
|  | ||||
| #}}} | ||||
| @@ -31,7 +31,7 @@ write_agentyaml(){ | ||||
|     git add "$agent" | ||||
| } | ||||
|  | ||||
| commit_jenkins_files(){ | ||||
| commit_ci(){ | ||||
|     local pkg="$1" | ||||
|  | ||||
|     write_jenkinsfile "$pkg" | ||||
|   | ||||
| @@ -25,9 +25,9 @@ set_arch_repos(){ | ||||
| find_repo(){ | ||||
|     local pkg="$1" pkgarch="${2:-${CARCH}}" repo | ||||
|     for r in "${ARCH_REPOS[@]}"; do | ||||
|         [[ -f $pkg/repos/$r-$pkgarch/PKGBUILD ]] && repo=repos/"$r-$pkgarch" | ||||
|         [[ -f $pkg/repos/$r-any/PKGBUILD ]] && repo=repos/"$r"-any | ||||
|         [[ -f $pkg/$pkgarch/$r/PKGBUILD ]] && repo="$pkgarch/$r" | ||||
|         [[ -f $pkg/repos/$r-$pkgarch/PKGBUILD ]] && repo="$r-$pkgarch" | ||||
|         [[ -f $pkg/repos/$r-any/PKGBUILD ]] && repo="$r"-any | ||||
|         [[ -f $pkg/$pkgarch/$r/PKGBUILD ]] && repo="$r" | ||||
|     done | ||||
|     printf "%s\n" "$repo" | ||||
| } | ||||
| @@ -42,8 +42,8 @@ tree_loop(){ | ||||
|     local func="$1" pkgs | ||||
|     for tree in "${ARTIX_TREE[@]}"; do | ||||
|         mapfile -t pkgs < <(find "${TREE_DIR_ARTIX}/$tree" -name "$CARCH" | sort) | ||||
|         for _package in "${pkgs[@]}"; do | ||||
|             "$func" "$_package" | ||||
|         for p in "${pkgs[@]}"; do | ||||
|             "$func" "$p" | ||||
|         done | ||||
|     done | ||||
| } | ||||
|   | ||||
| @@ -21,35 +21,8 @@ load_pkg_config(){ | ||||
|  | ||||
|     TREE_DIR_ARTIX=${TREE_DIR_ARTIX:-"${WORKSPACE_DIR}/artixlinux"} | ||||
|  | ||||
|     ARTIX_TREE=( | ||||
|         packages community | ||||
|         packages-{llvm,gfx,media,net} | ||||
|     ) | ||||
|  | ||||
|     local dev_tree=( | ||||
|         packages-{python,perl,java,ruby,misc} | ||||
|         python-{world,galaxy,galaxy-groups,misc} | ||||
|     ) | ||||
|  | ||||
|     local init_tree=(packages-{openrc,runit,s6,suite66,dinit}) | ||||
|  | ||||
|     local desktop_tree=( | ||||
|         packages-{xorg,gtk,qt5,qt6,kf5,plasma} | ||||
|         kde-{utils,devel,net,pim,media,edu,games} | ||||
|         packages-{lxqt,gnome,cinnamon,mate,xfce,wm,lxde} | ||||
|     ) | ||||
|  | ||||
|     [[ -z ${TREE_NAMES_ARTIX[*]} ]] && \ | ||||
|     TREE_NAMES_ARTIX=( | ||||
|         packages-kernel | ||||
|         "${init_tree[@]}" | ||||
|         "${dev_tree[@]}" | ||||
|         "${desktop_tree[@]}" | ||||
|         packages-devel | ||||
|         packages-lib32 | ||||
|     ) | ||||
|  | ||||
|     ARTIX_TREE+=("${TREE_NAMES_ARTIX[@]}") | ||||
|     [[ -z ${ARTIX_TREE[*]} ]] && \ | ||||
|     ARTIX_TREE=(main initsys desktop addons lib32) | ||||
|  | ||||
|     TREE_DIR_ARCH=${TREE_DIR_ARCH:-"${WORKSPACE_DIR}/archlinux"} | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user