# HG changeset patch # User Aleksej Bobylev # Date 1490369356 -7200 # Node ID 2ff4c8d701d328f48d0d6432e6e8a7b7c207cb5b # Parent eff71eaaee4ff9145f2ae25355f2ea2fa1023a00 cook: fix copy() -> cook_copy_folders() for repeated copying; web/cooker.cgi: manage packages with '+' in the name; web/style.css: get styles from mirror1. diff -r eff71eaaee4f -r 2ff4c8d701d3 cook --- a/cook Mon Mar 20 05:12:29 2017 +0200 +++ b/cook Fri Mar 24 17:29:16 2017 +0200 @@ -403,10 +403,10 @@ # A bit smarter function than the classic `cp` command copy() { - if [ "$(stat -c %h -- "$1")" -gt 1 ]; then + if [ -d "$1" -o "$(stat -c %h -- "$1")" -eq 1 ]; then + cp -a "$1" "$2" # copy folders and generic files + else cp -al "$1" "$2" # copy hardlinks - else - cp -a "$1" "$2" # copy generic files fi } @@ -782,6 +782,68 @@ } +# Receipt used for cooking the package is redundant to be included into package. +# This script will strip the original receipt to bare minimum: variables, +# {pre,post}_{install,remove} functions. + +mk_pkg_receipt() { + orig_receipt="$1" + # $pkg is package name + + # Receipt's signature is important, although some receipts may miss it + signature=$(head -n1 "$orig_receipt") + [ "${signature:0:1}" == '#' ] || signature='# SliTaz package receipt.' + + . "$orig_receipt" + + # Is package splitted one? + [ -n "$SPLIT" -a "${SPLIT/$pkg/}" != "$SPLIT" ]; splitted=$? + + # Manage splitted packages + if $splitted; then + # For packages with empty $DEPENDS + [ -n "$DEPENDS" ] || DEPENDS="$PACKAGE" + + # Default $CAT + [ -z "$CAT" ] && + case $pkg in + *-dev) CAT="development|development files" ;; + esac + + # Manage $CAT + CATEGORY="${CAT%|*}" + SHORT_DESC="$SHORT_DESC (${CAT#*|})" + fi + + # Mandatory variables + cat </dev/null)" ]; then - md2html="$(which cmark) --smart" + md2html="$(which cmark) --smart -e table -e strikethrough -e autolink -e tagfilter" elif [ -x "./cmark" ]; then - md2html="./cmark --smart" + md2html="./cmark --smart -e table -e strikethrough -e autolink -e tagfilter" elif [ -n "$(which sundown 2>/dev/null)" ]; then md2html=$(which sundown) elif [ -x "./sundown" ]; then @@ -131,13 +131,15 @@ mm=$(echo $time | cut -d: -f2) ss=$(echo $time | cut -d: -f3) date_s=$(date -ud "$year$mon$day$hh$mm.$ss" +%s) - if [ "$date_s" -ge "$(date -ur "$file" +%s)" ]; then - echo -e 'HTTP/1.1 304 Not Modified\n' - exit - fi +# if [ "$date_s" -ge "$(date -ur "$file" +%s)" ]; then +# echo -e 'HTTP/1.1 304 Not Modified\n' +# exit +# fi +# TODO: improve caching control done fi echo "Last-Modified: $(date -Rur "$file" | sed 's|UTC|GMT|')" + echo "Cache-Control: public, max-age=3600" } @@ -145,8 +147,8 @@ recook=*) case "$HTTP_USER_AGENT" in *SliTaz*) - grep -qs "^${QUERY_STRING#recook=}$" $CACHE/recook-packages || - echo ${QUERY_STRING#recook=} >> $CACHE/recook-packages + grep -qs "^$(GET recook)$" $CACHE/recook-packages || + echo "$(GET recook)" >> $CACHE/recook-packages esac echo -e "Location: ${HTTP_REFERER:-${REQUEST_URI%\?*}}\n" exit @@ -159,7 +161,7 @@ ;; src*) - file=$(busybox httpd -d "$SRC/${QUERY_STRING#*=}") + file=$(busybox httpd -d "$SRC/$(GET src)") manage_modified "$file" content_type='application/octet-stream' case $file in @@ -171,7 +173,8 @@ esac echo "Content-Type: $content_type" echo "Content-Length: $(stat -c %s "$file")" - echo "Content-Disposition: attachment; filename=\"$(basename "$file")\"" + filename=$(basename "$file") + echo "Content-Disposition: attachment; filename=\"$filename\"" # Note, no conversion '+' -> '%2B' here echo cat "$file" @@ -179,7 +182,7 @@ ;; download*) - file=$(busybox httpd -d "$PKGS/${QUERY_STRING#*=}") + file="$PKGS/$(GET download)" manage_modified "$file" content_type='application/octet-stream' case $file in @@ -201,7 +204,8 @@ echo "Content-Type: $content_type" echo "Content-Length: $(stat -c %s "$file")" - echo "Content-Disposition: inline; filename=\"$(basename "$file")\"" + filename=$(basename "$file") + echo "Content-Disposition: inline; filename=\"$filename\"" # Note, no conversion '+' -> '%2B' here echo cat "$file" @@ -213,7 +217,7 @@ ;; stuff*) - file="$wok/${QUERY_STRING#stuff=}" + file="$wok/$(GET stuff)" manage_modified "$file" ;; @@ -284,20 +288,21 @@ info2html() { sed \ - -e 's|&|\&|g' -e 's|<|\<|g' \ + -e 's|&|\&|g; s|<|\<|g; s|>|\>|g' \ -e 's|^\* \(.*\)::|* \1 |' \ -e 's|\*note \(.*\)::|\1|' \ - -e '/^File: /s|(dir)|Top|g' \ - -e '/^File: /s|Node: \([^,]*\)|Node: \1|' \ - -e '/^File: /s|Next: \([^,]*\)|Next: \1|' \ - -e '/^File: /s|Prev: \([^,]*\)|Prev: \1|' \ - -e '/^File: /s|Up: \([^,]*\)|Up: \1|' \ - -e '/^File: /s|^.*$|&|' \ + -e '/^File: / s|(dir)|Top|g' \ + -e '/^File: / s|Next: \([^,]*\)|Next: \1|' \ + -e '/^File: / s|Prev: \([^,]*\)|Prev: \1|' \ + -e '/^File: / s|Up: \([^,]*\)|Up: \1|' \ + -e '/^File: / s|^.* Node: \([^,]*\), *\(.*\)$|
\2|' \
+		-e '/^
]*>\)\(]*>Next: [^,]*\), *\(]*>Prev: [^,]*\), *\(]*>Up: .*\)|\1 \3 \4 \2|' \
 		-e '/^Tag Table:$/,/^End Tag Table$/d' \
 		-e '/INFO-DIR/,/^END-INFO-DIR/d' \
-		-e "s|https*://[^>),'\"\` ]*|&|g" \
+		-e "s|https*://[^>),'\"\`’ ]*|&|g" \
 		-e "s|ftp://[^>),\"\` ]*|&|g" \
-		-e "s|^|
|"
+		-e 's|^\* Menu:|Menu:|' \
+		-e "s|^|
|" } @@ -474,7 +479,7 @@ cmd=${QUERY_STRING%%=*} echo '
' active=''; [ "$cmd" == 'receipt' -o "$cmd" == 'stuff' ] && active=' active' - echo "receipt & stuff" + echo "receipt & stuff" unset WEB_SITE WANTED bpkg=$pkg @@ -487,27 +492,27 @@ if [ -f "$wok/$pkg/taz/$PACKAGE-$VERSION/receipt" ]; then active=''; [ "$cmd" == 'files' ] && active=' active' - echo "files" + echo "files" unset EXTRAVERSION . $wok/$pkg/taz/$PACKAGE-$VERSION/receipt if [ -f $wok/$pkg/taz/$PACKAGE-$VERSION/description.txt ]; then active=''; [ "$cmd" == 'description' ] && active=' active' - echo "description" + echo "description" fi if [ -f $PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg ]; then - echo "download" + echo "download" fi if [ -f $PKGS/$PACKAGE-$VERSION$EXTRAVERSION-$ARCH.tazpkg ]; then - echo "download" + echo "download" fi fi [ -n "$TARBALL" ] && [ -s "$SRC/$TARBALL" ] && - echo "source" + echo "source" [ -x ./man2html ] && if [ -d $wok/$bpkg/install/usr/man ] || @@ -515,7 +520,7 @@ [ -d $wok/$bpkg/taz/*/fs/usr/man ] || [ -d $wok/$bpkg/taz/*/fs/usr/share/man ]; then active=''; [ "$cmd" == 'man' ] && active=' active' - echo "man" + echo "man" fi if [ -d $wok/$bpkg/install/usr/doc ] || @@ -523,7 +528,7 @@ [ -d $wok/$bpkg/taz/*/fs/usr/doc ] || [ -d $wok/$bpkg/taz/*/fs/usr/share/doc ]; then active=''; [ "$cmd" == 'doc' ] && active=' active' - echo "doc" + echo "doc" fi if [ -d $wok/$bpkg/install/usr/info ] || @@ -531,15 +536,15 @@ [ -d $wok/$bpkg/taz/*/fs/usr/info ] || [ -d $wok/$bpkg/taz/*/fs/usr/share/info ]; then active=''; [ "$cmd" == 'info' ] && active=' active' - echo "info" + echo "info" fi [ -n "$(echo $REQUEST_URI | sed 's|/[^/]*?pkg.*||')" ] || - echo "browse" + echo "browse" if [ -s "$log" ]; then active=''; [ "$cmd" == 'log' ] && active=' active' - echo "logs" + echo "logs" fi echo '
' @@ -556,7 +561,7 @@ case "${QUERY_STRING}" in pkg=*) - pkg=${QUERY_STRING#pkg=} + pkg=$(GET pkg) log=$LOGS/$pkg.log # Define cook variables for syntax highlighter @@ -614,7 +619,7 @@ ;; log=*) - log=${QUERY_STRING#log=} + log=$(GET log) logfile=$LOGS/$log pkg=${log%.log*} if [ -s "$logfile" ]; then @@ -629,7 +634,8 @@ esac for i in $(ls -t $baselog $baselog.* 2>/dev/null); do class=''; [ $i == $logfile ] && class=' gray' - echo -n "" + j=$(basename "$i") + echo -n "" echo "$(stat -c %y $i | cut -d: -f1,2)" done @@ -646,7 +652,7 @@ file=*) echo "
" # Don't allow all files on the system for security reasons. - file=${QUERY_STRING#file=} + file=$(GET file) case "$file" in activity|cooknotes|cooklist) [ "$file" == "cooklist" ] && \ @@ -693,17 +699,17 @@ stuff=*) echo "
" - file=${QUERY_STRING#stuff=} + file=$(GET stuff) pkg=${file%%/*} if [ -f "$wok/$file" ]; then echo "

$file

" pkg_info - echo "receipt" + echo "receipt" ( cd $wok/$pkg ; find stuff -type f 2> /dev/null ) | sort | \ while read i ; do class=''; [ "$pkg/$i" == "$file" ] && class=" green" - echo "$i" + echo "$i" done case $file in @@ -742,7 +748,7 @@ # Display image case $file in *.png|*.svg|*.jpg|*.jpeg|*.ico) - echo "" + echo "" ;; esac @@ -767,22 +773,22 @@ receipt=*) echo "
" - pkg=${QUERY_STRING#receipt=} + pkg=$(GET receipt) echo "

Receipt for: $pkg

" pkg_info - echo "receipt" + echo "receipt" . $wok/$pkg/receipt ( cd $wok/$pkg; find stuff -type f 2> /dev/null ) | sort | \ while read file; do - echo "$file" + echo "$file" done | sort cat $wok/$pkg/receipt | show_code bash ;; files=*) echo "
" - pkg=${QUERY_STRING#files=} + pkg=$(GET files) dir=$(ls -d $WOK/$pkg/taz/$pkg-* 2>/dev/null) size=$(du -hs $dir/fs | awk '{ print $1 }') echo "

Files installed by the package \"$pkg\" ($size)

" @@ -793,14 +799,18 @@ find $dir/fs -not -type d -print0 | sort -z | \ xargs -0 ls -ld --color=always | \ syntax_highlighter files | \ - sed "s|\([^/]*\)/.*\(${dir#*wok}/fs\)\([^<]*\)\(<.*\)$|\1\3\4|" + sed "s|\([^/]*\)/.*\(${dir#*wok}/fs\)\([^<]*\)\(<.*\)$|\1\3\4|" |\ + awk ' + BEGIN { FS="\""; } + { gsub("+", "%2B", $2); print; } + ' echo '
' ;; description=*) echo "
" - pkg=${QUERY_STRING#description=} + pkg=$(GET description) dir=$(ls -d $WOK/$pkg/taz/$pkg-* 2>/dev/null) echo "

Description of $pkg

" pkg_info @@ -849,7 +859,7 @@ ;; info) info=$(basename $i) - echo "${info/.info/}" + echo "${info/.info/}" ;; *) echo "$(basename $i .gz)" @@ -864,14 +874,14 @@ [ -s "$tmp" ] && case "$type" in info) - echo '
' - echo '
'
+					echo '
'
 					info2html < "$tmp"
 					echo '
' ;; doc) case "$page" in *.sgml) class='xml';; + *.py) class='python';; # pycurl package *) class='asciidoc';; esac case "$page" in @@ -979,7 +989,7 @@ EOT tac $CACHE/activity | head -n 12 | syntax_highlighter activity | \ - sed 's|cooker.cgi||; s|^|
  • |; s|$|
  • |' + sed 's|cooker.cgi||; s|^|
  • |; s|$|
  • |;' echo '' @@ -1024,7 +1034,8 @@ cat <Latest cook
      -$(list_packages | sed "s|^.* :|\0 |g; s|^|
    • |; s|$|
    • |") +$(list_packages | sed 's|.tazpkg$||' | \ +sed "s|^.* :|\0 |g; s|^|
    • |; s|$|
    • |")
    EOT diff -r eff71eaaee4f -r 2ff4c8d701d3 web/style.css --- a/web/style.css Mon Mar 20 05:12:29 2017 +0200 +++ b/web/style.css Fri Mar 24 17:29:16 2017 +0200 @@ -19,64 +19,60 @@ a:hover { text-decoration: underline; } .files a { text-decoration: none; color: inherit; } .files a:hover { text-decoration: underline; } -hr { margin: 0; border: 1px solid #CFCFCF; } +hr { margin: 0; border: 1px solid #cfcfcf; } pre { - background-color: #F8F8F8; - border: 1px solid #DDD; + background-color: #f8f8f8; + border: 1px solid #ddd; padding: 8px; overflow: auto; } /* Header */ - -#header { - color: #FFF; - background: #222; - height: 40px; - border-bottom: 3px solid #AAA; +body>header { + display:block; + background:#444; + text-align:justify; + line-height:0; + box-shadow:0 -8px 8px #333 inset } - -#header h1 { - margin: 0; - padding: 8px 0 0 42px; - color: #FFF; - font-size: 20px; - width: 250px; +h1 { + display:inline-block; + margin:auto 0; + height:40px; + white-space:nowrap; + vertical-align:middle } -#logo { - background: url(/images/logo.png) no-repeat left; - position: absolute; - float: left; - left: 0px; - top: 0px; - width: 40px; - height: 40px; +h1::before { + display:inline-block; + content:url(images/logo.png); + vertical-align:middle } - -#header h1 a { - color: #FFF; - text-decoration: none; - font-size: 20px; - font-style: italic; +h1 a { + color:#FFF; + font-size:20px; + font-style:italic } - -#header h1 a:hover, #network a:hover { - color: #AFAFAF; +body>header::before,body>header::after,.block>div::before,.block>div::after { + display:inline-block; + width:100%; + height:0; + visibility:hidden; + overflow:hidden; + content:'' } - -/* Header links */ - -#network { - float: right; - padding: 14px 5px 0; - font-size: 12px; +.network { + display:inline-block; + text-align:left; + vertical-align:middle; + font-size:12px; + line-height:normal; + color:#999 } - -#network a { - padding: 0 4px; - color: #FFF; - font-weight: bold; - text-decoration: none; +.network a { + display:inline-block; + padding:0 6px; + vertical-align:middle; + color:#FFF } /* Content */ @@ -86,22 +82,22 @@ padding: 0.5em; } #content2 { - width: 100%; + width: 100%; box-sizing: border-box; max-width: 700px; margin: auto; padding: 0.5em; } -.span-ok { color: #0A0; } +.span-ok { color: #0a0; } .span-red { color: red; } .span-sky { color: blue; } -.span-no { color: #D90; } +.span-no { color: #d90; } .span-line { color: #888; } .log-date { color: #666; font-size: 95%; } -.sh-comment { color: #A00; } -.sh-val { color: #E50; font-weight: bold; } -.var { color: #05A; } +.sh-comment { color: #a00; } +.sh-val { color: #e50; font-weight: bold; } +.var { color: #05a; } /* Buttons */ @@ -117,7 +113,7 @@ } .pct { - background: #9DFF4A; + background: #9dff4a; background-image: -webkit-linear-gradient(#CDFFA3, #9DFF4A 40%, #87DB40); background-image: -moz-linear-gradient(#CDFFA3, #9DFF4A 40%, #87DB40); padding: 2px 4px; @@ -160,7 +156,7 @@ #footer { text-align: center; padding: 20px 0; - border-top: 1px solid #DDD; + border-top: 1px solid #ddd; font-size: 90%; /* position: absolute;*/ bottom: 0; @@ -170,12 +166,30 @@ #footer a { padding: 0 2px; } +body>footer { + background:#f1f1f1; + text-align:center; + border-top:1px solid #CCC; + padding:6px; + color:#666; + clear:both; + box-shadow:0 4px 8px #CCC inset +} + +footer a+a::before { display: inline-block; content: '• '; color: #E81; } + +body>footer div { + margin:12px +} + + + .log a { text-decoration: none; color: #666; } .log a:hover { color: #000; } .activity { padding-left: 0.5em; } .activity li { list-style-type: none; } -.activity li::before { color: #666; content: "•"; padding-right: 0.5em; } +.activity li:before { color: #666; content: "•"; padding-right: 0.5em; } .r { float: right; } @@ -193,4 +207,59 @@ a:target {background-color: yellow; } -pre.info { color: #FFF; background-color: #272822; } + +/* +table { + border-spacing: 0; + padding: 0 2px; + border-width: 1px; + border-color: #666; + border-radius: 4px; + border-style: solid; +} +th { + background-color: #CCC; +} +td { + border-bottom: 1px solid #79B; + padding: 2px; +} +tr:last-child td { + border-bottom: unset; +} +*/ + +table { + /*width: 100%;*/ + border: 1px solid #CCC; + border-radius: 4px; + border-spacing: 0; + padding: 0; +} +tr { + margin: 0; + padding: 2px; +} +td { + margin: 0; + padding: 3px; + vertical-align: top; + line-height: 1.1; +} +thead tr { + background-color:#DDD +} +thead th { + border-bottom:1px solid #BBB +} + +tbody tr:nth-child(odd) { background-color: #FFFFFF; } +tbody tr:nth-child(even) { background-color: #ECECEC; } + +#content, #content2 { + min-height: 80vh; +} + +.texinfo pre { display: none; } +/*.texinfo pre.first:not(:target) { display: block; }*/ +.texinfo pre:target { display: block; }